Write a program that inputs number of hours. It computes and displays the number of weeks, days, and hours within the input number of hours.

public static void main(String[] args) {

Scanner n=new Scanner(System.in);

int hrs,w,d;

System.out.println(“Enter number of hours”);

hrs= n.nextInt();

w=hrs/24*7;

hrs=hrs%24*7;

d=hrs/24;

hrs=hrs%24;

System.out.println(“Weeks are=”+w);

System.out.println(“Days are=”+d);

System.out.println(“Hours are=”+hrs);

}

}

Output

run:
Enter number of hours
8422
Weeks are=2450
Days are=6
Hours are=10
BUILD SUCCESSFUL (total time: 5 seconds)

Leave a Reply

Your email address will not be published. Required fields are marked *