0% found this document useful (0 votes)
14 views2 pages

CSC 218 Assignment

The document contains a Java code snippet for a grade calculator that uses an elseif-elseif-else structure to determine a student's grade based on their score. The grading scale is defined with specific score ranges for grades A through F. The program prompts the user to input a score and then outputs the corresponding grade.

Uploaded by

Nanji Lakan
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)
14 views2 pages

CSC 218 Assignment

The document contains a Java code snippet for a grade calculator that uses an elseif-elseif-else structure to determine a student's grade based on their score. The grading scale is defined with specific score ranges for grades A through F. The program prompts the user to input a score and then outputs the corresponding grade.

Uploaded by

Nanji Lakan
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/ 2

NAME: NANJI EMMANUELLA LAKAN

MATRIC NO: U21CS1031

DEPARTMENT:COMPUTER SCIENCE

COURSE CODE: CSC 218 (FUNDAMENTALS OF SQUENTIAL PROGRAMMING)

1. use the elseif-elseif-else structure in java to write a code that will display the grade of a student as
A,B,C,D,E,F depending on the scores input depending on the score entered by the keyboard.

Giving the Grade scores below:

A-100-70

B-69-65

C-64-55

D-54-50

E-49-45

Or else F

import java.util.Scanner;

public class GradeCalculator {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

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

int score = scanner.nextInt();

scanner.close();

char grade;

if (score >= 100 && score <= 70) {

grade = 'A';

} else if (score >= 69 && score <= 65) {

grade = 'B';

} else if (score >= 64 && score <= 55) {

grade = 'C';
} else if (score >= 54 && score <= 50) {

grade = 'D';

} else if (score >= 49 && score <= 45) {

grade = 'E';

} else {

grade = 'F';

System.out.println("Student's grade: " + grade);

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