Untitled

mail@pastecode.io avatar
unknown
c_cpp
a year ago
8.0 kB
1
Indexable
Never
#include <iostream>
#include <string>
using namespace std;
int GetGrades();
int FindAverage(int, int);
void studentinfo();
void start();




int main() {
 studentinfo();
 
 bool running = true;
 char choice;
 
 do{
    double averageGrade = GetGrades();

 if (averageGrade >= 90 && averageGrade <= 100)
 cout << "Your average is: " << averageGrade << " Your Letter Grade is A. " << endl;
 else if (averageGrade >= 80 && averageGrade < 90)
 cout << "Your average is: " << averageGrade << " Your Letter Grade is B. " << endl;
 else if (averageGrade >= 70 && averageGrade < 80)
 cout << "Your average is: " << averageGrade << " Your Letter Grade is C. " << endl;
 else if (averageGrade >= 60 && averageGrade < 70)
 cout << "Your average is: " << averageGrade << " Your Letter Grade is D. " << endl;
 else if (averageGrade >= 0 && averageGrade < 60)
 cout << "Your average is: " << averageGrade << " Your Letter Grade is FAILED. " << endl;
 else
 cout << "Invalid Entry" << endl;
 
 cout << "Continue? y/n : ";
 cin >> choice;
 
 if(choice == 'Y' || choice == 'y'){
     continue;
 }else if(choice == 'N' || choice == 'n'){
     running = false;
 }
 }while(running);
 
 return 0;
}




void studentinfo() {
 string FN, LN, gender, studentN, fullname;
 bool running = true;
 double currentyear = 2023;
 double ydate, age;
 cout << "================" << endl;
 cout << "WELCOME TAMARAWS" << endl;
 cout << "================" << endl;
 cout << "Input First name: ";
 getline(cin, FN);
 cout << "Input Last name: ";
 cin >> LN;
 
 while(running){
 cout << "Input Student Number: ";
 cin >> studentN;
 
     if(studentN.size() != 9){
         cout << "Please Enter the Correct Student Number!! (e.g 202110139)\n";
         continue;
     }
     else{
         break;
     }
 }
 

 while(running){
 cout << "Input Gender [MALE] [FEMALE]: ";
 cin >> gender;
 
    if(gender == "male" || gender == "MALE" || gender == "m" || gender == "M" || gender == "lalake" || gender == "LALAKE" || gender == "female" || gender == "FEMALE" || gender == "f" || gender == "F" || gender == "babae" || gender == "BABAE"){
        break;

        
    }
    else{
        cout << "Please Enter Correct Input. \n";
        continue;
    }
 }
 
 
 cout << "Input Birth Year: ";
 cin >> ydate;
 fullname = FN + " " + LN;
 age = currentyear - ydate;
 cout << "\nHello! " << fullname << "\tGender: " << gender << "\t" << studentN << "\tAge: " << age;
 cout << "\n\n" << endl;
}
int GetGrades() {
 int numberofgrades;
 int grade = 0;
 int totalgrades = 0;
 int qaverageMid = 0;
 int haverageMid = 0;
 int maverageMid = 0;
 float averageMid = 0;
 
 int qaverageFinal = 0;
 int haverageFinal = 0;
 int maverageFinal = 0;

 float averageFinal = 0; 
 float finalGrade = 0;
 char options;

 start();

 cout << "Select Option [1 for Quizzes, 2 for Homework]: ";
 cin >> options;
 switch (options) {
     
 case 'q':
 case '1':
 cout << "M I D T E R M\n\n";
 cout << "How many Quizzes would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a Quiz grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 qaverageMid = totalgrades / numberofgrades;
 totalgrades = 0;
 
 cout << "How many Homework grades would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a Homework grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 haverageMid = totalgrades / numberofgrades;
 totalgrades = 0;
 
 cout << "How many Midterm exam would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a MIDTERM grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 maverageMid = totalgrades / numberofgrades;
 
 averageMid = ((qaverageMid + maverageMid + haverageMid) /3) * 0.4;
 totalgrades = 0;
 
  cout << "F I N A L S \n\n"; 
  
 cout << "How many Quizzes would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a Quiz grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 qaverageFinal = totalgrades / numberofgrades;
 totalgrades = 0;

 cout << "How many Homework grades would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a Homework grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 haverageFinal= totalgrades / numberofgrades;
 totalgrades = 0;

 
 
 cout << "How many Final exam would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a FINAL grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 maverageFinal = totalgrades / numberofgrades;
 
 averageFinal = ((qaverageFinal + maverageFinal + haverageFinal) /3) * 0.6;
 
 totalgrades = 0;
 
 finalGrade = averageMid + averageFinal;
 
 cout << "=-=-=-=-=-=-=-=-=-=\n";
 cout << "TOTAL MIDTERM = " <<  (qaverageMid + maverageMid + haverageMid) / 3 << endl;
 cout << "(40%) = " << averageMid << endl << endl;
 cout << "TOTAL FINALS = " << (qaverageFinal + maverageFinal + haverageFinal) / 3 << endl;
 cout << "(60%) = " << averageFinal << endl << endl;
 cout << "=-=-=-=-=-=-=-=-=-=\n";


 return finalGrade;

 
 case 'h':
 case '2':
 
 cout << "MIDTERM\n";
 cout << "How many Homework grades would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a Homework grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 haverageMid = totalgrades / numberofgrades;
 totalgrades = 0;
 
 
 cout << "How many Quizzes would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a Quiz grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 qaverageMid = totalgrades / numberofgrades;
 totalgrades = 0;

 cout << "How many Midterm grades would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a MIDTERM grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 maverageMid = totalgrades / numberofgrades;
 averageMid = ((qaverageMid + maverageMid + haverageMid) /3)* 0.4;
 totalgrades = 0;

 cout << "F I N A L S \n\n"; 
  
 cout << "How many Homework grades would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a Homework grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 haverageFinal= totalgrades / numberofgrades;
 totalgrades = 0;
 
 cout << "How many Quizzes would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a Quiz grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 qaverageFinal = totalgrades / numberofgrades;
 totalgrades = 0;

 
 
 cout << "How many Final exam would you like to input? ";
 cin >> numberofgrades;

 for (int i = 1; i <= numberofgrades; i++) {
 cout << "Please enter a FINAL grade: ";
 cin >> grade;
 totalgrades += grade;
 }
 maverageFinal = totalgrades / numberofgrades;
 
 averageFinal = ((qaverageFinal + maverageFinal + haverageFinal) /3) * 0.6;
 
 totalgrades = 0;
 
 finalGrade = averageMid + averageFinal;

 cout << "=-=-=-=-=-=-=-=-=-=\n";
 cout << "TOTAL MIDTERM = " <<  (qaverageMid + maverageMid + haverageMid) / 3 << endl;
 cout << "(40%) = " << averageMid << endl << endl;
 cout << "TOTAL FINALS = " << (qaverageFinal + maverageFinal + haverageFinal) / 3 << endl;
 cout << "(60%) = " << averageFinal << endl << endl;
 cout << "=-=-=-=-=-=-=-=-=-=\n";

return finalGrade;

 
 
 default:
 cout << "Invalid Input. Try Again." << endl;
 return 0;
 
 }
}

int FindAverage(int total, int number) {
 return (total) / number;
}
void start() {
 cout << "********************************************************" << endl;
 cout << "Welcome to FEU GRADING SYSTEM" << endl;
 cout << "Grade = HOMEWORK [10%] + QUIZZES [40%] + MAJOR EXAM [50%]" << endl;
 cout << "********************************************************" << endl;
 cout << "\n\n" << endl;
}