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
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.