# GPA CALCULATOR

Page 1 of 1

## 3 Replies - 4317 Views - Last Post: 07 May 2008 - 05:43 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=51259&amp;s=1af10bb1a79aae66cc695a9f2af27c04&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 p0oper89

Reputation: 0
• Posts: 3
• Joined: 06-May 08

# GPA CALCULATOR

Posted 06 May 2008 - 05:14 PM

This program will allow you to calculate your GPA for one semester. After receiving an explanation of the program and entering the semester, the student will be allowed to enter as many courses as he/she sees fit. The program must then calculate and display the GPA earned for that semester.

In order to produce the GPA, several calculations are needed. For each course, the number of credits, multiplied by the grade point earned in that class, results in a value known as quality points. To calculate the GPA, the total number of quality points for the semester is divided by the total number of credits taken that semester, exclusive of credits for courses taken with the Pass/Fail grading method. Your program should NOT handle Pass/Fail courses at all. The only acceptable grade points are in the range of 0 through 4, where 4 is an A, 3 a B, 2 a C, 1 a D and 0 an F. So, for example, if you took one 4 credit course and received a B, your GPA for that semester would be:

4 credits * 3 points = 12 quality points
12 total quality points / 4 total credits = 3.000 GPA

If there is more than one course, you just keep adding the quality points to the total points and credits to the total credits.

To begin the program , you should print a message to the user explaining what the program does. Then you should ask the user to enter the semester. After these initial steps, you should begin asking the user to enter the number of credits and grade points for each course, one course at a time. The user should enter a -1 as the number of credits to end the input phase. So -1 is the sentinel value for this exercise. At this point a report should be generated that shows the total number of credits taken, the total quality points earned, and the GPA for the semester.

Your program must generate all of the same information as shown in the sample output. You do not need to match the output exactly, however the GPA should be shown to three decimal places. You may also use the data shown here to test your program for accuracy.

More Requirments and details:
* You are REQUIRED to use the following functions exactly as they are given:
o function PrintExplanation(){} - This function should display a description of the program to the user. It should let the user know the specific points values for each of the letter grades. You should print the explanation using an alert(). The function should not return anything.
o function GetValidInput(promptString, sentinel){} - This function takes two arguments: the string that contains the prompt you want to print and the sentinel, which is -1 in this program. You should ask the user for the number and then error check to make sure the number is either greater than 0 or equal to -1. As long as the number the user enters is less than or equal to 0 and not equal to the sentinel, it should continue to prompt for a new number. The function should return the valid number. The function should be general and not mention anything about credits.
o function GenerateGradeReport(semester, totalCredits, totalPoints){} - This function should display the grade report to the user. You should use document.write() to produce the report. You will make a call to the function CalculateGPA() from within this function. The function should not return anything.
o function CalculateGPA(totalCredits, totalPoints){} - This function simply performs the GPA calcuation. It should return the calculated GPA.
* You should use the GetValidInput() function to get the number of credits from the user.
* You do not have to error check the points. You can assume the user will only type 4, 3, 2, 1 or 0.
* Feel free to add any style you would like to the GPA Report.

Is This A Good Question/Topic? 0

## Replies To: GPA CALCULATOR

### #2 pbl

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

Reputation: 8379
• Posts: 31,956
• Joined: 06-March 08

## Re: GPA CALCULATOR

Posted 06 May 2008 - 06:02 PM

[rules][/rules]

### #3 rgfirefly24

• D.I.C Lover

Reputation: 449
• Posts: 2,186
• Joined: 07-April 08

## Re: GPA CALCULATOR

Posted 07 May 2008 - 12:24 PM

mate, i dont know why you think you can tell one of our members to go F himself then repost this exact same thing in a different forum. You need to either find a different site or follow the rules. Your behavior also better change REAL fast.

and incase you've forgotten i'm refering to this:

http://www.dreaminco...wtopic51260.htm

This post has been edited by rgfirefly24: 07 May 2008 - 12:24 PM

### #4 herefishyfishy

Reputation: 7
• Posts: 60
• Joined: 01-May 08

## Re: GPA CALCULATOR

Posted 07 May 2008 - 05:43 PM

First of all, I think the post window specifically has a watermark that says "We Will Not Do Your Homework!"
Second, "Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well."
Third, PsychoCoder could easily code this program in his sleep!

Don't just copy your homework assignment verbatim into a post and expect us to answer.