Create an application in java that asks a user for a number


Create an application in Java that asks a user for a number of hours, days, and years and computes the equivalent number of seconds (ignoring leap years).

import java.util.Scanner;
public class Example2
{ public static void main(String[] args)
{ // First get the info from user
Scanner days = new Scanner(System.in);
System.out.println("Please enter a number of days: ");
Scanner years = new Scanner(System.in);
System.out.println("Please enter a number of years: ");
Scanner hours=new Scanner(System.in);
System.out.println("Please enter a number of hours: ");
// Now do calculations
newyears = years/31536000;
newdays = days/86400;
newhours = hours/60;
//Now present results
System.out.println("That's" +newyears + newdays + newhours +" second(s)");

} // end main method
} // end class

 

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create an application in java that asks a user for a number
Reference No:- TGS01420046

Now Priced at $10 (50% Discount)

Recommended (94%)

Rated (4.6/5)