1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
djyliett [7]
3 years ago
12

Write a program that do the following unit conversion based on user menu selection: (use while or do-while loop until the user e

nter 'Quit' selection) 1. Seconds to hours, minutes and seconds (must Implement as a function) a. Inputs an Integer that represents a length of time in seconds.b. The program should then output the number of hours, minutes, and seconds that corresponds to that number of seconds.c. For example, If the user inputs 50391 total seconds then the program should output 13 hours, 59 minutes, and 51 seconds.d. Your program must check for valid input (positive integer only)
Computers and Technology
2 answers:
pochemuha3 years ago
5 0
<h2>Answer:</h2>

package brainly;

// import the Scanner class

import java.util.Scanner;

public class TimeConverter {

   public static void main(String[] args) {

       //Create an object of the Scanner class to allow for users inputs

       Scanner input = new Scanner(System.in);

       //Create an infinite do while loop.

       //At each of the cycles in the loop,

       do {

           //1. Create a prompt for the user to make a selection

           System.out.println("1. Seconds to hours, minutes and seconds ");

           System.out.println("2. Quit ");

           System.out.println("Enter 1 or 2");

           // Receive the users input and store in a variable

           int userselection = input.nextInt();

           // if the user enters 1, ask them to enter the length of time

           if (userselection == 1) {

               System.out.println("Enter the length of the time in seconds ");

               //Receive the length of time and store in a variable

               int lengthOfTime = input.nextInt();

               //Check if the length is positive

               //if yes, call the converter method

               if (lengthOfTime >= 0) {

                   converter(lengthOfTime);

               }  

               

               //if no, return an error message

              else {

                   System.out.println("");

                   System.err.println("Invalid input! Number should be positive");

               }

           }

           // else if the user enters 2, break out of the loop to quit the program

           else if (userselection == 2) {

               System.out.println("You have quit the program");

               break;

           }  

           // else display an invalid input error message

           else {

               System.err.println("Invalid input! Enter 1 or 2");

           }

       } while (true);

   }                 // end of main method

   //The converter method

   public static void converter(int lengthOfTime) {

       //Convert the length of time to hours

       int noOfHours = lengthOfTime / 3600;

       //Convert the length of time to minutes

       int noOfMinutes = (lengthOfTime % 3600) / 60;

       //Convert the length of time to seconds

       int noOfSeconds = lengthOfTime - (noOfMinutes * 60 + noOfHours * 3600);

       //Print out the results

       System.out.println(noOfHours + " hours " + noOfMinutes + " minutes " + noOfSeconds + " seconds ");

   }          //end of converter method

}               // end of class declaration

<h2>Explanation:</h2>

The code above has been written in Java. The code contains comments explaining important sections of the code. Kindly go through the comments in the code.

The source code file has also been attached to this response. Kindly download it for better formatting and readability.

Download java
atroni [7]3 years ago
3 0

Answer:

Explanation:

import java.util.*;

public class Exercise55 {

public static void main(String[] args)

   {

       Scanner in = new Scanner(System.in);

       System.out.print("Do you want to run again? ")

       string run = in.nextString()

       System.out.print("Input seconds: ");

       int seconds = in.nextInt();  

       Do

      {

       int p1 = seconds % 60;

       int p2 = seconds / 60;

       int p3 = p2 % 60;

       p2 = p2 / 60;

       System.out.print( p2 hours + ":" + p3 minutes+ ":" + p1 seconds);

       System.out.print("\n");

        }

while( run == yes)

   }    

}

You might be interested in
What is the name of tool in number 9 picture? CAPITAL LETTER ONLY
Mariana [72]

Answer:

WHERE IS THE PICTURE??????????

3 0
3 years ago
You are connected to a server on the Internet and you click a link on the server and receive a time-out message. What layer coul
Grace [21]

Answer: Application layer

Explanation: Application layer is the level in the OSI model which carries out the function of the abstraction in the network.The abstraction works by maintaining the interface between application and network.

It helps in the transferring of the information and data as well using the protocols. So,if any time out message alert is received  by clicking on the link then the server condition is usually busy and thus cannot respond. In this case application layer is responsible for the problem.

7 0
3 years ago
What kind of document serves as a legally binding contract or part of a contract that defines, in plain language and in measurab
s344n2d4d5 [400]

Answer:

C. memorandum of understanding

Explanation:

A memorandum of understanding is a type of agreement between two or more parties. It expresses a convergence of will between the parties, indicating an intended common line of action.

5 0
4 years ago
Supports traditional transactional processing for day-to-day front-office operations or systems that deal directly with the cust
Jet001 [13]

Answer:

Operational CRM.

Explanation:

Operational CRM can be described as most of the programs that allow a company to taking care of the desires of the consumers. The structure links and maintains the selling, marketing, and customer support activities of a corporation, thus providing a structure that requires customer service.

So, the following answer is correct according to the statement.

7 0
4 years ago
Q) Select the two obstacles for data parsing
fgiga [73]

Answer:

A and B

Explanation:

parsing with a rich grammar like TAG faces two main obstacles: low parsing speed and a lot of ambiguous syntactical parses.

3 0
4 years ago
Read 2 more answers
Other questions:
  • Select the correct answer from each drop-down menu.
    8·1 answer
  • What is the difference between word processing software and email?
    12·2 answers
  • Given main() and a base Book class, define a derived class called Encyclopedia. Within the derived Encyclopedia class, define a
    10·1 answer
  • What is the difference between the throw statement and the throws clause?
    10·1 answer
  • What is the default view when you first open a PowerPoint presentation
    10·1 answer
  • Decimal numbers is equivalent to binary 110
    5·1 answer
  • Draw a flowchart diagram for a program that display a person's name x times​
    5·1 answer
  • If you need to change the typeface of a document, which menu will you choose?
    6·1 answer
  • Deirdre has a hearing disability. One of her friends advised her to use real-time text or RTT on her phone. In which of these
    13·1 answer
  • alle Mbawah: Attempt 1 How does a bystander become an advocate? By harassing the bully until he or she stops the harmful activit
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!