Create a program that will input grade and will display the corresponding * equivalent. Use if statement in a program.
GRADE EQUIVALENT
A EXCELLENT
B VERY GOOD
C GOOD
D FAIR
E POOR
F NEEDS IMPROVEMENTS
OTHER LETTERS INVALID GRADE.
Sample Program Output
Enter a Grade : E
E IS YOUR GRADE AND YOU ARE POOR.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Program Listing
/* Letter_Grade.java
* Prof. Jake Rodriguez Pomperada, MAED-IT, MIT
* www.jakerpomperada.com and www.jakerpomperada.blogspot.com
* jakerpomperada@gmail.com
* Bacolod City, Negros Occidental Philippines.
*
*/
//packages to import
import java.util.Scanner;
class Letter_Grade
{
/*
* Machine Problem
*
* Create a program that will input grade and will display the corresponding
* equivalent. Use if statement in a program.
*
* GRADE EQUIVALENT
* A EXCELLENT
* B VERY GOOD
* C GOOD
* D FAIR
* E POOR
* F NEEDS IMPROVEMENTS
* OTHER LETTERS INVALID GRADE.
*
* Sample Program Output
*
* Enter a Grade : E
* E IS YOUR GRADE AND YOU ARE POOR.
*
*/
public static void main(String args[])
{
System.out.println("\tLetter Grade in Java");
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";
String letter_grade;
String remarks;
while (choice.equalsIgnoreCase("y"))
{
//get input from the user
System.out.print("\tEnter a Grade:\t");
letter_grade = sc.next();
//convert user letter grade into grade remarks
if (letter_grade.equalsIgnoreCase("a"))
remarks = "EXCELLENT";
else if (letter_grade.equalsIgnoreCase("b"))
remarks = "VERY GOOD";
else if (letter_grade.equalsIgnoreCase("c"))
remarks = "GOOD";
else if (letter_grade.equalsIgnoreCase("d"))
remarks = "FAIR";
else if (letter_grade.equalsIgnoreCase("e"))
remarks = "POOR";
else if (letter_grade.equalsIgnoreCase("f"))
remarks = "NEED IMPROVEMENTS";
else
remarks = "INVALID GRADE.";
String upper_case_grade =letter_grade.toUpperCase();
// display conversion result
System.out.println();
String message = "\t" + upper_case_grade + " IS YOUR GRADE AND YOU ARE " + remarks + ".";
System.out.println(message);
//see if user wants to continue
System.out.println();
System.out.print("\tContinue? (y/n):\t");
choice = sc.next();
System.out.println();
}//end while loop
System.out.println("\tEnd of Progam");
System.out.println();
}
} // End of Code
No comments:
Post a Comment