Many treadmills output the speed of the treadmill in miles per hour (mph) on the console, but most runners think of speed in terms of a pace. A common pace is the number of minutes and seconds per mile instead of mph. Write a program that starts with a quantity in mph and converts the quantity into minutes and seconds per mile. As an example, the proper output for an input of 6.5 mph should be 9 minutes and 13.8 seconds per mile. If you need to convert a double to an int, which will discard any value after the decimal point, then you may use intValue

Answers

Answer 1

Answer:

This question is answered using C++ programming language.

This program does not make use of comments; However, see explanation section for detailed line by line explanation.

The program starts here

#include <iostream>

using namespace std;

int main()

{

 double quantity,seconds;

 int minutes;

 cout<<"Quantity (mph): ";

 cin>>quantity;

 minutes = int(60/quantity);

 cout<<minutes<<" minutes and ";

 seconds = (60/quantity - int(60/quantity))*60;

 printf("%.1f", seconds);

 cout<<" seconds per mile";

 return 0;

}

Explanation:

The following line declares quantity, seconds as double datatype

 double quantity,seconds;

The following line declares minutes as integer datatype

 int minutes;

The following line prompts user for input in miles per hour

 cout<<"Quantity (mph): ";

User input is obtained using the next line

 cin>>quantity;

 

The next line gets the minute equivalent of user input by getting the integer division of 60 by quantity

minutes = int(60/quantity);

The next statement prints the calculated minute equivalent followed by the string " minuted and " without the quotes

 cout<<minutes<<" minutes and ";

After the minutes has been calculated; the following statement gets the remainder part; which is the seconds

 seconds = (60/quantity - int(60/quantity))*60;

The following statements rounds up seconds to 1 decimal place and prints its rounded value

 printf("%.1f", seconds);

The following statement prints "seconds per mile" without the quotes

 cout<<" seconds per mile";

Answer 2

Following are the program to the given question:

Program Explanation:

Defining the header file.Defining the main method.Inside the method, three double variables "mph, sec, and min_per_mile", and one integer variable "min" is defined. After defining a variable "mph" is defined that inputs value by user-end.After input value, "sec, min_per_mile, and min" is defined that calculates the value and prints its calculated value.  

Program:

#include<iostream>//header file

using namespace std;

int main()//defining main method

{

   double mph,sec,min_per_mile;//defining a double variable  

int min;//defining integer variable

cout<<"Enter the speed of the treadmill in mph:";//print message

cin>>mph;//input double value

min_per_mile=(1/mph)*60;//defining a double variable that calculates minutes per mile

min=static_cast<int>(min_per_mile);//defining int variable that converts min_per_mile value into integer

sec=(min_per_mile-min)*60;//defining double variable that calculates seconds per mile value  

cout<<"A common pace is the "<<min<<" minutes and "<<sec<<" seconds per mile"<<endl;//print calculated value with message  

return 0;

}

Output:

Please find the attached file.

Learn more:

brainly.com/question/21278031

Many Treadmills Output The Speed Of The Treadmill In Miles Per Hour (mph) On The Console, But Most Runners

Related Questions

Other Questions
Which of the following would have the best thermal conductor properties?A. A thick mugB. A plastic cup. A paper cupD. A cup made of metal deandre saves rare coins. he starts his collection with 14 coins and plans to save 3 coins each month. write an equation to represent the number of coins saved, y, in terms of the number of months, x. if deandre saved for 30 months, how many coins will he have? Which equation is parallel to the line y=2x+6 and passes through the point (8,1)?y = 2x+6 y = 2x-15 y = 2x+10 y = -2x-7 of a school's population are girls. There are 129 boys. If each classroom can hold 25 students. How many classroom does the school have ? Calculate the lateral area of a right prism with a heptagon base side of 4 feet and aheight of 10 feet. A and B are supplementary, and A and C are supplementary. Which conclusion is valid? Select one: A. B and C are supplementary. B. B and C are acute. C. B and C are complementary. D. B and C are congruent. Which leader was a member of the Kikuyu tribe?A. Kwame NkrumahB. Marcus GarveyC. Mohandas GandhiD. Jomo Kenyatta What is claim of value ) Let an denote number of n-digit ternary sequences (sequences of 0,1 and 2) which have no consecutive 0s in them. Find a recurrence relation for an. (Do not solve the recurrence. However, depending on the order of the recurrence, provide a sufficient number of initial conditions. ) The management of a chain of frozen yogurt stores believes that t days after the end of an advertising campaign, the rate at which the volume V (in dollars) of sales is changing is approximated by V ' ( t ) = 26400 e 0.49 t . On the day the advertising campaign ends ( t = 0 ), the sales volume is $ 170 , 000 . Find both V ' ( 6 ) and its integral V ( 6 ) . Round your answers to the nearest cent. Limestone is formed primarily through ________. chemical interactions between ocean bottom sediments and ions in sea water direct precipitation from seawater biochemical sediments secreted by marine organisms evaporation of calcite rich seawater A piece of wood near a fire is at 23C. It gains 1,160 joules of heat from the fire and reaches a temperature of 42C. The specific heat capacity ofwood is 1.716 joules/gram degree Celsius. What is the mass of the piece of wood?. 16 gOB. 29 gC. 36 gOD. 61 g Read the excerpt from Part 2 of "The Most Dangerous Game, by Richard Connell. He slid down from the tree, and struck off again into the woods. His face was set and he forced the machinery of his mind to function. Three hundred yards from his hiding place he stopped where a huge dead tree leaned precariously on a smaller, living one. Throwing off his sack of food, Rainsford took his knife from its sheath and began to work with all his energy. The job was finished at last, and he threw himself down behind a fallen log a hundred feet away. He did not have to wait long. In this scene in both the story and the film, Rainsford is depicted as Can someone help me with the below question??? Under the rule of Queen Elizabeth I, Parliament: AC =Round your answer to the nearest hundredth.A535BC Maria, Max, Molly, and Mitch are all picking apples at an orchard. The number of apples Max picks is the number of apples Maria picks squared. Molly picks the number of apples that Max and Maria pick combined. Mitch picks the number of apples Molly picks squared plus the number of apples that Maria picks. If Maria picks 3 apples, then how many apples does Mitch pick What type of information system would a chain of theaters use to selltickets? The model below can be used to find the quotient of 1/21/4. What is the quotient? What is the area of the triangle below?18