Ask 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 using the formula: volume mass / density. Format your output to two decimal places.

+1
Answers (1)
  1. 29 March, 06:01
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers