KaiquanMah commited on
Commit
ec73a3d
·
verified ·
1 Parent(s): 5ce8dad

int days = Integer.valueOf(reader.nextLine())

Browse files
Week 1: Types, condition clauses and loops/7. Minutes in a day ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Write a program that asks the user to enter the number of days (integer). The program calculates and prints the number of minutes per day according to the example output below. The user input is given in bold in the example. Please note that the output of your program must be exactly the same as the example output.
3
+
4
+ Give the number of days: 4
5
+ 4 days contain 5760 minutes.
6
+ """
7
+
8
+
9
+
10
+
11
+ import java.util.Random;
12
+ import java.util.Scanner;
13
+
14
+
15
+
16
+ public class Test{
17
+ public static void main(String[] args){
18
+ final Random r = new Random();
19
+
20
+
21
+ Scanner reader = new Scanner(System.in);
22
+ System.out.print("Give the number of days: ");
23
+ int days = Integer.valueOf(reader.nextLine());
24
+
25
+ // days * hours/day * min/hr
26
+ int mins = days*24*60;
27
+ System.out.println(days + " days contain " + mins + " minutes.");
28
+
29
+
30
+ }
31
+ }
32
+
33
+
34
+
35
+
36
+ """
37
+ Testing with input4
38
+ Give the number of days: 4
39
+ 4 days contain 5760 minutes.
40
+
41
+ Testing with input2
42
+ Give the number of days: 2
43
+ 2 days contain 2880 minutes.
44
+
45
+ Testing with input7
46
+ Give the number of days: 7
47
+ 7 days contain 10080 minutes.
48
+ """