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) ? “sorted” : “not sorted”);
}
}
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)
Web Development and Design Foundations with HTML5 (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Using MIS (10th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
- Write a java program: Using a single print() method [i.e., System.out.print()], create output shown below: Line 1Line 2Line 3Line 4 Line 5arrow_forwardWrite 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_forwardWrite 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_forward
- THIS IS IN JAVA Question: Given a line of text as input, output the number of characters excluding spaces, periods, exclamation points, or commas. Ex: If the input is: Listen, Mr. Jones, calm down. the output is: 21 Note: Account for all characters that aren't spaces, periods, exclamation points, or commas (Ex: "r", "2", "?"). My incorrect code: import java.util.Scanner; public class LabProgram { public static void main(String[] args) {Scanner scnr = new Scanner(System.in); String userText; int count = 0; userText = scnr.nextLine(); for (int i = 0; i < userText.length(); i++) { if (userText.charAt(i) != ' ' && userText.charAt(i) != '.' && userText.charAt(i) != ',') count++; } System.out.println(count); }} An example/hint i'm given to compare to my code as to why i'm getting it wrong: Output differs. See highlights below. Input Howdy! Your output 6 Expected output 5 Please…arrow_forwardTHIS IS IN JAVA Question: Given a line of text as input, output the number of characters excluding spaces, periods, exclamation points, or commas. Ex: If the input is: Listen, Mr. Jones, calm down. the output is: 21 Note: Account for all characters that aren't spaces, periods, exclamation points, or commas (Ex: "r", "2", "?"). My incorrect code: import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String userText; int counter = 0; userText = scnr.nextLine(); for (int i = 0; i < userText.length(); i++) { if (userText.charAt(i) != ' ' && userText.charAt(i)!= '.' && userText.charAt(i) != ',') { counter++; } } System.out.println(counter); }} example/hint i'm given to compare to my code as to why i'm getting it wrong: Output differs. See highlights below. Input: Howdy! Your output: 6 Expected output: 5 Output…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 creating a Java code where when the user types 2 the program would just show the number of throws it took. The rest of the Java code is fine but I can't input the elseif when the user types 2 Output is when the user types 2 when the program prints to "Just print the answer" Java code: import java.util.Scanner;public class Dice_Face_In_a_row_FallProject_2 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int diceFaceNumber, numTimes, numThrows; char choice; do { System.out.println(" This game throws a dice until a particular dice face number"); System.out.println(" appears in a row a certain number of times."); System.out.println("Please enter the version you want:"); System.out.println(" 1) Trace the game."); System.out.println(" 2) Just give the answer"); System.out.println("Please enter 1 or 2"); Scanner input = new Scanner(System.in); int a = input.nextInt(); if (a == 1) { System.out.println("Please enter…arrow_forwardAnswer the given question with a proper explanation and step-by-step solution. Java: please do not copy/ paste from another solution because it is wrong, I am looking for the same output /******* My question is how can I put the (while loop, do-while, if - else condition) in methods ? below: is a solution how can you fix it ? import java.util.Scanner; public class Main { public static void main(String[] args) { int menuChoice; Scanner keyboard = new Scanner(System.in); while (true) { do { printMenuOptions(); menuChoice = getUserChoice(keyboard); if (menuChoice <= -1) { System.out.println("Invalid number"); } else { if (menuChoice > 5) { System.out.println("Invalid number choose between 0 to 5."); } } } while (menuChoice <= -1 || menuChoice > 5 || menuChoice == 5); // Rest of your code goes here } } public static void printMenuOptions() { System.out.println("what do you like"); System.out.println("1. pepsi"); System.out.println("2. sprit"); System.out.println("3.…arrow_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_forward
- What should I edit or do in my code so that I will get the outcome? What could be edited in my code below to acheive the desired outcome? import java.util.Scanner; class program { } class prog1 extends program implements Runnable { private String nVoters = new String(""); public prog1 (String nVote){ nVoters = nVote; } @Override public void run(){ for (int x = 1; x <= input; x++){ System.out.println(" Voter " + x + "\t" + nVoters + "= " ); } }} public class Quiz2 { public static void main(String args[]){ Scanner sc = new Scanner(System.in); for (int x = 0; x < args.length; x++){ System.out.println(args[x]); } System.out.print("Enter number of voters: "); int input = sc.nextInt(); Runnable r = new prog1("Thread #1"); Thread Candidate1 = new Thread(r); Candidate1.start(); r = new prog1("Thread #2"); Thread Candidate2 = new…arrow_forwardMAke this code runnable with outputimport java.util.Scanner;public class Project04 {public static void main(String[] args) {Scanner keyboard=new Scanner(System.in);int win = 0,lose=0, tie=0;while (win<2) {System.out.print("Please select one of your dragons[Fire/Plant/Water]: ");String player=keyboard.nextLine();System.out.println("You chose: " + player + " dragon");int x=(int) Math.floor(Math.random()*3+1);String fire1="Fire",fire2="FIRE",fire3="fire",fire4="F",fire5="f";Stringplant1="Plant",plant2="PLANT",plant3="plant",plant4="P",plant5="p";Stringwater1="Water",water2="WATER",water3="water",water4="W",water5="w";if (x==1) {String CPU="Fire";System.out.println("I chose: " + CPU + " dragon");if (player.equalsIgnoreCase(fire1)||player.equalsIgnoreCase(fire2)||player.equalsIgnoreCase(fire3)||player.equalsIgnoreCase(fire4)||player.equalsIgnoreCase(fire5)) {System.out.println("A Tie!");tie++;}else…arrow_forwardSomeone please help and teach me , based on the java source code given , how can i add a feature of "virtual money account transfer to the bank account" in this program. package orderingsystem; import java.util.Scanner;public class Orderingsystem {public static Scanner input = new Scanner(System.in);public static String again;public static int choose,quantity=1;public static double total=0,pay;public static void menu(){System.out.println("\t\t\t\t+=======================================+");System.out.println("\t\t\t\t+ Food Menu +");System.out.println("\t\t\t\t+ 1. Aloe vera RM 45 +");System.out.println("\t\t\t\t+ 2. Appple Juice RM 40 +");System.out.println("\t\t\t\t+ 3. Banana Juice RM 49 +");System.out.println("\t\t\t\t+ 4. Cancel +");System.out.println("\t\t\t\t+=======================================+");}public static void order (){System.out.println("Press 1 to Aloe vera ,Press 2 to Appple Juice ,Press 3 to Banana Juice,Press 4 to cancel");System.out.println("what you want to…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