Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by James McKee ( 14 years ago )
/*
James McKee
CSCD 210 Grade Scale Program.
*/
import java.util.Scanner;
public class grade
{
public static void main(String[] args)
{
int choice = 0;
double finalPercent = 30.0;
double examsPercent = 20.0;
double quizesPercent = 10.0;
double assignPercent = 40.0;
double finalPoints = 0;
double examsPoints = 0;
double quizesPoints = 0;
double assignPoints = 0;
double finalExam = 0;
double exams = 0;
double quizes = 0;
double assign = 0;
double finalGradePercentage = 0;
Scanner kb = new Scanner(System.in);
do
{
choice = menu(kb);
if(choice ==1)
{
System.out.print("\nEnter the following using positive Integers only:\n\tTOTAL Final Exam Points Possible: ");
finalPoints = kb.nextDouble();
System.out.print("\tTOTAL Exam Points Possible: ");
examsPoints = kb.nextDouble();
System.out.print("\tTOTAL Quiz(es) Points Possible: ");
quizesPoints = kb.nextDouble();
System.out.print("\tTOTAL Assignment Points Possible: : ");
assignPoints = kb.nextDouble();
}
else if(choice ==2)
{
System.out.print("\n\nNow lets enter your scores using positive Integers only:\n" );
System.out.print("\tEnter Your Final Exam Score: ");
finalExam = kb.nextDouble();
System.out.print("\tEnter Your Total Exams Score: ");
exams = kb.nextDouble();
System.out.print("\tEnter Your Total Quizes Score: ");
quizes = kb.nextDouble();
System.out.print("\tEnter Your Total Assignments Score: ");
assign = kb.nextDouble();
}
else if(choice == 3)
{
finalGradePercentage = ((((finalExam/finalPoints)*(finalPercent/100)) + ((exams/examsPoints)*(examsPercent/100)) + ((quizes/quizesPoints)*(quizesPercent/100)) + ((assign/assignPoints)*(assignPercent/100.0))) * 100);
printFinalGrade(finalGradePercentage);
}
}while (choice != 4);
System.out.println("Thank you and have a nice day");
}//end of main
public static int menu(Scanner kb)
{
int choice;
do
{
System.out.println("\nPlease select from the following menu choices.\n");
System.out.println("\t1. Enter Total Points For Your Class: ");
System.out.println("\t2. Enter Your Points For Your Class: ");
System.out.println("\t3. Show Your Grade");
System.out.println("\t4. Quit the program");
System.out.print("\nChoice --> ");
choice = kb.nextInt();
System.out.print("\n");
if(choice < 1 || choice > 4)
{
System.out.println("I am sorry that is an invalid menu choice.\nPlease try again");
}// end of if loop
}while(choice < 1 || choice > 4);
return choice;
}// end menu
public static void printFinalGrade(double finalGradePercentage)
{
double gpa = 0.0;
if(finalGradePercentage > 95.0)
gpa = 4.0;
else if(finalGradePercentage < 95.0 && finalGradePercentage > 61.0)
{
gpa = 4.0 -((95.0 - finalGradePercentage)*0.1);
}
else if(finalGradePercentage < 62.0 && finalGradePercentage > 59.0)
gpa = 0.7;
else
gpa = 0.0;
if(gpa > 2.5)
System.out.printf("\nYour final grade is %3.2f with a %3.2f percent, Congrants!",gpa,finalGradePercentage);
else
System.out.printf("\nYour final grade is %3.2f with a %3.2f percent, Better Luck Next Time!!",gpa,finalGradePercentage);
}//end of print final grade
}// end of class
Revise this Paste
Children: 48531