Concept explainers
Suppose, when you run the following
public class Test {
public static void main(String[] args) {
java.util.Scanner Input = new java.util.Scanner(System.in);
double x = input.nextDouble();
double y = input.nextDouble();
double z = input.nextDouble();
System.out.println(“(x < y && y < z) is ” + (x < y && y < z));
System.out.println(“(x < y || y < z) is ” + (x < y || y < z));
System.out.println(“!(x < y) is ” + !(x < y));
System.out.println(“(x + y < z) is ” + (x + y < z));
System.out.println(“(x + y > z) is ” + (x + y > z));
}
}
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (3rd Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Computer Science: An Overview (12th Edition)
Starting Out with C++: Early Objects (9th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
- Write a Java program, GradeApp that reads a series of exam scores given as integers in the range 0 to 100. Display the total number of grades and the number of grades in each letter-grade category, followed class average (as a percentage with 2 decimal place): Use the value -1 as a sentinel value to indicate the end of the input. (The -1 value is used only to end the loop. Please do not use it in the calculations.)arrow_forwardI need help with a Java question described below: Integers firstRange and secondRange are read from input. Complete the outer while loop so the inner loop executes (firstRange + 1) * secondRange times. Ex: If the input is 3 6, then the output is: Inner loop ran 24 times - import java.util.Scanner; public class NestedLoops { public static void main (String[] args) { Scanner scnr = new Scanner(System.in); int firstRange; int secondRange; int count; int i; int j; firstRange = scnr.nextInt(); secondRange = scnr.nextInt(); count = 0; i = 0; while (/* Your code goes here */) { j = 0; while (j < secondRange) { ++count; ++j; } ++i; } System.out.println("Inner loop ran " + count + " times"); } }arrow_forwardJAVA What is the output of the following code sequence when the user successively enters 3, 5, and -1? Scanner scan = new Scanner(System.in); int i = 0; while(i != -1) { System.out.println("RED"); i = scan.nextInt(); } System.out.println("END");arrow_forward
- What is the output of the following java code? Scanner input = new Scanner("15 10"); String sum = input.nextInt()+ input.nextInt(); System.out.println(sum); 150 1510 15 10 An error messagearrow_forwardTo write a java program that display inputs of an integer, n, from the command line and displays the string "1 + 2 + 3 + 4 + ... + n = sum." For example, if the command-line argument is 7, the output should be: The sum of (1 + 2 + 3 + 4 + 5 + 6 + 7) = 28 Make sure the number entered on the command line is positive.arrow_forwardWrite a java program: Using a single print() method [i.e., System.out.print()], create output shown below: Line 1Line 2Line 3Line 4 Line 5arrow_forward
- Write a java program that uses the Scanner to ask the user for an integer, but forces the user to re-enter the number if they enter a negative value. Then if the number is odd, print it out. Otherwise, check if the number is greater than 10 and if so, print it out twice. For example: 3 is printed once 8 is not printed 13 is printed once 40 is printed twicearrow_forwardI have a difficult task that i have been given, the problem is that I just simply cant seem to manage to first print a binary number so if you give me six my code doesnt seem to print the number in binary. but also i need to print it in reverse and my code just doesnt seem to work with that. heres my code import java.util.Scanner; public class LabProgram { public static void main(String[] args) { int x; int output; int i; Scanner input = new Scanner(System.in); x = input.nextInt(); output = x; for ( i = 0; i <= x; i = ++i){ output = x / 2; System.out.println(output); } } } // and bellow this are my instructions . what am i doing wrong what am i missing? ive googled sites and erased portions of code, put in eithers. ive switched back and forth from a for loop to a while loop for awhile now Write a program that takes in a positive integer as input, and…arrow_forwardWhat will be the output of the following Java program? class Output { public static void main(String args[]) { Double i = new Double(257.5); Double x = i.MAX_VALUE; System.out.print(x); } }arrow_forward
- I need help to Fill in the two methods in the .java file in the following below: public class JavaProject{public static int[][] sum(int[][] A, int[][] B){//TODO: Your code should go herereturn null; //This line is wrong and should be changed.} public static int[][] cutOffTheCrust(int[][] input){//TODO: Your code should go here return null; //This line is wrong and should be changed.}public static int[][] getSubsetRows(int[][] input, int row_start, int row_end){//TODO: Your code should go here return null; //This line is wrong and should be changed.}public static void main(String[] args){System.out.println("=== TESTING sum Test 1 ===");int[][] input1 = {{1, 5},{4, 6}};int[][] input2 = {{7, 3},{5, 4}};int[][] result = sum(input1, input2);printArray(result); System.out.println("=== TESTING sum Test 2 ===");int[][] input7 = {{1, 5, 1, 0},{4, 6, -3, 7}};int[][] input8 = {{7, 3, 1, 1},{5, 4, 0, -2}};result = sum(input7, input8);printArray(result); System.out.println("=== TESTING…arrow_forwardWhen the given integer variable numberOfTools is: less than 14, output "Small tool box". between 14 inclusive and 39 inclusive, output "Mid-sized tool box". greater than 39, output "Need wall storage". End with a newline. Ex: If the input is 13, then the output is: (in java) Given Code: import java.util.Scanner; public class ToolDetails {public static void main(String[] args) {Scanner scnr = new Scanner(System.in);int numberOfTools; numberOfTools = scnr.nextInt();arrow_forwardCreate a JAVA program Write a program that reads total marks of 5 students and give their grades according to the following table. (Can we use switch?) Total mark Grade Equal or above 90 A Between 80 and less than 90 B Between 70 and less than 80 C Between 60 and less than 70 D Less than 60 Farrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education