Question
2) [13 points] Youve been hired by Planet Poachers to write a C++ console application that converts planet data. Download file PlanetsIn.txt to project folder
2) [13 points] Youve been hired by Planet Poachers to write a C++ console application that converts planet data. Download file PlanetsIn.txt to project folder
Use the following C++ function to convert a substring to a real number (double):
stod(
You may combine the parse and convert operations into one. Here is an example:
stod(line.substr(11, 15))
Convert the diameter from miles to kilometers (diameter * 1.609344) and the length to earth days (length / 24). Print the planet, and the converted diameter and length. After all lines have been read from the input file, print the average diameters in miles and kilometers, and the average lengths in hours and days. Format any real numbers to one decimal place. The start of your output should look like this:The end of your output should look like this:
Planet Diameter (miles) Length of Day (hours) Mercury 3032 4222.6 Venus 7521 2802.0 Earth 7926 24.0 Moon 2159 708.7 Mars 4221 24.7 Jupiter 88846 9.9 Saturn 74897 10.7 Uranus 31763 17.2 Neptune 30775 16.1 Pluto 1485 153.3Reading lines from tile PlanetsIn.txt .. . Input line (miles, hours): output line (kilometers, days): Mercury 3032 4879.5 4222.6 175.9 Input line (miles, hours): output line (kilometers, days): Venus 7521 12103.9 2802.0 116.8 Venus
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