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 …

Read More

Write a program that inputs a three-digit number from the user and displays it in reverse order. Fox example if the user enter 123, it display 321.

public static void main(String[] args) { Scanner c= new Scanner(System.in); int n,x,y; System.err.println(“Enter 3 digit number”); n=c.nextInt(); x=n/100; n=n%100; y=n/10; n=n%10; System.out.print(n); System.out.print(y); System.out.println(x); } } Output run: Enter 3 …

Read More

Write a program that gets temperature from the user in Fahrenheit and converts it into Celsius using the formula C=5/9*(F-32).

package input.output.programm; import java.util.Scanner; class InputOutputProgramm { public static void main(String[] args) { Scanner n=new Scanner(System.in); float cel,fahr; System.out.println(“Enter the temperature in Fahrenheit “); fahr= n.nextFloat(); cel=5/9*(fahr-32); System.out.println(“Temperature in Fahrenheit …

Read More