Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CSC 15 Lab 3, Chaper 3 Write a complete program that generates the exact followi

ID: 3587018 • Letter: C

Question

CSC 15 Lab 3, Chaper 3 Write a complete program that generates the exact following output. In this program you need to prompt the user the number of hours, minutes and seconds and then output the equivalent amount in minutes and seconds and hours. Please refer to the shell provided for you for more details. Requirements: I. Must Main method can only have two lines of code. Proper indentation Proper naming Comments Logic provide the exact same o utput word by word 2. 3. 4. 5, 6. At the top of your program include the following info as comments: First name, last name Description of the program Date you created the program This program converts hours, minutes, second to second and display in on the screen. How many times do you want to use the app? 2 What is your name? Alex Patten Hi Alex Patten Lets start!! Enter the number of the hours:3 Enter the number of the minutes: 5 Enter the number of the seconds: 360 3 Hours, 5 Minutes, and 360 Seconds is: 11460 seconds 191 Minutes 0 Scoonds 3 Hours and1 Minutes and 0 Seconds What is your name? Mary Lee Hi Mary Lee Lets start!! Enter the number of the hours:5 Enter the number of the minutes: 128 Enter the number of the seconds: 728 S Hours, 128 Minutes, and 728 Seconds is: 26408 scconds 440 Minutes 8 Seoonds

Explanation / Answer


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
class conversion
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
String name;
int hrs, min, sec;
System.out.print(" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
System.out.print(" This program converts hours, minutes, second to second and display it on the screen");
System.out.print(" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  
System.out.println(" How many times do you want to use the app? ");
int n = scan.nextInt();
for(int i = 0; i < n; i++)
{
System.out.println(" What is your name? ");
name = scan.next();
System.out.println(" Hi " + name + " Lets start!!");
System.out.println(" Enter the number of hours: ");
hrs = scan.nextInt();
System.out.println(" Enter the number of minutes: ");
min = scan.nextInt();
System.out.println(" Enter the number of seconds: ");
sec = scan.nextInt();
  
int s = sec + (60 * min) + (3600 * hrs);
System.out.println(+ hrs + " Hours " + min + " Minutes " + sec + " Seconds ");
  
System.out.print(" ");
System.out.println(s + " Seconds");
  
int minutes = s / 60;
int seconds = s % 60;
System.out.println(+ minutes + " Minutes " + seconds + " Seconds ");
  
int hour = s / 3600;
int minute = (s - (hour * 3600))/60;
int second = s % 60;
System.out.println(+ hour + " Hours " + minute + " Minutes " + second + " Seconds ");
}
}
}

OUTPUT

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This program converts hours, minutes, second to second and display it on the screen

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

How many times do you want to use the app? 2

What is your name? Alex

Hi Alex Lets start!!

Enter the number of Hours: 3

Enter the number of minutes: 5

Enter the number of seconds: 360

3 Hours 5 Minutes 360 Seconds

11460 Seconds

191 Minutes 0 Seconds

3 Hours 11 Minutes 0 Seconds

What is your name? MaryLee

Hi MaryLee Lets start!!

Enter the number of Hours: 5

Enter the number of minutes: 128

Enter the number of seconds: 728

5 Hours 128 Minutes 728 Seconds

26408 Seconds

440 Minutes 8 Seconds

7 Hours 20 Minutes 8 Seconds