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
Triss [41]
2 years ago
9

Write a program that asks the user to enter a number of seconds. There are 60 seconds in a minute. If the number of seconds ente

red by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours in that many seconds. There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of days in that many seconds.
Computers and Technology
1 answer:
frez [133]2 years ago
8 0

Answer:

// here is code in c.

#include <stdio.h>

// main function

int main()

{

// variable to store seconds

long long int second;

printf("enter seconds:");

// read the seconds

scanf("%lld",&second);

// if seconds is in between 60 and 3600

if(second>=60&& second<3600)

{

// find the minutes

int min=second/60;

printf("there are %d minutes in %lld seconds.",min,second);

}

// if seconds is in between 3600 and 86400

else if(second>=3600&&second<86400)

{

// find the hours

int hours=second/3600;

printf("there are %d minutes in %lld seconds.",hours,second);

}

// if seconds is greater than 86400

else if(second>86400)

{

// find the days

int days=second/86400;

printf("there are %d minutes in %lld seconds.",days,second);

}

return 0;

}

Explanation:

Read the seconds from user.If the seconds is in between 60 and 3600 then find the minutes by dividing seconds with 60 and print it.If seconds if in between 3600 and 86400 then find the hours by dividing second with 3600 and print it. If the seconds is greater than 86400 then find the days by dividing it with 86400 and print it.

Output:

enter seconds:89

there are 1 minutes in 89 seconds.

enter seconds:890000

there are 10 days in 890000 seconds.

You might be interested in
Where can I find answer key for electrician systems based on NEC 2017
lisov135 [29]

google or search through pvps

6 0
3 years ago
Virtual machines are not susceptible to the threats and malicious attacks like other operating systems.
Nonamiya [84]

Answer:

flamingo was here

Explanation:

3 0
3 years ago
Write a function with two parameters, prefix (a string, using the string class from ) and levels (an unsigned integer). The func
Allisa [31]

Answer:

Here is the program:

#include <iostream>  //to use input output functions

#include <string>  // to use functions to manipulate strings

using namespace std;  //to identify objects cin cout

void function(string prefix, unsigned int levels){  // function that takes two parameters, a string, using the string class and levels an unsigned integer

   if (levels == 0) {  //if number of levels is equal to 0

       cout << prefix << endl;  //displays the value of prefix

       return;    }  

  for (int i = 1; i <=9 ; i++){  //iterates 1 through 9 times

       string sections = (levels == 1 ? "" : ".");  //if the number of levels is equal to 1 then empty space in sections variable otherwise stores a dot

       string output = prefix +  std::to_string(i) + sections;   // displays the string prefix followed by the section numbers. Here to_string is used to convert integer to string

       function(output, levels - 1);   } }   //calls function by passing the resultant string and levels-1  recursively to print the string prefix followed by section numbers

int main() {  // start of main function

   int level = 2;  //determines the number of levels

   function("BOX", level);  } //calls function by passing the string prefix and level value

Explanation:

The program has a function named function() that takes two parameters, prefix (a string, using the string class from ) and levels (an unsigned integer). The function prints the string prefix followed by "section numbers" of the form 1.1., 1.2., 1.3., and so on. The levels argument determines how many levels the section numbers have. If the value of levels is 0 means there is 0 level then the value of prefix is printed. The for loop iterates '1' through '9' times for number of digits in each level. If the number of levels is 1 then space is printed otherwise a dot is printed. The function() calls itself recursively to print the prefix string followed by section numbers.

Let us suppose that prefix = "BOX" and level = 1

If level = 1 then the loop for (int i = 1; i <=9 ; i++) works as follows:

At first iteration:

i = 1

i <=9 is true because value of i is 1

string sections = (levels == 1 ? "" : "."); this statement checks if the levels is equal to 1. It is true so empty space is stored in sections variable so,

sections = ""

Next, string output = prefix +  std::to_string(i) + sections; statement has prefix i.e BOX plus value of i which is 1 and this int value is converted to string by to_string() method plus sections has an empty space. So this statement becomes

string output = BOX + 1  

So this concatenates BOX with 1 hence output becomes:

output = BOX1

At second iteration:

i = 2

i <=9 is true because value of i is 2

string sections = (levels == 1 ? "" : "."); is true so

sections = ""

Next, string output = prefix +  std::to_string(i) + sections; statement becomes

string output = BOX + 2  

So this concatenates BOX with 1 hence output becomes:

output = BOX2

At third iteration:

i = 3

i <=9 is true because value of i is 3

string sections = (levels == 1 ? "" : "."); is true so

sections = ""

Next, string output = prefix +  std::to_string(i) + sections; statement becomes

string output = BOX + 3  

So this concatenates BOX with 1 hence output becomes:

output = BOX3

Now at each iteration the prefix string BOX is concatenated and printed along with the value of i. So at last iteration:

At last iteration:

i = 9

i ==9 is true because value of i is 9

string sections = (levels == 1 ? "" : "."); is true so

sections = ""

Next, string output = prefix +  std::to_string(i) + sections; statement becomes

string output = BOX + 9  

So this concatenates BOX with 1 hence output becomes:

output = BOX9

After this the loop breaks at i = 10 because the condition i<=9 becomes false. So the output of the entire program is:

BOX1                                                                                                                                          BOX2                                                                                                                                          BOX3                                                                                                                                          BOX4                                                                                                                                          BOX5                                                                                                                                          BOX6                                                                                                                                          BOX7                                                                                                                                          BOX8                                                                                                                                          BOX9  

The program along with the output is attached.

4 0
3 years ago
Write a statement that declares a PrintWriter reference variable named output and initializes it to a reference to a newly creat
dusya [7]

Answer:

PrintWriter variable = new PrintWriter("output.txt");

Explanation:

There are two ways of declaring a reference variable in programming.

One way is

Reference Variable-name = new Reference ("some texts here");

While the other is

Reference Variable-name;

Variable-name = new Reference ("some texts here");

Both ways are valid ways of reference variable declaration.

In the question above, the reference is PrintWriter, it points to output.txt and the question says "write a single statement";

Hence, we make use of

PrintWriter variable = new PrintWriter("output.txt");

A reference variable is declared to be of a specific type and that type can never be changed.

5 0
3 years ago
Using the diagram to the right, match each letter
alexira [117]

Answer:

A - slide

B - ribbon

C- command

D - group

E - format painter

F - tab

Explanation:

edge2020

5 0
2 years ago
Other questions:
  • Write an exception class named InvalidTestScore. Modify the TestScores class you wrote in Part I so that it throws an InvalidTes
    10·1 answer
  • When creating an input control (for example, a button) on a form the _____________ indicates the data that is contained in the n
    13·1 answer
  • Unit testing:_________. A. provides the final certification that the system is ready to be used in a production setting. B. incl
    8·1 answer
  • What is the main purpose of cutting plane line arrows?
    7·1 answer
  • Which decimal number is equivalent to this hexadecimal number?<br> F8
    6·2 answers
  • What is the preferences of occupation in ones life?
    14·1 answer
  • Write a method that takes a Regular Polygon as a parameter, sets its number of sides to a random integer between 10 and 20 inclu
    10·1 answer
  • Complete the following sentence.
    7·1 answer
  • In which of the following stages of the development process is a team MOST likely to interview a potential user of an app?
    6·1 answer
  • How can I use HTML to express a personal value
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!