Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

Sample Output (user input is in yellow)
--- Mass Converter --- Enter the weight in pounds: 184 184.00 pounds is 83.46 kilograms or 4.196e-29 solar masses.

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions