AssignGrades - score = gradeScanner.nextInt(); s if (score...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// File: AssignGrades.java // Course: CSC 211 // Author: Amber Settle // Purpose: Demonstrate nested if-else branching / import java.util.Scanner; i public class AssignGrades { // Take a numerical score as input, and convert it to a grade // For this program (and this program only!), 90+ is A, 80-89 is B, // 70-79 is C, 69- is F / public static void main(String[] args) { char grade; double score; d Scanner gradeScanner = new Scanner(System.in); S System.out.print("What was your numerical score? ");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: score = gradeScanner.nextInt(); s if (score >= 80) // 80+ . .. Grade is A or B // Braces are not necessary, but help with clarity { if (score >= 90) grade = 'A'; else // grade is between 80 and 89 grade = 'B'; } else // 79- . .. grade is C or F { if (score >= 70) grade = 'C'; else // grade is less than 70 grade = 'F'; } System.out.println("Your letter grade is " + grade + "."); } }...
View Full Document

Ask a homework question - tutors are online