Ask Question
29 July, 05:49

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.

+3
Answers (1)
  1. 29 July, 05:54
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers