java programming

The following script will convert number grades to letter grades using java. Just copy and paste the below script into your preferred IDE (Integrated Development Environment) and run it.

 

/*
	Programmer: Your Name
	Date:       June 9, 2018
	File Name:  GradeConverter.java
	Purpose:    To create an app that gets numeric grade input from the user,
                    converts numeric grade to letter grade, and displays 
                    conversion as output.
*/

//packages to import
import java.util.Scanner;

public class GradeConverter //class declaration
{
	public static void main(String args[])//this is main method header
	{
	//welcome the user
	System.out.println("Welcome to the Letter Grade Conversion Project");
	System.out.println(); //print a blank line

	//construct a scanner object
	Scanner sc = new Scanner(System.in);

	//perform conversions until choice is value other than "y" or "Y"
	String choice = "y";
	while (choice.equalsIgnoreCase("y"))
	{
	//get input from the user
	System.out.print("Enter Numeric Grade:\t\t");
	double score = sc.nextDouble();

	//convert user numeric grade into letter grade
	char userGrade = 'F';
	if(score >= 88)
	userGrade = 'A';
	else if(score >= 80)
	userGrade = 'B';
	else if (score >= 67)
	userGrade = 'C';
	else if (score >= 60)
	userGrade = 'D';

	// display conversion result
	String message = "Equivalent Letter Grade:\t" + userGrade;
	System.out.println(message);

	//see if user wants to continue
	System.out.print("\nContinue? (y/n):\t\t");
	choice = sc.next();
	System.out.println();
	}//end while loop
	}//end main()
} //end class GradeConverter