Question


17.1 LAB: Niles to track laps  (C++)

One lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input, and outputs the number of laps.

Output each floating-point value with two digits after the decimal point, which can be achieved by executing 

cout << fixed << setprecision(2); once before all other cout statements.


Ex. If the input is:

1.5

the output is:

6.00

Ex: If the input is:

2.2

the output is:

8.80


Your program must define and call a function: double MilesToLaps (double userMiles)

17.1 LAB: Miles to track laps One lap around a standard high-school running track is exactly 0.25 miles. Write a program that


1 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

#include
#include
using namespace std;
//method to compute number of laps
double MilesToLaps(double userMiles)
{
    return (userMiles/0.25); //return number of laps
}
//driver program
int main()
{
   double userMiles;
   cout<    cin>>userMiles; //read number of miles from user
   cout<    //print the number of laps
   cout< }

output

Enter Miles : 1.5 1.50 Miles = 6.00 Laps. Process exited after 12 seconds with return value o ID Icou to nuo

Enter Miles : 2.2 2.20 Miles = 8.80 Laps. Process exited after 1.862 seconds with return value o Press any key to continue

Add a comment
Know the answer?
Add Answer to:
(C++) One lap around a standard high-school running track is exactly 0.25 miles
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • (JAVA) One lap around a standard high-school running track is exactly 0.25 miles

    (JAVA) 7.12 LAB: Miles to track lapsOne lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input, and outputs the number of laps.Output each floating-point value with two digits after the decimal point, which can be achieved as follows: System.out.print f("%.2 f", yourValue);Ex: if the input is.1.5the output is:6.00Ex: if the input is:2.2the output is:8.80

  • Code Program in C++ Language.5.9 LAB: Miles to track laps One lap around a standard...

    5.9 LAB: Miles to track lapsOne lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input, and outputs the number of laps.Ex: If the input is 1.5, the output is6Ex: If the input is 2.2, the output is8.8Your program must define and call a function:double MilesToLaps(double userMiles)

  • PLEASE WRITE IN C++ 2.25 LAB: Driving costs Driving is expensive. Write a program with a...

    PLEASE WRITE IN C++ 2.25 LAB: Driving costs Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating-point value with two digits after the decimal point, which can be achieved by executing cout << fixed << setprecision(2); once before all other cout statements. Ex: If the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20 Note:...

  • 2.24 LAB: Expression for calories burned during workout 2.24 LAB: Expression for calories burned during workout...

    2.24 LAB: Expression for calories burned during workout 2.24 LAB: Expression for calories burned during workout The following equations estimate the calories burned when exercising (source): Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184 Men: Calories = ( (Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184 Write a program with inputs age (years), weight...

  • In this project you will write a C++ program that simulates the purchase of a single...

    In this project you will write a C++ program that simulates the purchase of a single item in an online store. What to do Write a C++ program that: 1. Prints out a welcome message. 2. Prompts the user for the following information: (a) Their first name (example: Roger) (b) Their last name (example: Waters) (c) The name of the product (example: Brick) (d) The unit price of the product (example: 1.99) (e) The quantity to buy (example: 200) (f)...

  • In C++ Amanda and Tyler opened a business that specializes in shipping liquids, such as milk,...

    In C++ Amanda and Tyler opened a business that specializes in shipping liquids, such as milk, juice, and water, in cylindrical containers. The shipping charges depend on the amount of the liquid in the container. (For simplicity, you may assume that the container is filled to the top.) They also provide the option to paint the outside of the container for a reasonable amount. Write a program that does the following: Prompts the user to input the dimensions (in feet)...

  • This is a C++ assignment that I'm trying to create and would like some help understanding...

    This is a C++ assignment that I'm trying to create and would like some help understanding while loops, with possible integration of for loops and if statements. This program only uses while, for, and if. I have some code that I have started, but where to go from there is what's giving me some trouble. This is involves a sentinel controlled while loop, and there are a lot of specifications below that I must have in the program. The program...

  • This is a C++ assignment that I'm trying to create and would like some help understanding...

    This is a C++ assignment that I'm trying to create and would like some help understanding while loops, with possible integration of for loops and if statements. This program only uses while, for, and if. I have some code that I have started, but where to go from there is what's giving me some trouble. This is involves a sentinel controlled while loop, and there are a lot of specifications below that I must have in the program. The program...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT