View Single Post
Old 09-24-2006, 04:42 PM   #1 (permalink)
mziel
Registered User
 
Join Date: Sep 2006
Posts: 2
mziel is on a distinguished road
Exclamation new to java.. code question

hey guys.. i'm new to java (college course).. and i'm currently writing a grading program for a class.
basically all you do is input 3 quiz grades, two midterm grades, and one final grade. It's weighted.. 25% for quizzes, 35% for midterms, and 40% for the final.
i have the code written out completely but it's coming up with some errors. if i input all perfect scores (three 10's, two 100's, and one 100), the result is "1.0, A". Fair enough.. but if I put in anything else, it comes up with something like ".54, Fail", or another number (depending on what i put in). two questions... how might I convert the decimals (1.0 for example) into the actually percentage? (i.e. 1.0 would be 100)? Also, how might I actually get it to work correctly??
any tips?? i'm not looking for someone to write it for me correctly... just some guidance..
Here's my code:
Code:
import java.util.Scanner;

public class Proj1 
{
	public static void main(String[] args)
	{
	Scanner keyboard = new Scanner(System.in);
	
	System.out.println("Enter three quiz grades: ");
	int quizGrade1 = keyboard.nextInt();
	int quizGrade2 = keyboard.nextInt();
	int quizGrade3 = keyboard.nextInt();
	
	double totalQuizGrade = (quizGrade1 + quizGrade2 + quizGrade3);
	totalQuizGrade = totalQuizGrade / 30;
	totalQuizGrade = totalQuizGrade * .25;
	
	System.out.println("Enter two midterm grades: ");
	int midtermGrade1 = keyboard.nextInt();
	int midtermGrade2 = keyboard.nextInt();
	
	double totalMidtermGrade = (midtermGrade1 + midtermGrade2);
	totalMidtermGrade = totalMidtermGrade / 200;
	totalMidtermGrade = totalMidtermGrade * .35;
	
	System.out.println("Enter final exam grade: ");
	int finalExam = keyboard.nextInt();
	double totalFinalCalc = finalExam / 100;
	totalFinalCalc = totalFinalCalc * .40;
	
	double totalGrade = (totalQuizGrade + totalMidtermGrade + totalFinalCalc);
	int totalGrade1 = (int)totalGrade / 10;
	switch(totalGrade1)
	{
	case 10: case 9:
		System.out.println(totalGrade + ", A");
		break;
	case 8:
		System.out.println(totalGrade + ", B");
		break;
	case 7:
		System.out.println(totalGrade + ", C");
		break;
	case 6:
		System.out.println(totalGrade + ", C");
		break;
		default:
			System.out.println(totalGrade + ", Fail");
		break;
		
	}
	}
}



_____________thanks for any help!!
mziel

Last edited by Belisarius; 09-24-2006 at 05:29 PM. Reason: Inserted code tags
mziel is offline   Reply With Quote