my problem is i cant get the overall numeric score and the grade letter

import java.io.*;
import java.util.Scanner;


public class GradePrg  {   
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
int quiz1, quiz2, quiz3;    
float tMidTerm, tFinal, tQuiz;   
int midTermExam = 0;   
int finalExam = 0;   
float finalScore= 0;   
String name;   
char grade;   

            //Method: get Student Name   
            public void getName()    
            {         
            System.out.println("Students calculated final scores");   
            System.out.println("and letter grades. ");   
                        System.out.println("Please enter your name. ");   
     Scanner in = new Scanner(System.in);

              name = in.nextLine();   
            }   

        //Method: get grades   
            public void getGrades()  throws Exception
             {   
            System.out.println("Please enter your first quiz number :");   
    Scanner in = new Scanner(System.in);
            quiz1 = in.nextInt();   
            System.out.println("Please enter your second quiz number. ");   
            quiz2 = in.nextInt();   
            System.out.println("Please enter your third quiz number. ");
            quiz3 = in.nextInt();
             System.out.println("Please enter your mid term exam number ");   
            midTermExam = in.nextInt();   
    System.out.println("Please enter your Final exam number ");   
            finalExam= in.nextInt();   



            }     

          //Method: Calculate Score   
          public void getScore()   
            {   
         tQuiz = (((quiz1 + quiz2 + quiz3)/30)* 25); 
          tMidTerm = ((midTermExam/100)*25);   
          tFinal = ((finalExam/100)*50);
          } 
          public void getFinalScore()
          {

         finalScore = tQuiz + tMidTerm + tFinal;


       }   

//Method: get letter grade   
public void getLetterGrade(){   
if (finalScore >= 90)   
{   
grade = 'A';   
}   
if (finalScore >= 80)   
{   
grade = 'B';   
}   
if (finalScore >= 70)   
{   
grade = 'C';   
}   
if (finalScore >= 60)   
{   
grade = 'D';   
}   

System.out.println( "Student name: " + name );      
System.out.println( "First quiz score: " + quiz1 );       
System.out.println( "Second quiz score: " + quiz2 ); 
System.out.println( "Third quiz score: " + quiz3 );      
System.out.println( "Midterm Exam score: " + midTermExam );        
System.out.println( "Final Exam score: " + finalExam );   
System.out.println( "Your final grade is: " + grade ); 


}




}


import java.io.*;


public class GradePrgTester
{
    public static void main(String args[]) throws Exception
    {

        GradePrg quiz =new GradePrg();
        quiz.getName();
        quiz.getGrades();
        quiz.getScore();
        quiz.getLetterGrade();


    }    


}

Recommended Answers

All 6 Replies

1) Please use the code tags - select your code and click the (CODE) button above the text entry box
2) Please expand a little on what problem you're trying to solve. What happens when you run the program, and how does it differ from what you're trying to do?

import java.io.*;
	import java.util.Scanner;


	public class GradePrg  {   
	BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
	int quiz1, quiz2, quiz3;    
	float tMidTerm, tFinal, tQuiz;   
	int midTermExam = 0;   
	int finalExam = 0;   
	float finalScore= 0;   
	String name;   
	char grade;   
	  
	            //Method: get Student Name   
	            public void getName()    
	            {         
	            System.out.println("Students calculated final scores");   
	            System.out.println("and letter grades. ");   
            	            System.out.println("Please enter your name. ");   
		 Scanner in = new Scanner(System.in);

	              name = in.nextLine();   
              	}   
	  
	        //Method: get grades   
              	public void getGrades()  throws Exception
	             {   
	            System.out.println("Please enter your first quiz number :");   
		Scanner in = new Scanner(System.in);
	            quiz1 = in.nextInt();   
	            System.out.println("Please enter your second quiz number. ");   
	            quiz2 = in.nextInt();   
	            System.out.println("Please enter your third quiz number. ");
	            quiz3 = in.nextInt();
	             System.out.println("Please enter your mid term exam number ");   
	            midTermExam = in.nextInt();   
		System.out.println("Please enter your Final exam number ");   
	            finalExam= in.nextInt();   
	            
	          
	               
	            }     
	       
	          //Method: Calculate Score   
	          public void getScore()   
	            {   
	         tQuiz = (((quiz1 + quiz2 + quiz3)/30)* 25); 
	          tMidTerm = ((midTermExam/100)*25);   
	          tFinal = ((finalExam/100)*50);
	          
	          
	         finalScore = tQuiz + tMidTerm + tFinal;
			 getLetterGrade();         
               }    
	  
	//Method: get letter grade   
	public void getLetterGrade(){   
	if (finalScore >= 90)   
	{   
	grade = 'A';   
	}   
	if (finalScore >= 80)   
	{   
	grade = 'B';   
	}   
	if (finalScore >= 70)   
	{   
	grade = 'C';   
	}   
	if (finalScore >= 60)   
	{   
	grade = 'D';   
	}   
	  
	System.out.println( "Student name: " + name );      
	System.out.println( "First quiz score: " + quiz1 );       
	System.out.println( "Second quiz score: " + quiz2 ); 
	System.out.println( "Third quiz score: " + quiz3 );      
	System.out.println( "Midterm Exam score: " + midTermExam );        
	System.out.println( "Final Exam score: " + finalExam );   
	System.out.println( "Your final grade is: " + grade ); 
	 
	
	}
	
}
import java.io.*;


public class GradePrgTester
{
	public static void main(String args[]) throws Exception
	{
		
	    GradePrg quiz =new GradePrg();
	    quiz.getName();
	    quiz.getGrades();
	    quiz.getScore();
	    
	     
	   
	}    
	
	
}

i was trying to get the overall numeric score for the entire course and final letter grade

but everytime i run the output letter will always D even if its a lower or higher number

Look at the your getLetterGrade method. Suppose finalscore is 86 - what happens?

Don't tell me what you mean to happen, walk through the code of the method and tell me what does happen.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.