Question
Write a program that prompts the user to enter the weight of a person in pounds and outputs the equivalent weight in kilogram and solar
Write a program that prompts the user to enter the weight of a person in pounds and outputs the equivalent weight in kilogram and solar masses (used to measure the mass of stars and galaxies).
Output both the weight in pounds and kilograms rounded to two digits after the decimal place (trailing zeros if necessary). Output the weight in solar masses in scientific notation with 4 significant digits (for example, 102 would be output as 1.020e+002
in C++ scientific notation, which is short for 1.020 10002). The relationship between pounds and kilograms and the relationship between kilograms and solar masses should be declared in your program as constants named KILOGRAM_PER_POUND and KILOGRAM_PER_SOLAR_MASS respectively. Use these constants in the conversion formulas.
- 1 pound = 0.453592 kilograms
- 1 kilogram = 5.0279e-31 solar masses (or 5.0279 10-31 solar masses)
Hint: Remember that scientific notation always has exactly one significant figure before the decimal place and the rest are after the decimal place. If you want to remove the fixed
manipulator, you can use a new manipulator called defaultfloat
.
Name your source code file MassConverter.cpp.
Your program should match the following layout exactly.
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