KaiquanMah's picture
int days = Integer.valueOf(reader.nextLine())
ec73a3d verified
raw
history blame
1.11 kB
"""
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.
Give the number of days: 4
4 days contain 5760 minutes.
"""
import java.util.Random;
import java.util.Scanner;
public class Test{
public static void main(String[] args){
final Random r = new Random();
Scanner reader = new Scanner(System.in);
System.out.print("Give the number of days: ");
int days = Integer.valueOf(reader.nextLine());
// days * hours/day * min/hr
int mins = days*24*60;
System.out.println(days + " days contain " + mins + " minutes.");
}
}
"""
Testing with input4
Give the number of days: 4
4 days contain 5760 minutes.
Testing with input2
Give the number of days: 2
2 days contain 2880 minutes.
Testing with input7
Give the number of days: 7
7 days contain 10080 minutes.
"""