Computer Science, asked by sumedha55, 1 month ago

Write a java program to convert 6 hours 30 minutes 40 seconds into second.​

Answers

Answered by theblazer1607
1

long hour = 6;

long minute = 30;

long second = 40;

minute += hour*60;

second += minute*60;

System.out.println(second);

Now this is with inout from user:

import java.util.Scanner;

Scanner scanner = new Scanner(System.in);

System.out.print("Enter the hour time: ");

long hour = scanner.nextLong();

System.out.print("Enter the minute time: ");

long tempMinute = scanner.nextLong();

long minute;

long second = 1;

minute = hour*60;

minute += tempMinute;

second = 60*minute;

System.out.println(second);

Similar questions