0% found this document useful (0 votes)
9 views3 pages

Program4 12A Olisa Ferati

Uploaded by

Olisa Ferati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Program4 12A Olisa Ferati

Uploaded by

Olisa Ferati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Create a Java program that accepts a student's score (between 0 and 100) and outputs the
corresponding grade based on the school's grading system.

The program should prompt the user to enter a score (an integer between 0 and 100).

Based on the input score, the program will assign a grade as per the following grading system:

0 to 39 → Grade 1

40 to 54 → Grade 2

55 to 69 → Grade 3

70 to 84 → Grade 4

85 to 100 → Grade 5

Write the code below:

import java.util.Scanner;

class Main {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Enter the student's score (0-100): ");

int score = scanner.nextInt();

if (score < 0 || score > 100) {

System.out.println("Invalid score! Please enter a value between 0 and 100.");

} else {

int grade;

if (score <= 39) {


grade = 1;

} else if (score <= 54) {

grade = 2;

} else if (score <= 69) {

grade = 3;

} else if (score <= 84) {

grade = 4;

} else {

grade = 5;

System.out.println("The grade is: " + grade);

scanner.close();

}
2. Create a Java program that uses the switch statement to evaluate a given input and print an appropriate
message based on the value of that input.

Write the code below:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy