Pages

Thursday, March 20, 2025

Scanner in Java!

 import java.util.*;


public class JavaBasics {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
            // String input = sc.next();
            // System.out.println(input);


            // String name = sc.nextLine();
            // System.out.println(name);

        int number = sc.nextInt();
        System.out.println(number);

        float price = sc.nextFloat();
        System.out.println(price);
    }

}



Practice questions to strengthen this part of concept, it will help a-lot.

No comments:

Post a Comment

3917. Count Indices With Opposite Parity (Brute Force) O(n2) + Optimized Solution O(n) + tips LEETCODE WEEKLY 500

  class Solution {     public int [] countOppositeParity ( int [] nums ) {          // approach 1 - checks every pair         int n = n...