Sunday, March 19, 2017

Student Grade Solver Using Pointers in C++

A simple program that I wrote using C++ to compute the student grades using functions and pointers as my data structure. The code is very simple and easy to understand I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler in this sample program. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Program Listing


#include <iostream>
#include <iomanip>

 using namespace std;

float X_Prelim=0.00, X_Midterm=0.00, X_Endterm=0.00;

 float solve_grade(float *prelim,  float *midterm, float *endterm)
 {
     float compute_grade =0.00;
     bool  result;
     compute_grade = (*prelim * 0.30) + (*midterm * 0.30)
                     + (*endterm * 0.40);

    if (compute_grade >= 75.00) {
        result = true;
    }
    else {
        result = false;
    }

    switch(result) {

     case   true : cout << "\nThe Student Passed the Subject.";
                   break;
      case   false : cout << "\nThe Student Failed the Subject.";
                     break;
      default      : cout << "Sorry Invalid Grade !!!";
    }
     return(compute_grade);
 }

 void start()
 {

     cout << "\t\t GRADE SOLVER VERSION 1.0 USING POINTERS";
     cout << "\n\n\t       Created By: Mr. Jake R. Pomperada, MAED-IT";
     cout << "\n\n";
     cout << "Enter Prelim Grade  ==> ";
     cin >> X_Prelim;
     cout << "Enter Midterm Grade ==> ";
     cin >> X_Midterm;
     cout << "Enter Endterm Grade ==> ";
     cin >> X_Endterm;
     cout << "\n";
     cout << fixed;
     cout << setprecision(2);
     cout << "\nYour Final Grade is " <<
          solve_grade(&X_Prelim,&X_Midterm,&X_Endterm) << ".";

     cout << "\n\n";
     system("PAUSE");
 }

main() {

    start();
}


No comments:

Post a Comment