Question: Java Write an if-else statement for the following: If numDifference is greater than -20, execute totalDifference = -10. Else, execute totalDifference = numDifference. import java.util.Scanner;

Java

Write an if-else statement for the following: If numDifference is greater than -20, execute totalDifference = -10. Else, execute totalDifference = numDifference.

import java.util.Scanner;

public class NumberDifference { public static void main (String [] args) { int totalDifference; int numDifference;

Scanner scnr = new Scanner(System.in); numDifference = scnr.nextInt(); // Program will be tested with values: -18, -19, -20, -21.

/* Your solution goes here */

System.out.println(totalDifference); } }

Java Write an if-else statement for the following: If numDifference is greater

ACIIEN.2.3: Basic if-else Reset Write an if-else statement for the following: If numDifference is greater than -20, execute totalDifference--10. Else, execute totalDifference- numDifference. 1 import java.util.scanner; 3 public class NumberDifference f 4 public static void main (String [] args) int totalDifference; int numDifference; 6 9ncaniererence nscnscnenernsiot l progran wi1l be tested with values: 18, -19, -20, -21. nunDifference = scnr.nextint ( ); // Program will be tested with values: -18, -19, -20, -21. /Your solution goes here */ System.out.println (totalDifference); 12 13 14 15 2 Check Next Feedback

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!