Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Main.java 5. Main.java + Main.java 115116117118/Exercise5:Threevaluesover10Thishasthesamevariables:1,2,3 * In this case if any one of the three values is greater * than 10 print Yes, otherwise

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Main.java 5. Main.java + Main.java 115116117118/Exercise5:Threevaluesover10Thishasthesamevariables:1,2,3 * In this case if any one of the three values is greater * than 10 print "Yes", otherwise print "No" / public static void exercise_5_0ne_Value_0ver_10() \{ I/ Comment out the line below when you are working on this exercise System.out.println( "Suppress detailed output for this exercise "); I/ Get the data int 1= projectData.nextInt( ) int 2= projectData. nextInt(); int 3= projectData.nextInt(); /I These lines could use some work. Feel free to use additional /I else-if blocks, or anything else you need if (x1>102>10 || x3>10) if (x1!=0){ System.out.println( "Yes"); \} else \{ System.out.println( "No"); \} \} * Exercise 6: Keep going * This logic might belong in a smart car. It has two variables * - int milestraveled represents the total miles since recharging * - boolean stopImmediately stores either true of false * If stopImmediately is true or milestravled is greater than 300 * print "Stop". 0therwise print "Keep Going" * See if you can do this with a single if statement to practice * combining a boolean variable and a numeric comparison in a single * boolean expression. / public static void exercise_6_Should_Keep_Going() \{ // Comment out the line below when you are working on this exercise System.out.println( "Suppress detailed output for this exercise "); II Get the data int milesTraveled = projectData. nextInt(); boolean stopImmediately = projectData.nextBoolean( ); if ( milesTraveled >0){// This line needs some work System. out.println( "Stop"); \} else \{ System.out.println( "Keep Going"); \} 108: Col 1 (1 chars) * Exercise 8: The answer is yes * In this exercise the input is a single string. * Print "yes" if the string is "Yes", "yes", "Y", or " y " * Otherwise print "no" / public static void exercise_Yes_8_() \{ // Comment out this line System.out.println( "Suppress detailed output for this exercise "); // Get the data String response = projectData.nextLine( ) if (response.equals( "what?")) \{ // this line needs some work System.out. println("yes"); \} else \{ System.out. println( "no"); \} \} * Exercise 9: Comparing Doubles * There is an odd trick that is required when you are * comparing two double values to see if they are equal. Col 1 (1 chars) History (5) Run 4. Main.java x+ A. Main.|ava Run 3. Main.java + 3. Main.java Line 108: Col 1 ( 1 chars) History (3) Main.java 5. Main.java + Main.java 115116117118/Exercise5:Threevaluesover10Thishasthesamevariables:1,2,3 * In this case if any one of the three values is greater * than 10 print "Yes", otherwise print "No" / public static void exercise_5_0ne_Value_0ver_10() \{ I/ Comment out the line below when you are working on this exercise System.out.println( "Suppress detailed output for this exercise "); I/ Get the data int 1= projectData.nextInt( ) int 2= projectData. nextInt(); int 3= projectData.nextInt(); /I These lines could use some work. Feel free to use additional /I else-if blocks, or anything else you need if (x1>102>10 || x3>10) if (x1!=0){ System.out.println( "Yes"); \} else \{ System.out.println( "No"); \} \} * Exercise 6: Keep going * This logic might belong in a smart car. It has two variables * - int milestraveled represents the total miles since recharging * - boolean stopImmediately stores either true of false * If stopImmediately is true or milestravled is greater than 300 * print "Stop". 0therwise print "Keep Going" * See if you can do this with a single if statement to practice * combining a boolean variable and a numeric comparison in a single * boolean expression. / public static void exercise_6_Should_Keep_Going() \{ // Comment out the line below when you are working on this exercise System.out.println( "Suppress detailed output for this exercise "); II Get the data int milesTraveled = projectData. nextInt(); boolean stopImmediately = projectData.nextBoolean( ); if ( milesTraveled >0){// This line needs some work System. out.println( "Stop"); \} else \{ System.out.println( "Keep Going"); \} 108: Col 1 (1 chars) * Exercise 8: The answer is yes * In this exercise the input is a single string. * Print "yes" if the string is "Yes", "yes", "Y", or " y " * Otherwise print "no" / public static void exercise_Yes_8_() \{ // Comment out this line System.out.println( "Suppress detailed output for this exercise "); // Get the data String response = projectData.nextLine( ) if (response.equals( "what?")) \{ // this line needs some work System.out. println("yes"); \} else \{ System.out. println( "no"); \} \} * Exercise 9: Comparing Doubles * There is an odd trick that is required when you are * comparing two double values to see if they are equal. Col 1 (1 chars) History (5) Run 4. Main.java x+ A. Main.|ava Run 3. Main.java + 3. Main.java Line 108: Col 1 ( 1 chars) History (3)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions