Knowee
Questions
Features
Study Tools

Try the following code. Add an else statement to the if statement that prints out “Good job!” if the score is greater than 9. Change the value of score to test it. Can you change the boolean test to only print out “Good job” if the score is greater than 20?Save & RunOriginal - 1 of 1Show CodeLensReformat1public class ScoreTest2{3 public static void main(String[] args)4 {5 int score = 8;6 if (score <= 9)7 {8 System.out.println("Try for a higher score!");9 }10 }11}12​13​Try for a higher score!Result Expected Actual NotesFail true false Checking for score <= 20 or score > 20Fail Good job! Checking output if score is 25Pass Try for a higher score! Try for a higher score! Checking output if score is 5Fail true false Checking that code contains elseFail true false Checking that code has been changed

Question

Try the following code. Add an else statement to the if statement that prints out “Good job!” if the score is greater than 9. Change the value of score to test it. Can you change the boolean test to only print out “Good job” if the score is greater than 20?Save & RunOriginal - 1 of 1Show CodeLensReformat1public class ScoreTest2{3 public static void main(String[] args)4 {5 int score = 8;6 if (score <= 9)7 {8 System.out.println("Try for a higher score!");9 }10 }11}12​13​Try for a higher score!Result Expected Actual NotesFail true false Checking for score <= 20 or score > 20Fail Good job! Checking output if score is 25Pass Try for a higher score! Try for a higher score! Checking output if score is 5Fail true false Checking that code contains elseFail true false Checking that code has been changed

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

It seems like you want to modify the Java code to add an else statement that prints "Good job!" if the score is greater than 9. Also, you want to change the boolean test to print "Good job" only if the score is greater than 20. Here's how you can do it:

public class ScoreTest
{
    public static void main(String[] args)
    {
        int score = 25; // Change the score value to test
        if (score <= 20)
        {
            System.out.println("Try for a higher score!");
        }
        else
        {
            System.out.println("Good job!");
        }
    }
}

In this code, if the score is less than or equal to 20, it will print "Try for a higher score!". If the score is greater than 20, it will print "Good job!". You can change the value of score to test different scenarios.

This problem has been solved

Similar Questions

Try the following code. Add an else statement to the if statement that prints out “Good job!” if the score is greater than 9. Change the value of score to test it. Can you change the boolean test to only print out “Good job” if the score is greater than 20?Save & RunOriginal - 1 of 1Show CodeLensReformat1public class ScoreTest2{3 public static void main(String[] args)4 {5 int score = 8;6 if (score <= 9)7 {8 System.out.println("Try for a higher score!");9 }10 }11}12​13​Try for a higher score!Result Expected Actual NotesFail true false Checking for score <= 20 or score > 20Fail Good job! Checking output if score is 25Pass Try for a higher score! Try for a higher score! Checking output if score is 5Fail true false Checking that code contains elseFail true false Checking that code has been changed

Step 1 (3 pts). Complete the CheckSingles() function. Return the sum of all values that match parameter goal. Update the FindHighScore() function using a loop to call CheckSingles() six times with parameters being 1 - 6. Return the highest score from all function calls. Submit for grading to confirm two tests pass.Ex: If input is:2 4 1 5 4the output is:High score: 8

Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error. If the score is between 0.0 and 1.0, print a grade using the following table:Score Grade>= 0.9 A>= 0.8 B>= 0.7 C>= 0.6 D< 0.6 FIf the user enters a value out of range, print a suitable error message and exit. For the test, enter a score of 0.85.

Single File Programming QuestionProblem statementRaja is designing a simple game where players earn points based on their performance. Each player starts with a default score of 100. If a player completes a level, they earn 20 points. However, for each unsuccessful attempt, they lose 10 points. Additionally, if a player's score drops below 50, they are disqualified. Write a program that takes the number of successful and unsuccessful attempts from the user and calculates the player's final score using the Relational and Ternary operators.ExamplesInput215OutputThe player is disqualified.Explanation: In this case, the player has 2 successful attempts and 15 unsuccessful attempts.finalScore = 100 + (2 * 20) - (15 * 10) = 100 + 40 - 150 = -10Since the final score is below 50, the player is disqualified.Input5010OutputThe player's final score is 1000.Explanation: In this case, the player has 50 successful attempts and 10 unsuccessful attempts.finalScore = 100 + (50 * 20) - (10 * 10) = 100 + 1000 - 100 = 1000The final score is 1000, and it is greater than or equal to 50, so the player is not disqualified.Input format :The first line of input consists of an integer value 'n', representing the number of successful attempts.The second line of input consists of an integer value 'n1', representing the number of unsuccessful attempts.Output format :If the player is disqualified it displays as: "The player is disqualified."If the player is qualified, the final score is displayed in the format "The player's final score is [score]."Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1 ≤ n ≤ 501 ≤ n1 ≤ 30Sample test cases :Input 1 :215Output 1 :The player is disqualified.Input 2 :1030Output 2 :The player is disqualified.Input 3 :5010Output 3 :The player's final score is 1000.Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.

Check the following Java program carefully. What should be written in the blank? Choose from the given options.                                        public class Test {  public static void main(String[] args) {    System.out.print("The grade is " + getGrade(78.5));    System.out.print("\nThe grade is " + getGrade(59.5));  }  public static ________ getGrade(double score) {    if (score >= 90.0)      return 'A';    else if (score >= 80.0)      return 'B';    else if (score >= 70.0)      return 'C';    else if (score >= 60.0)      return 'D';    else      return 'F';  }}Group of answer choicesvoidStringintchar

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.