Answer to Question #186069 in Java | JSP | JSF for Johnny

Question #186069

write a program that accepts as input the mass (in grams) and density (in grams per cubic centimeters), and ooutputs the volume of the object using the formula: density = mass / volume.


1
Expert's answer
2021-04-27T02:10:58-0400
import java.util.Scanner;


public class Main {
    public static void main(String args[]) {
        Scanner input=new Scanner(System.in);
	    int mass=0;
	    int density=0;
	    int volume=0;
		System.out.println("Please provide value of the mass in grams and press Enter: ");
		mass=input.nextInt();
		System.out.println("Please provide value of the density (in grams per cubic centimeters) and press Enter: ");
		density=input.nextInt();
		volume=mass/density;
		System.out.println("The volume is: "+volume);
		input.close();
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS