Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include using namespace std; /* Define your function here */ int main() { /* Type your code here. */ return 0; } please

image text in transcribed

#include

#include

#include

using namespace std;

/* Define your function here */

int main() {

/* Type your code here. */

return 0;

}

please complete this code above in C++

A pedometer treats walking 2,000 steps as walking 1 mile. Write a StepsToMiles 0 function that takes the number of steps as an integer parameter and returns the miles walked as a double. The StepsToMiles() function throws a runtime_error object with the message "Exception: Negative step count entered." when the number of steps is negative. Complete the main() function that reads the number of steps from a user, calls the StepsToMiles() function, and outputs the returned value from the StepsToMiles() function. Use a try-catch block to catch any runtime_error object thrown by the StepsToMiles() function and output the exception message. 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 of the program is: 5345 the output of the program is: 2.67 Ex: If the input of the program is: 3850 the output of the program is: Exception: Negative step count entered. 419632.2632270.932qy7

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

Develop successful mentoring programs. page 400

Answered: 1 week ago