Java Stdin and Stdout II

  • + 0 comments

    import java.util.*; import java.math.BigDecimal;

    public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s="";
        int c=0;
        String[] arr = new String[3];
    
        // double d = scan.nextInt();
        // int i = scan.nextInt();
    
        while(scan.hasNext()) {
            s = scan.nextLine();
    
          arr[c]= s;
    
               c++;
        }
    
        for (int i = arr.length; i >= 0;i--) {
           if (i==2) {
                System.out.println("String: " + arr[i]);
            } else if (i==1) {
                System.out.println("Double: " + 
                Double.parseDouble(arr[i]));
            }  else if (i==0) {
                System.out.println("Int: " + arr[i]);
            } 
        }
    
    
        // Write your code here.
    
    
    
    
    
    
    }
    

    }