1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Artyom0805 [142]
3 years ago
14

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.
Computers and Technology
1 answer:
rewona [7]3 years ago
3 0

Answer:

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.
You might be interested in
In this scenario, two friends are eating dinner at a restaurant. The bill comes in the amount of 47.28 dollars. The friends deci
pickupchik [31]

Answer:

The java program for the given scenario is as follows.

import java.util.*;

import java.lang.*;

public class Main

{

   //variables for bill and tip declared and initialized

   static double bill=47.28, tip=0.15;

   //variables for total bill and share declared

   static double total, share1;

public static void main(String[] args) {

    double total_tip= (bill*tip);

    //total bill computed

    total = bill + total_tip;

    //share of each friend computed

    share1 = total/2;

    System.out.printf("Each person needs to pay: $%.2f", share1);  

}

}

Explanation:

1. The variables to hold the bill and tip percent are declared as double and initialized with the given values.

static double bill=47.28, tip=0.15;

2. The variables to hold the values of total bill amount and total tip are declared as double.

3. All the variables are declared outside main() and at class level, hence declared as static.

4. Inside main(), the values of total tip, total bill and share of each person are computed as shown.

double total_tip= (bill*tip);

total = bill + total_tip;

share1 = total/2;

5. The share of each person is displayed to the user. The value is displayed with only two decimal places which is assured by %.2f format modifier. The number of decimal places required can be changed by changing the number, i.e. 2. This format is used with printf() and not with println() method.

System.out.printf("Each person needs to pay: $%.2f", share1);  

6. The program is not designed to take any user input.

7. The program can be tested for any value of bill and tip percent.

8. The whole code is put inside a class since java is a purely object-oriented language.

9. Only variables can be declared outside method, the logic is put inside a method in a purely object-oriented language.

10. As shown, the logic is put inside the main() method and only variables are declared outside the method.

11. Due to simplicity, the program consists of only one class.

12. The output is attached.

5 0
3 years ago
Read 2 more answers
Even closed systems are never perfectly closed. <br>true false​
Oxana [17]

Answer:

True

Explanation:

You can learn through many different textbooks that a closed system is always closed.

3 0
2 years ago
Which bitwise operation has the same effect as multiplying a by 16?
Shalnov [3]
<span>Jun 15, 2011 - Multiplication and division can be achieved using bit operators, for example .... I discovered pretty much the same thing for Sun CC close to 20 years ago. ... Just to add a rough estimation: On a typical 16-Bit processor ..... Doing it yourself willaffect readability and possibly have no effect on performance.</span><span>
</span>
4 0
2 years ago
Read 2 more answers
Que es la papirofobia​
PilotLPTM [1.2K]

Answer:

Aporofobia : temor obsesivo a la pobreza y de gente pobre.

4 0
2 years ago
Read 2 more answers
What is the name of small programs stored on the hard drive that tell the computer how to communicate with a specific hardware d
Katena32 [7]
Small programs stored on the harddrive that provide basic functionality for he devices listed would be called Hardware Drivers.
I hope this helps!
5 0
3 years ago
Other questions:
  • ________ are devices used to send data between two networks.
    11·1 answer
  • This stores a piece of data and gives it a specific name
    7·1 answer
  • Which interest bearing account is best for people who won’t need access to their money for several months or longer?
    6·1 answer
  • A _____ is a link on a web page that leads to another web page.
    13·1 answer
  • At the beginning of this month, the balance of Reed's checking account was $692.35. So far this month, he has received a paychec
    13·2 answers
  • You have to display or connect to network shares on remote computers. Which command-line utility will you use to accomplish the
    10·1 answer
  • What is the value of the average variable after the following code is executed? var sum = 0; var prices = [14, 10, 9, 12, 11, 14
    14·1 answer
  • Which of the following should you do if your accelerator is stuck? A. Pump your brakes to build fluid pressure. B. Shift to Neut
    14·2 answers
  • What tool can help discover and report computer errors when you first turn on a computer and before the operating system is laun
    9·2 answers
  • Why does my smoke detector keep beeping even after i change the battery?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!