0

* and / using scanner

How can I * or / using scanner? I have defined int day = scanner.nextint(); Day = 10 System.out.println(Day); And when I run program whatever I write for example 3 or 5 result of program will be always 10. I want it to be 30 or 50. How can I do this ?

5th Aug 2021, 6:25 PM
mzurek79
mzurek79 - avatar
3 Respuestas
+ 3
Try this int day = scanner.nextInt(); int Day = 10; System.out.println(Day*day); //System.out.println(Day/day);
6th Aug 2021, 2:05 AM
Simba
Simba - avatar
+ 1
// and it works ;););) you can check how many seconds has 10 days for example ;););) thx import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int second = 1; int minute = 60* second; int hour = 60 * minute; int day = 24 * hour; System.out.println( days * day); //your code goes here } }
6th Aug 2021, 7:18 AM
mzurek79
mzurek79 - avatar