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)
- The following program has 10 blanks, all of which can be deduced from other given parts of the program. blank java.util.Scanner; public class Perimeter { public static Blank main(String [] args) { double length, width, Blank ; Scanner Blank= new Scanner(); System.Blank .print("Enter the length of the rectangle: "); length = scan.nextDouble(); System.out.print("Enter the width of the rectangle: "); width = scan.next Blank(); perimeter = Blank*2 + width*2; System.out. ("%s%f%s, "The perimeter of the rectangle is " + Blank + " inches."); }//end blank method }//end classarrow_forwardI have my code here and I am getting errors (I have also attached my code): " import java.util.Compiler; public class Test Score { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Ënter the first exam Score: "); Double Score1 = scan.nextDouble(); System.out.println("Enter the second exam Score: "); Double Score2 = scan.nextDouble(); System.out.println("Enter the third exam Score: "); Double Score3 = scan.nextDouble(); System.out.println("Enter the fourth exam Score: "); Double Score4 = scan.nextDouble(); System.out.println("Enter the fifth exam Score: "); Double Score5 = scan.nextDouble(); Double total = Score1 + Score2 + Score3 + Score4 + Score5 Double average = total/5; if (average >= 90) { System.out.printf("your average was a: %f and recieved an A in this Class", average ); } else if (average >= 80) {…arrow_forward1. What is the output of the following program? import java.util.Scanner; public class Factorial { public static void main(String args[]){ Scanner scanner = new Scanner(System.in); System.out.printIn("Enter the number:"); scanner.nextInt(); int factorial = fact(num); System.out.println("Factorial of int num = entered number is: "+factorial); } static int fact(int n) { int output; if(n==1){ return 1; } output = fact(n-1)* n; return output; } }arrow_forward
- Is this the correct Java programming code when repeat the images below using the text method of input and output? import java.util.Scanner; public class Main { public static void main(String[] args) { //scanner object Scanner scnr = new Scanner(System.in); String name,street,city,postalcode; //input System.out.print("What is your name? "); name = scnr.nextLine(); System.out.print("stret name "); street = scnr.nextLine(); System.out.print("City name "); city = scnr.nextLine(); System.out.print("Postal code "); postalcode = scnr.nextLine(); } }arrow_forwardYou are required to implement a preprocessor in Java. Your preprocessor should be able to perform the following task:Identifying loops and methods Example of output: import java.util.Scanner public class String Scanner new Scanner(System.in) System.out.print.ln nextLine voidarrow_forwardStatistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics. Ex: When the input is: 15 20 0 5 -1 the output is: 10 20 You can assume that at least one non-negative integer is input. import java.util.Scanner; public class LabProgram {public static void main(String[] args) {Scanner scnr = new Scanner(System.in);int numValue;int average;int max;int numValues;int numTotal;numTotal = 0;numValues = 0;max = 0;numValue = scnr.nextInt();while (numValue > 0){numTotal = numTotal + numValue;numValues = numValues + 1;numValue = scnr.nextInt();}average = numTotal / numValues;System.out.print(average);while (numValues > max){max = numValues;System.out.print(" " + max);} }} Why is it giving me the wrong output??arrow_forward
- This isn't not working for me. import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userNum = in.nextInt(); int divNum = in.nextInt(); System.out.print("What is the user number?"); userNum = scnr.nextInt(); int a, b, c; a = userNum/divNum; System.out.println(a); b = a/divNum; System.out.println(b); c = b/divNum; System.out.println(c); }} ERROR LabProgram.java:6: error: cannot find symbol int userNum = in.nextInt(); ^ symbol: variable in location: class LabProgram LabProgram.java:7: error: cannot find symbol int divNum = in.nextInt(); ^ symbol: variable in location: class LabProgram 2 errorsarrow_forwardCreate a Flowchart //Java Source Code :- import java.util.Scanner; public class bExpert { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("\nVALUES"); System.out.print("Value 1: "); int v1 = sc.nextInt(); System.out.print("Value 2: "); int v2 = sc.nextInt(); System.out.print("Value 3: "); int v3 = sc.nextInt(); System.out.println("\nPROCESS"); System.out.println("\n1. Summation"); System.out.println("2. Product"); System.out.println("3. Min / Max"); System.out.println("4. Odd / Even"); char st = 'y'; while(st != 'n'){ System.out.print("\nCHOICE: "); int ch = sc.nextInt(); switch(ch) { case 1: int sum = v1 + v2 + v3; System.out.println("\nSum = "+sum); break; case 2: int prod =…arrow_forwardimport java.util.Scanner; public class leapYearLab { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userYear; boolean LeapYear; System.out.println("Enter the year"); userYear = scnr.nextInt(); isLeapYear(userYear); //if leap year if (isLeapYear){ System.out.println(userYear + " - leap year"); } else{ System.out.println(userYear + " - not a leap year"); } scnr.close(); } public static boolean isLeapYear(int userYear){ boolean LeapYear; /* Type your code here. */ if ( userYear % 4 == 0) { // checking if year is divisible by 100 if ( userYear % 100 == 0) { // checking if year is divisible by 400 // then it is a leap year if ( userYear % 400 == 0) LeapYear = true; else LeapYear = false; } // if the year is not divisible by 100 else…arrow_forward
- Write a for loop that prints: 1 2 … countNum Ex: If the input is: 4 the output is: 1 2 3 4arrow_forwardDraw the flowchart of this code below import java.util.*;public class Test{public static void main(String[] args){Scanner scan = new Scanner(System.in);double base, height, area;System.out.println("Enter the value of base of triangle: ");base = scan.nextDouble();System.out.println("Enter the value of height of triangle: ");height = scan.nextDouble();area = base*height*0.5;System.out.println("The area of triangle is: " + area);}}arrow_forwardContinuing from the example, modify the program so that it outputs the average grade in each course, and also shows which course has the highest average grade. import java.util.Scanner; public class Main { publicstaticvoid main(String[] args) { Scanner s = new Scanner(System.in); int numCourses, numTests; double[][] testScores; System.out.print("How many courses are you taking? "); numCourses = s.nextInt(); testScores = new double[numCourses][]; // allocate an array of references to 1-D arrays (rows) for(int i = 0; i < numCourses; i++) { System.out.print("How many tests are in course number " + (i+1) + "? "); numTests = s.nextInt(); // allocate this row: a 1-D array of doubles: testScores[i] = new double[numTests]; } for(int courseId=0; courseId < testScores.length; courseId++) { for(int testId=0; testId < testScores[courseId].length; testId++) { System.out.print("What was your grade on test " + (testId+1) + " for course " + (courseId+1) + "? ");…arrow_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