Ask Question
29 August, 14:02

Write a program that accepts as input the mass, in grams, and density, in grams per cubic centimeters, and outputs the volume of the object using the formula: volume mass / density. Format your output to two decimal places.

+4
Answers (1)
  1. 29 August, 14:53
    0
    Program for the above question in python:

    mass = float (input ("Enter the mass in grams")) # It is used to take the mass as input.

    density = float (input ("Enter the density grams per cm cube")) # It is used to take the input for the grams.

    print ("Volume = {:.2f}". format (mass/density)) #It is used to print the Volume.

    Output:

    If the user inputs as 2.98 and 3.2, then it will results as 0.92.

    Explanation:

    The above code is in python language, in which the first statement is used to take the inputs from the user for the mass and sore it into a mass variable. Then the second statement also takes the input from the user and store it into a density variable. Then the third statement of the code is used to print the volume up to two places using the above-defined formula.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a program that accepts as input the mass, in grams, and density, in grams per cubic centimeters, and outputs the volume of the object ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers