Question

Java Language

Question 22 Design an algorithm that will get a test score (0 to 40) from the user. Convert the test score to a percentage anQuestion 23 Implement the solution algorithm of Question 22 in Java (15 marks)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have provided the defining diagram in handwritten format and provided the code for the same algorithm in Java with proper comments and indentation with screenshots. I hope you find it useful. If you have any doubts then please ask in the comments section. Since you didn't mentioned which question to solve? I have assumed that you are asking mainly for the Q23. Even though I provided with an algorithm and defining diagram for the same.

Defining Diagram:

Algorithm:

- Take the input of the marks

- Check if the marks are valid, if marks are invalid then print an error message and end the program

- Else calculate percentage

- Print grade according to the table given in the question

CODE:

------------------------------------------------------------------------------------------------------------------------------------------

// Importing scanner class
import java.util.Scanner;

public class abc {
    public static void main(String args[]) {
        // defining scanner class
        Scanner in = new Scanner(System.in);
        // Prompt for asking the marks
        System.out.println("Enter you marks : ");
        // Taking input of the marks
        int marks = in.nextInt();
        // Checking if marks are invalid and printing the error message
        if(marks < 0 || marks > 40){
           System.out.println("You entered invalid marks !");
        }
        // Else calculating the percentage and printing the appropriate grade
        else{
           double percentage = (marks / 40.0) * 100;
           if(percentage >= 80) System.out.println("A Grade");
           else if (percentage >=60) System.out.println("B Grade");
           else if (percentage >=50) System.out.println("C Grade");
           else System.out.println("F Grade");
        }
    }
}

------------------------------------------------------------------------------------------------------------------------------------------

Screenshots:

Output and Run :

For compiling you can use the following command -- "javac abc.java"

and for running you can use "java abc"

Add a comment
Know the answer?
Add Answer to:
Java Language Question 22 Design an algorithm that will get a test score (0 to 40)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Programming Language Edit and modify from the given code Perform the exact same logic, except...

    Java Programming Language Edit and modify from the given code Perform the exact same logic, except . . . The numeric ranges and corresponding letter grade will be stored in a file. Need error checking for: Being able to open the text file. The data makes sense: 1 text line of data would be 100 = A. Read in all of the numeric grades and letter grades and stored them into an array or arraylist. Then do the same logic....

  • SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes...

    SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array....

  • pls help me to write the defining algorithm,pseudo code and desk checking(2 test cases each) Design...

    pls help me to write the defining algorithm,pseudo code and desk checking(2 test cases each) Design an algorithm to accept income from the user; compute the income tax to be paid and display the income and the tax payable on the screen. 3. Income tax calculation is based on the following table. It is also available at this link: https://www.iras.gov.sg/irashome/Individuals/Locals/Working-Out-Your-Taxes/Income Tax-Rates/ (12 Marks) Chargeable Income Income Tax Rate (%) Gross Tax Payable (S) First $20,000 Next $10,000 200 First $30,000...

  • In Java Main method Your main program will prompt the user for a test name and...

    In Java Main method Your main program will prompt the user for a test name and the number of scores the user will enter. After creating an arraylist to hold the scores, prompt the user for all the scores to hold in the arraylist. After all the scores are entered, then repeat back the score & letter grade. GradeBook Object Create an instance of a GradeBook object and pass the test name and arraylist to set the instance variables. At...

  • answer the following question in the java programming language thank you!Definition: The Strategy pattern defines a...

    answer the following question in the java programming language thank you!Definition: The Strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use itYour assignment is to implement the Strategy pattern for the problem of computing an average for a list of submitted grades. The algorithms are as follows:Calculate the average grade for a list of integer numbersCalculate the average grade for a list of integer numbers,...

  • codeblock c++ language Write a program that reads students test scores in the range 0-200 from...

    codeblock c++ language Write a program that reads students test scores in the range 0-200 from a file until end of file (use e of() to check if ifstream reaches the End of File Stream) and store those scores in an array. It should then determine the number of students having scores in each of the following ranges: 0-24, 25-49, 50-74, 75-99, 100- 124, 125–149, 150-174, and 175–200. Finally, the program outputs the total number of students, each score range...

  • Q3) (20 Mark) A student's test score T is an integer between 0 and 100 corresponding...

    Q3) (20 Mark) A student's test score T is an integer between 0 and 100 corresponding to the experimental outcomes s0; s1,., s100. A score of 90 to 100 is an A, 80 to 89 is a B, 70 to 79 is a C, 60 to 69 is a D, and below 60 is a failing grade of F. If all scores between 51 and 100 are equally likely and a score of 50 or less never occurs, find the...

  • Need code written for a java eclipse program that will follow the skeleton code. Exams and...

    Need code written for a java eclipse program that will follow the skeleton code. Exams and assignments are weighted You will design a Java grade calculator for this assignment. A user should be able to calculate her/his letter grade in COMS/MIS 207 by inputting their scores obtained on worksheets, assignments and exams into the program. A skeleton code named GradeCompute.java containing the main method and stubs for a few other methods, is provided to you. You must not modify/make changes...

  • Question 1 (30 marks) The scores of 60 students in a test are: 58 49 48...

    Question 1 (30 marks) The scores of 60 students in a test are: 58 49 48 62 50 76 61 82 60 72 70 35 61 55 82 66 50 47 36 58 84 55 68 32 62 58 48 75 80 49 55 67 71 46 40 57 69 70 52 60 48 53 42 68 54 60 63 70 72 68 42 55 36 70 36 82 66 46 59 50 (i) Find the mean score of the...

  • in java plz amaining Time: 1 hour, 49 minutes, 15 seconds. Jestion Completion Status: Write a...

    in java plz amaining Time: 1 hour, 49 minutes, 15 seconds. Jestion Completion Status: Write a program that asks the user for an input file name, open, read ar number of students is not known. For each student there is a name and and display a letter grade for each student and the average test score fc • openFile: This method open and test the file, if file is not found and exit. Otherwise, return the opened file to the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT