I'm taking AP comp sci and I'm new to JAVA. Can someone help me write this program?

Assignment:

1.

Write a program that accepts the letter grades for a student, calculates the student's GPA, and prints it out along with one of the following five messages:

Eligible
Ineligible, taking less than 4 classes.
Ineligible, gpa below 2.0
Ineligible, gpa above 2.0 but has F grade (note: gpa >= 2.0)
Ineligible, gpa below 2.0 and has F grade

2.

Your program must use an appropriate sequence of nested if-else statements to print out the appropriate message.
3.

The message "Ineligible, taking less than 4 classes" has priority over the other 3 ineligible cases.
4.

The program is not to ask the user for how many grades are in a student's report card. The program will continue to read grades until a non-grade character is input. At this point, some type of loop will cease and the program prints the GPA value and the eligibility message.
5.

Example of run output:

GPA = 3.75 Eligible

6.

You do not have to print out any of the individual grades.
7.

Your program should allow input of grades in either upper or lower case.

Thank you!!

Recommended Answers

All 6 Replies

You didnt write the comparison of grades vs the gpa ... how would I know the gpa if my grade is A?? A means 4? B means 3 or above ? or something else????

We dont do your hw for you here. what dont you understand about it? be more specific of your problem.

can you please let us know what exactly you are having problems on thanks

We dont do your hw for you here. what dont you understand about it? be more specific of your problem.

Yes. Please ask specific questions that you're having with YOUR code. We're not here to help you essentially cheat.

I dont understand the basic structure of the program. Where does everything go? Things like that.

A=4
B=3
C=2
D=1
F=0

I'm not trying to cheat, I just need some help. Thanks. :o

This isnt exactly what your looking for but it should give you an idea of how it kind of works. I hope this helps a little...

import java.io.*;

class Grade 
{
	public static void main(String[] args) throws IOException 
	{
	  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	  String inData;
	  double grade = 0;
	  double count = 0;
	  
	  do
	  {
	    
	    System.out.println("Enter the letter grade");
	    inData = br.readLine();
	     if (inData.equals("a"))
	     {
	       grade = grade + 4.0;
	     } 
	     else if (inData.equals("b"))
	     {
		grade = grade + 3.0;
	     }
	     else if (inData.equals("c"))
	     {
	   	grade = grade + 2;
	     }
	    else if (inData.equals("d"))
	    {
		grade = grade + 1;
	    }
	   else if (inData.equals("f"))
	   {
		grade = grade + 0;
	   }
	   count++;
	  
	}
	

	while  (!inData.equals(""));

	System.out.println("GPA = " + (grade / (count - 1)));
	
        }
}
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.