Friday, March 2, 2018

Student Grading System Using Text File in C++

A very simple program that I wrote a long time ago to compute and store the student grade in a text file using C++. I am using Code Blocks as my text editor and Dev C++ as my C++ compiler in this program.

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

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

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is  +63 (034) 4335675.



Program Listing.

student_grade.cpp

#include <iostream>
#include <fstream>

using namespace std;

float grade(float pre, float med, float end)
{
   float compute=0;
  compute = (pre * 0.30) + (med * 0.30) + (end * 0.40);
  return(compute);
}

 main() {
      ofstream myfile("grade.txt");
      string name,course;
      float pre1=0.00, med1=0.00,end1=0.00;
      cout << "\n\t Student Grading System 1.0";
      cout << "\n\n";
      cout << "Enter Student Name    : ";
      getline(cin,name);
      cout << "Enter Student Course : ";
      getline(cin,course);
      cout << "Enter Prelim Grade    : ";
      cin >> pre1;
      cout << "Enter Midterm Grade   : ";
      cin >> med1;
      cout << "Enter Midterm Grade   : ";
      cin >> end1;
      cout << "\n\n";
      cout << "Final Grade "
           << grade(pre1,med1,end1)
           << ".";
      cout << "\n\n";
      myfile << "\n======================";
      myfile << "\n Student Grade Report ";
      myfile << "\n====================== ";
      myfile << "\n\n";
      myfile << "\nStudent Name   : " << name;
      myfile << "\nStudent Course : " << course;
      myfile << "\n\n";
      myfile << "\nPrelim  Grade   : " << pre1;
      myfile << "\nMidterm Grade   : " << med1;
      myfile << "\nEndterm Grade   : " << end1;
      myfile << "\n\n";
      myfile << "Final Grade "
           << grade(pre1,med1,end1)
           << ".";
      myfile.close();
      system("pause");
 }


No comments:

Post a Comment