Question

Write an expression that will cause "greater or equal to -10" to print if the value...

Write an expression that will cause "greater or equal to -10" to print if the value of userNum is greater than or equal to -10.

import java.util.Scanner;

public class EqualityAndRelational {
   public static void main (String [] args) {
      int userNum;

      Scanner scnr = new Scanner(System.in);
      userNum = scnr.nextInt(); // Program will be tested with values: -9, -10, -11, -12.

      if (//solution goes here//) {
         System.out.println("greater or equal to -10");
      }
      else {
         System.out.println("less than -10");
      }
   }
}

Homework Answers

Answer #1
import java.util.Scanner;

public class EqualityAndRelational {
    public static void main (String [] args) {
        int userNum;

        Scanner scnr = new Scanner(System.in);
        userNum = scnr.nextInt(); // Program will be tested with values: -9, -10, -11, -12.

        if (userNum >= -10) {
            System.out.println("greater or equal to -10");
        }
        else {
            System.out.println("less than -10");
        }
    }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write an expression that will cause "Foot or more" to print if the value of numInches...
Write an expression that will cause "Foot or more" to print if the value of numInches is greater than or equal to 12. import java.util.Scanner; public class EqualityAndRelational {    public static void main (String [] args) {       int numInches;       Scanner scnr = new Scanner(System.in);       numInches = scnr.nextInt(); // Program will be tested with values: 10, 11, 12, 13.       if (/* Your solution goes here */) {          System.out.println("Foot or more");       }       else {...
Write an if-else statement that checks patronAge. If 55 or greater, print "Senior citizen", otherwise print...
Write an if-else statement that checks patronAge. If 55 or greater, print "Senior citizen", otherwise print "Not senior citizen" (without quotes). End with newline. import java.util.Scanner; public class DetectSenior {    public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       int patronAge; //Solution goes here//       patronAge = scnr.nextInt();    } }
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of 0 1 0 -1. See "How to Use zyBooks". Also note: If the submitted code has an...
4.9.1: Nested loops: Indent text. JAVA Print numbers 0, 1, 2, ..., userNum as shown, with...
4.9.1: Nested loops: Indent text. JAVA Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces after the printed number. Ex: userNum = 3 prints: 0 1 2 3 Please use my template import java.util.Scanner; public class...
Write a for loop to print all elements in courseGrades, following each element with a space...
Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print: 7 9 11 10 10 11 9 7 Hint: Use two for loops. Second loop starts with i = courseGrades.length - 1. (Notes) IN JAVA: import java.util.Scanner; public class CourseGradePrinter { public static void main (String [] args) { Scanner scnr =...
in JAVA Write a switch statement that checks origLetter. If 'a' or 'A', print "Alpha". If...
in JAVA Write a switch statement that checks origLetter. If 'a' or 'A', print "Alpha". If 'b' or 'B', print "Beta". For any other character, print "Unknown". Use fall-through as appropriate. End with newline. import java.util.Scanner; public class ConvertToGreek { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); char origLetter; origLetter = scnr.next().charAt(0); /* Your solution goes here */ } }
Write a for loop that prints: 1 2 ... userNum Ex: userNum = 4 prints: 1...
Write a for loop that prints: 1 2 ... userNum Ex: userNum = 4 prints: 1 2 3 4 import java.util.Scanner; public class ForLoops { public static void main (String [] args) { int userNum; int i; Scanner input = new Scanner(System.in); userNum = input.nextInt(); for (/* Your code goes here */) { System.out.print(i + " "); } } } Need to fill out the "for" solved in JAVA
Write a loop that sets each array element to the sum of itself and the next...
Write a loop that sets each array element to the sum of itself and the next element, except for the last element which stays the same. Be careful not to index beyond the last element. Ex: Initial Scores: 10, 20, 30, 40 Scores after loop: 30, 50, 70, 40 Import. java.util.Scanner; public class StudentScores { public static void main (String [] args){ Scanner scnr = new Scanner (System.in); final int SCORES_SIZE = 4; int [] bonusScores = new int[SCORES_SIZE]; int...
Complete the program below. The program takes in two positive integers, n and m, and should...
Complete the program below. The program takes in two positive integers, n and m, and should print out all the powers of n that are less than or equal to m, on seperate lines. Assume both n and m are positive with n less than or equal to m. For example, if the input values are n = 2 and m = 40 the output should be: 2 4 8 16 32 Starter code: import java.util.Scanner; public class Powers {...
Array testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total...
Array testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full credit is 100, so anything over 100 is extra credit. Ex: If testGrades = {101, 83, 107, 90}, then sumExtra = 8, because 1 + 0 + 7 + 0 is 8. Java COde: import java.util.Scanner; public class SumOfExcess { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); final int NUM_VALS = 4; int[] testGrades...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT