Java Stdin and Stdout II

Sort by

recency

|

1183 Discussions

|

  • + 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.
    
    
    
    
    
    
    }
    

    }

  • + 0 comments

    Hi @Everyone can you please explain me how they are take input without any code

  • + 0 comments
    import java.util.Scanner;
    
    public class Solution {
    
        public static void main(String[] args) {
            Scanner scan = new Scanner(System.in); 
            int i = scan.nextInt();
            double d=scan.nextDouble();
            scan.next();
            String s =scan.nextLine();
            // Write your code here.
    
            System.out.println("String: " + s);
            System.out.println("Double: " + d);
            System.out.println("Int: " + i);
        }
    }
    
  • + 0 comments

    import java.util.Scanner;

    public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();  
          double d=scan.nextDouble();
         scan.nextLine();//ye next isliya dee h kyuki ye integer value le rahe tha isko khtm karne ke liya next 
                 line dee h
    

    String s=scan.nextLine();

        // Write your code here.
    
        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
    

    }

  • + 0 comments

    this is the solution import java.util.Scanner;

    public class Solution {

    public static void main(String[] args) { Scanner scan = new Scanner(System.in); int i = scan.nextInt(); double d = scan.nextDouble(); scan.nextLine(); String str= scan.nextLine();
    scan.close();

    // Write your code here.
    
    System.out.println("String: " + str);
    System.out.println("Double: " + d);
    System.out.println("Int: " + i);
    

    } }