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
Alenkasestr [34]
3 years ago
13

Write a java program that prompts the user to input the elapsed time for an event in hours, minutes, and seconds. The program th

en outputs the elapsed time in seconds.
Computers and Technology
1 answer:
Arisa [49]3 years ago
6 0

Answer:

import java.util.*;

class seconds

{

public static void main (String[] args)

{

    Scanner takeinput=new Scanner(System.in);//creating a scanner object for taking input.

    int hour,min,sec; //declaring 3 variables for hour , minutes and seconds.

    System.out.println("enter hours");

    hour=takeinput.nextInt();//taking input of hours..

    System.out.println("enter minutes");

    min=takeinput.nextInt();//taking input of minutes..

    System.out.println("enter seconds");

    sec=takeinput.nextInt();//taking input of seconds..

    int tot_time_sec=(hour*60*60)+(min*60)+sec; //calculating time in seconds in variable tot_time_sec.

    System.out.println("Total time in seconds is "+tot_time_sec);//pritning total time in seconds..

}

}

For input:

7

20

45

Output is:-

Total time in seconds is 26445..

Explanation:

Above is the code for finding the time in seconds.I have taken three integer variables hour,min and sec for taking input of hours ,minutes and seconds. After taking input i have taken an integer variable tot_time_sec to store the calculated time in seconds and after that printing tot_time_sec.

You might be interested in
The________ format is usually used to store data
Nikitich [7]
The answer is BCD; The BCD format is usually used to store data
5 0
3 years ago
Construct a group frequency distribution for the following data: 18, 22, 15, 12, 18, 22, 22, 24, 21, 19, 13, 13, 17, 18, 20, 12,
Y_Kistochka [10]

Answer:

uhebcuwcih

Explanation:

iqic c .j .c h de c veo  dnjen jndc j .ececiibbec .cecinineijc    

4 0
3 years ago
Read 2 more answers
Because assembly language is so close in nature to machine language, it is referred to as a ____________.
Travka [436]

Answer:

low-level language.

Explanation:

6 0
3 years ago
Read 2 more answers
Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The user shoul
iVinArrow [24]

The do-while loop for the given problem is shown below.  

do  

{  

  // user asked to enter two numbers  

  cout<<"Enter two numbers to be added."<<endl;  

  cin>>num1;  

  cin>>num2;  

  sum = num1 + num2;  

 

  // sum of the numbers is displayed  

  cout<<"Sum of the two numbers is "<<sum<<endl;  

  // user asked whether to perform the operation again  

  cout<<"Do you wish to continue (y/n) ?"<<endl;  

   cin>>choice;  

}while(choice != 'n');  

The variables to hold the two numbers and their sum are declared as float so that the program should work well for both integers and floating numbers.

float num1, num2, sum;

The char variable is taken since it holds only a single-character input from the user, 'y' or 'n'.

char choice;

The whole program is given below.

#include <iostream>

using namespace std;

int main() {

float num1, num2, sum;

char choice;  

do  

{  

  // user asked to enter two numbers  

  cout<<"Enter two numbers to be added."<<endl;  

  cin>>num1;  

  cin>>num2;  

  sum = num1 + num2;  

  // sum of the numbers is displayed  

  cout<<"Sum of the two numbers is "<<sum<<endl;  

  // user asked whether to perform the operation again  

  cout<<"Do you wish to continue (y/n) ?"<<endl;  

  cin>>choice;  

}while(choice != 'n');

cout<<"Quitting..."<<endl;

}

5 0
3 years ago
What is a complex instruction set computer chip? Multiple Choice Performs all arithmetic operations (for example, addition and s
Mademuasel [1]

Answer:  A type of CPU that can recognize as many as 100 or more instructions, enough to carry out most computations directly

Explanation: Complex instruction set computer(CISC) is the computer device that performs the task of multiple execution through a single instruction.The instruction set present in CISC can range from simple to complex category.They can execute the numerous complex instruction efficiently.

Other options are incorrect because CISC does not perform every arithmetic function,does not helps functioning of hardware via software and does not execute function of software through interpretation of hardware.

7 0
3 years ago
Other questions:
  • What item on a business card is generally the most prominent?
    13·2 answers
  • Generally speaking, mobile sites are good for acquiring new customers and inspiring new relationships while mobile apps are good
    6·1 answer
  • If you delete selected cells using the Delete key on your keyboard, only the _______ of the cells is removed. formatting content
    8·2 answers
  • What is 1/10 of 2.0 in decimal form​
    10·1 answer
  • What is meant by polling mode in communication between software andUART and what is its disadvantage as compared to interrupt mo
    14·1 answer
  • In which phase of website design does the designer create a mock-up aimed at the target use
    15·1 answer
  • Using Phyton
    9·1 answer
  • How dose computers it use the information to solve problems
    6·1 answer
  • When software is purchased, a _____ is being bought that gives the purchaser the right to use the software under certain terms a
    9·1 answer
  • Write algorithm and flowchart for the following<br>a.find the sum and average of any four numbers ​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!