Ask Question
25 August, 09:26

Write a program that asks the user to enter an object's mass, then calls a / / function to return the object's weigh in newtown. If the object weighs / / more than 500 newtons, the function also displays a message indicating that / / it is too heavy. If the object weighs less than 100 newtons, the function / / also displays a message indicating that it is too light.

+4
Answers (1)
  1. 25 August, 11:58
    0
    import java. util. Scanner;

    public class num8 {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

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

    double mass = in. nextDouble ();

    double weight = calWeight (mass);

    System. out. println ("The weigth is "+weight);

    }

    static double calWeight (double mass) {

    double weight = mass*9.80665; / / assume a = accelation due to gravity = 9.80665N

    if (weight>500) {

    System. out. println ("Too Heavy");

    }

    else if (weight<100) {

    System. out. println ("Too Light");

    }

    return weight;

    }

    }

    Explanation:

    Using Java programming language The main method is created to request and store a variable, mass in kilogram. The main method call calWeight () and passes the value for mass A method calWeight () is created that calculates the weight in newtons (mass * 9.8). The method checks if the weight is greater than 500 (prints too heavy) if less than 100 (prints to light) Returns the weight
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program that asks the user to enter an object's mass, then calls a / / function to return the object's weigh in newtown. If the ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers