Assistance with java grading program(New to programming)

Need help rounding numbers, and solving errors with the compiler

Page 1 of 1

2 Replies - 7416 Views - Last Post: 20 September 2008 - 03:28 PM Rate Topic: -----

#1 revisionist00  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-September 08

Assistance with java grading program(New to programming)

Posted 14 September 2008 - 10:59 PM

I am attempting to create a grading program in java that will allow the user to input numberic as well as letter grades. The user must input if they would like to use number or letters. For the numberic grade I need to have the user input the grade in decimal format and then round the number to the next whole number. Once completed with that task I will need to associate the number with a letter grade. If the user chooses to input a letter grade I must associate their input with a switch statement that prints the range the letter grade corrisponds with.

My issue are I am not sure how the best way to round the numbers up, I have read articals on BigDecimal statement and the RoundingMode but I am unsure on how to implement it in my code.

Thank you in advance for any help!

Here is my code!:



 import java.util.*;
import java.math.*;

public class AbbeyChrisProg4_5
{
	public static void main (String[] args)
	{
	//Print out the welcome screen
	System.out.println("Welcome to Chris' Grading Program");

	Scanner stdIn = new Scanner (System.in);
	char choice;
	double numberGrade;
	char letterGrade;

	System.out.print("Will you be entering in numbers or letters? (Type N for numbers and L for letters.");
	choice = stdIn.nextLine().charAT(0);

while (choice == 'N')
		{
		System.out.println("Enter a number in the following format. (Ex. 75.22645)");
		numberGrade += stdln.nextLine ();
		public static RoundingMode valueOf(numberGrade);

			if (numberGrade >=90)
			finalLetterGrade ="A";
			else
			if ((numberGrade >=80) & (finalNumericGrade <90))
			finalLetterGrade ="B";
			else
			if ((numberGrade >=70) & (finalNumericGrade <80))
			finalLetterGrade ="C";
			else
			if ((numberGrade >=60) & (finalNumericGrade <70))
			finalLetterGrade ="D";
			else
			if ((numberGrade >=0) & (finalNumericGrade <60))
			finalLetterGrade ="F";

		System.out.println("\nHere is your letter grade:\n" + finalLetterGrade);
			}
while (choice == 'L')
		{
		System.out.println("Please enter your letter grade.");
		letterGrade += stdln.nextLine ();

		switch(letterGrade)
			{
			case A:
					System.out.println("90-100 = A");
					break;
			case B:
					System.out.println("80-89.9 = B");
					break;
			case C:
					System.out.println("70-79.9 = C");
					break;
			case D:
					System.out.println("60-69.9 = D");
					break;
			case F:
					System.out.println("0-59.9 = F");
					break;
			default:
					System.out.println("You have entered an incorrect grade.");
					break;
			}

		}
	}
}




Is This A Good Question/Topic? 0
  • +

Replies To: Assistance with java grading program(New to programming)

#2 revisionist00  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-September 08

Re: Assistance with java grading program(New to programming)

Posted 20 September 2008 - 02:32 PM

** Bump **
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8342
  • View blog
  • Posts: 31,880
  • Joined: 06-March 08

Re: Assistance with java grading program(New to programming)

Posted 20 September 2008 - 03:28 PM

The correct syntax for a switch on a char is

case 'A':

not

case A:
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1