0

program about students grants

import java.util.Scanner; public class main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Input a number: "); double num = in.nextInt(); if (num>3.5) { System.out.print("Congratulations!"); } else if (num<3.5) { System.out.print("Sorry,try again"); } } } This program work only when i imput 1,2,3,4,5 , but not work when i try 1.1 1.2, why?

24th Oct 2020, 2:02 PM
Ar4i Epic
Ar4i Epic - avatar
1 Odpowiedź
+ 1
Use in.nextDouble() instead of in.nextInt().
24th Oct 2020, 2:09 PM
Ipang