Skip to content

Commit

Permalink
Added GPAcalculator.cpp program file, the .exe file, and README.md fi…
Browse files Browse the repository at this point in the history
…le about me and this program.
  • Loading branch information
matyod committed Sep 4, 2023
1 parent c2d5294 commit 0d90538
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Hacktoberfest-2021/FirdausRazali/GPAcalculator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main(){
float totalCredHrs = 0, finalCredHrs;
string arrSubject[10] = {"Bahasa Melayu","Bahasa Inggeris","Sejarah","Matematik Moden","Matematik Tambahan","Fizik","Kimia","Pend. Islam / Pend. Moral","Biologi / Prinsip Akaun","Pendidikan Jasmani"};
int arrCredHrs[10] = {5, 5, 3, 4, 5, 5, 4, 4, 4, 2};
string userGrade[10];
float userPointer[10];

cout << "Enter the grade for each subject (e.g. A+, or A, or A-, etc.)\n\n";

for (int i = 0; i < 10; i++){
cout << arrSubject[i] << ": ";
cin >> userGrade[i];
}

for (int i = 0; i < 10; i++){
if (userGrade[i] == "A+"){
userPointer[i] = 4.00;
} else if (userGrade[i] == "A"){
userPointer[i] = 4.00;
} else if (userGrade[i] == "A-"){
userPointer[i] = 3.75;
} else if (userGrade[i] == "B+"){
userPointer[i] = 3.50;
} else if (userGrade[i] == "B"){
userPointer[i] = 3.25;
} else if (userGrade[i] == "B-"){
userPointer[i] = 3.00;
} else if (userGrade[i] == "C+"){
userPointer[i] = 2.75;
} else if (userGrade[i] == "C"){
userPointer[i] = 2.50;
} else if (userGrade[i] == "C-"){
userPointer[i] = 2.25;
} else if (userGrade[i] == "D"){
userPointer[i] = 2.00;
} else if (userGrade[i] == "E"){
userPointer[i] = 1.00;
} else if (userGrade[i] == "F"){
userPointer[i] = 0.00;
}
}

for (int i = 0; i < 10; i++){
totalCredHrs += userPointer[i] * arrCredHrs[i];
}

finalCredHrs = totalCredHrs / 41;
cout << "\nGPA: " << fixed << setprecision(2) << finalCredHrs;

return 0;
}
Binary file not shown.
34 changes: 34 additions & 0 deletions Hacktoberfest-2021/FirdausRazali/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# About Me
**Name:** Muhamad Firdaus Bin Mohd Razali
**Github username:** ausrazali

**How many pull requests have you done here:** 1

**LinekdIn profile url:** [Connect with me](https://www.linkedin.com/in/muhamadfirdausmohdrazali/)
**Twitter profile url:** N/A

**Country:** Malaysia

**Bio:** Pursuing a Bachelor of Information Technology (Hons) in Software Engineering. Baby steps learning everything I need to know to land a software engineer job as soon as I graduate. Pray the best for me! Love to contribute to open source project, and start my OSP too. Soon.I highly value guidance and believe in continuous learning and professional growth, and I am eager to collaborate and explore new opportunities with like-minded professionals.
- Follow me [GitHub](https://github.com/ausrazali)
<hr>

# About Program
**Program:** GPA Calculator
**Filename:** GPAcalculator.cpp

This C++ program calculates the Grade Point Average (GPA) based on the user's input of grades and corresponding credit hours for ten subjects. It uses a standard grading scale to assign grade points to letter grades and calculates the weighted GPA. The grading scale is based on Malaysia's MARA Junior Science College *(malay: Maktab Rendah Sains MARA)* grading scale for upper-form (Form 4 & Form 5).

Program Components:
- **arrSubject:** An array that stores the names of the ten subjects.
- **arrCredHrs:** An array that stores the credit hours for each subject respectively.
- **userGrade:** An array to store the user's input for letter grades.
- **userPointer:** An array to store the calculated grade points based on the user's input.

- **Grading Scale:** The program uses a standard grading scale to assign grade points to letter grades. The grading scale includes grades from "A+" to "F" and assigns the corresponding grade points.

- **User Input:** The user is prompted to input their grades for each subject, following the grading scale. The program then calculates the corresponding grade points for each grade input.

- **GPA Calculation:** The program calculates the GPA by multiplying each subject's grade points by its credit hours, summing these values, and dividing by the total credit hours (41 in this case). The result is formatted with two decimal places using setprecision from the <iomanip> library.

- **Output:** The program displays the calculated GPA as the final output.

0 comments on commit 0d90538

Please sign in to comment.