Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Prog 6: Scientists measure an object\'s mass in kilograms and its weight in pewt

ID: 3594091 • Letter: P

Question

Prog 6: Scientists measure an object's mass in kilograms and its weight in pewtons, If you know the amount of mass that an object has, you can calculate its weight, in newtons, with the following formula: Weight mass 9.8 Write a program that asks the user to enter an object's mass, and then calculates and displays its weight. If the object weighs more than 1,000 newtons, display a message indicating that it is too heavy. If the object weighs less than 10 pewtons, display a message indicating that the object is too light.

Explanation / Answer

ObjectMassTest.java

import java.util.Scanner;

public class ObjectMassTest {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("Enter the object mass: ");

double mass = scan.nextDouble();

double weight = mass * 9.8;

if(weight > 1000) {

System.out.println("It is too heavy");

} else {

System.out.println("It is too light");

}

}

}

Output:

Enter the object mass:
200
It is too heavy

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote