You've been hired by Planet Pals to write a C++ console application that reads and converts planet data. Create text file PlanetsIn.txt and paste this data into it: 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.3 Place the file in a folder where your development tool can locate it. Read the file by scanning past the header row. Print a file-reading message, and the column headers. Each detail row in the file contains three tokens (planet, diameter, length of day) so you may do one token per read. For each detail row: Read each token from the file. Convert the diameter from miles to feet. Convert the length of day from hours to minutes. Print both the input and corresponding output tokens. Format all real numbers to one decimal place. Continue reading until the end-of-file. Print the number of lines read.
You've been hired by Planet Pals to write a C++ console application that reads and converts planet data. Create text file PlanetsIn.txt and paste this data into it:
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.3
Place the file in a folder where your development tool can locate it. Read the file by scanning past the header row. Print a file-reading message, and the column headers. Each detail row in the file contains three tokens (planet, diameter, length of day) so you may do one token per read. For each detail row:
- Read each token from the file.
- Convert the diameter from miles to feet.
- Convert the length of day from hours to minutes.
- Print both the input and corresponding output tokens.
Format all real numbers to one decimal place. Continue reading until the end-of-file. Print the number of lines read.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images