diff --git a/Hacktoberfest-2021/FirdausRazali/GPAcalculator.cpp b/Hacktoberfest-2021/FirdausRazali/GPAcalculator.cpp new file mode 100644 index 0000000..b2d663d --- /dev/null +++ b/Hacktoberfest-2021/FirdausRazali/GPAcalculator.cpp @@ -0,0 +1,56 @@ +#include +#include +#include +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; +} \ No newline at end of file diff --git a/Hacktoberfest-2021/FirdausRazali/GPAcalculator.exe b/Hacktoberfest-2021/FirdausRazali/GPAcalculator.exe new file mode 100644 index 0000000..7bc30eb Binary files /dev/null and b/Hacktoberfest-2021/FirdausRazali/GPAcalculator.exe differ diff --git a/Hacktoberfest-2021/FirdausRazali/README.md b/Hacktoberfest-2021/FirdausRazali/README.md new file mode 100644 index 0000000..3e57d46 --- /dev/null +++ b/Hacktoberfest-2021/FirdausRazali/README.md @@ -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) +
+ +# 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 library. + +- **Output:** The program displays the calculated GPA as the final output. \ No newline at end of file