Note that there are some explanatory texts on larger screens.

plurals
  1. PONo if-else branch is entered on certain values
    text
    copied!<p>I am have a little trouble with this java homework. I am still fairly new to this programming work. I am having trouble making the program do the following: Scientists measure an object’s mass in kilograms and its weight in Newtons. If you know the amount of mass that an object has, you can calculate its weight, in Newtons, with the following formula:</p> <p>Weight = mass X 9.8</p> <p>Write a program that asks the user to enter an object’s mass, and then calculate its weight. If the object weighs more than 1000 Newtons, display a message indicating that it is too heavy. If the object weighs less than 10 Newtons, display a message indicating that the object is too light.</p> <p>this is what I have written so far: </p> <pre><code>import java.util.Scanner; public class MassandWeight{ public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); double mass; System.out.print("Please enter the object's mass: "); mass = keyboard.nextDouble(); // Convert the mass to weight using the following expression: double weight = (mass * 9.8); if (weight &gt;= 10 &amp;&amp; weight &lt;= 1000) System.out.println("The weight of the object is " + weight + "."); else if (weight &gt; 1001) System.out.println("The object's weight is too heavy."); else if (weight &lt; 9) System.out.println("The object's weight is too light."); } } </code></pre> <p>so everything works great! and I am really proud of myself for getting this far. however when I enter "1" i get no response back. everything else works great. if you need more information, please let me know. Thank you!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload