Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // String Input 1 //
- InputStreamReader isr = new InputStreamReader(System.in);
- BufferedReader in = new BufferedReader(isr);
- String str;
- str = in.readLine();
- System.out.println(str);
- // String Input 2 //
- Scanner scan = new Scanner(System.in);
- String str = scan.nextLine();
- System.out.println(str);
- // if String equals //
- if(str.equals("apple"))
- // Converting to Int //
- int num = Integer.parseInt(str);
- // Random number //
- Random r = new Random();
- int randomNum = Math.abs(r.nextInt() % 3); // 0 -> 2
- // Formula for percentage //
- DecimalFormat fmt = new DecimalFormat("###.#%");
- System.out.println(fmt.format(30.0/80.0));
- -------------> 37.5%
Advertisement
Add Comment
Please, Sign In to add comment