Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Unit conversions (30 points) a. Write a function that can convert miles to kilometers or kilometers to miles. b. Pass two parameters to this
1. Unit conversions (30 points) a. Write a function that can convert miles to kilometers or kilometers to miles. b. Pass two parameters to this function: i. A parameter of type double that represents the value to be converted. ii. A parameter of type int that indicates whether the conversion is from kilometers to miles or miles to kilometers. (Look up the conversion factors using the internet or the library.) ii. Use an if...else statement with the second parameter to determine whether to convert from miles to kilometers or kilometers to miles. C. In main(), call the above function to print the following speeds in both miles per hour (mph) and meters per second (m/s) with one decimal place. (There are 1000 meters in a kilometer. Don't forget to convert seconds to/from hours.) For example, if 29 mph were given, you should print something like: "29.0 mph is equal to 13.0 m/s" or if 13.0 m/s were given you should print something like: "13.0 m/s is equal to 29.0 mph." 10.5 m/s 35 mph 3.2 m/s 73.1 mph 159.7 m/s
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started