Creating a GPA Calculator on Your Own

In summary: You will also need to prompt for the grade (A, B, C, D, F) and convert that to a number (4, 3, 2, 1, 0).In summary, to create a GPA calculator, you will need to prompt for the number of classes, then use a loop to prompt for the grade and credits for each class, and calculate the running totals. Finally, you will need to divide the total points by the total credits to get the GPA.
  • #1
TheDoorsOfMe
46
0

Homework Statement



I want to create a gpa calculator. This isn't for school I am just trying to learn some programming on my own and came up with this project.

I want the output to be something like this:

how many classes have you taken?

grade for class 1:
number of credits for class 1:

and so on...

What do I need to do to make the number of classses entered come up?

Homework Equations





The Attempt at a Solution



#include <stdio.h>
#include <stdlib.h>
#define a 4
#define b 3
#define c 2
#define d 1
#define f 0


int main(void)
{
int classes;
int credits;


printf("How Many Classes did you take? ");
scanf("%d", &classes);

printf("How Many credits was class 1: ");
scanf("%d", &credits);

return 0;
}
 
Physics news on Phys.org
  • #2
the is in C if that helps!
 
  • #3
Something like this.

int ii,total=0;
for(ii=1;ii<=classes;++ii){
printf("How many credits was class %d? ",ii);
scanf("%d",&credits);
total=total+credits;
}
 
  • #4
thank you very much!
 
  • #5
TheDoorsOfMe said:

Homework Statement



I want to create a gpa calculator. This isn't for school I am just trying to learn some programming on my own and came up with this project.

I want the output to be something like this:

how many classes have you taken?

grade for class 1:
number of credits for class 1:

and so on...

What do I need to do to make the number of classses entered come up?

Homework Equations





The Attempt at a Solution


Code:
#include <stdio.h>
#include <stdlib.h>
#define a 4
#define b 3
#define c 2
#define d 1
#define f 0


int main(void)
{
    int classes;
    int credits;


    printf("How Many Classes did you take? ");
    scanf("%d", &classes);

    printf("How Many credits was class 1: ");
    scanf("%d", &credits);

    return 0;
}
Your code above (that I formatted with code tags) looks like it would compile just fine, but wouldn't do anything useful. Your code prompts for the number of classes, and then sets you classes variable with the number you enter. The code then prompts for the number of credits of class 1, and then sets the credits variable for that class.

The code doesn't prompt for the grade for class 1 (or any other classes), and doesn't do any further calculations. The last thing it does is return 0.

What the code should do is this: for each class, multiply the number of credits by the grade, and keep a running total of these values. When you have cycled through all of the classes, divide by the number of credits to get the GPA.

For example, if your classes were 5 credits, 4 credits, and 5 credits, and the respective grades were B, A, and B, you program should have a total points value of 15, then 15 + 16 = 31, then 31 + 14 = 45.

The total number of credits is 14, so the GPA would be 45/14 = 3.214286 (approx.). Since the GPA is a decimal number, you should use either float or double to store this value.

Since there are (potentially) multiple classes, you will need to use a loop of some kind to input the information and calculate the running totals for each class.
 
Last edited:

Related to Creating a GPA Calculator on Your Own

1. How do I calculate my GPA?

To calculate your GPA, you must first convert your letter grades to their numerical equivalents (A = 4.0, B = 3.0, C = 2.0, D = 1.0, F = 0.0). Then, multiply each grade by the number of credit hours for that course. Add all of these numbers together and divide by the total number of credit hours. The resulting number is your GPA.

2. Can I use a GPA calculator for both semester and cumulative GPA?

Yes, you can use a GPA calculator for both semester and cumulative GPA. Simply enter the grades and credit hours for each semester separately and calculate the GPA for each. Then, add all of the credit hours and total grade points together and divide by the total number of credit hours to get your cumulative GPA.

3. What about courses with a plus or minus grade?

For courses with a plus or minus grade, you will need to convert them to their numerical equivalents (e.g. A- = 3.7, B+ = 3.3) and use those numbers in your calculation. Some GPA calculators may have the option to input plus/minus grades directly, so be sure to check the calculator's instructions.

4. Is there a GPA cutoff for academic probation or honors?

The GPA cutoff for academic probation or honors varies by institution. It is important to check with your school's academic policies to determine the specific requirements for these designations.

5. Can I use a GPA calculator to predict my GPA for future semesters?

While a GPA calculator can provide an estimate for future semesters, it is important to keep in mind that your actual GPA may differ due to various factors such as course difficulty, workload, and personal circumstances. It is best to use the calculator as a guide and not a guarantee of your future GPA.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
3
Views
709
  • Engineering and Comp Sci Homework Help
Replies
17
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
929
  • Engineering and Comp Sci Homework Help
Replies
19
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
984
  • Engineering and Comp Sci Homework Help
Replies
12
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
787
  • Engineering and Comp Sci Homework Help
Replies
9
Views
2K
Back
Top