473,386 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

grade average using c++

hi guys
i new in this section
i have a doubt;
im trying to find the student average on my execise,here a copy

Expand|Select|Wrap|Line Numbers
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9.     ifstream infile;
  10.   ofstream outfile;
  11.   infile.open("filein.dat");
  12.   outfile.open("outrep.txt");
  13.  
  14.   outfile << "\t\t\t TURABO UNIVERSITY" << endl;
  15.   outfile << "\t\t\tGRADE AVERAGE\n" << endl;
  16.   outfile << "\tSTUDENT" << "\t\tFIRST" << "\t\tSECOND" << "\t\tTHIRD" << "\t\tSTUDENT" << endl;
  17.   outfile << "\tNUMBER" << "\t\tExam" << "\t\tExam" << "\t\tExam" << "\t\tAVERAGE" << endl;
  18.  
  19.  
  20.     while (infile) 
  21.    string sn;
  22.       int sn;
  23.       int fe=00;
  24.       int se=00;
  25.       int te=00;
  26.       int st=00;
  27.      float avr=00.0;
  28.      float cavr=00;
  29.  
  30.       sn=458;
  31.       fe=90;
  32.       se=85;
  33.       te=75;
  34.       avr=fe+se+te/3;
  35.       cavr=cavr+avr;
  36.       outfile << "\t" << sn << "\t\t" << fe << "\t\t" << se << "\t\t" << te << endl;
  37.  
  38.       sn=459;
  39.       fe=100;
  40.       se=88;
  41.       te=78;
  42.       avr=fe+se+te/3;
  43.       cavr=cavr+avr;
  44.       outfile << "\t" << sn << "\t\t" << fe << "\t\t" << se << "\t\t" << te << endl;
  45.  
  46.       sn=4510;
  47.       fe=67;
  48.       se=90;
  49.       te=99;
  50.       avr=fe+se+te/3;
  51.       outfile << "\t" << sn << "\t\t" << fe << "\t\t" << se << "\t\t" << te << endl;
  52.  
  53.  
  54.       st=st+3;
  55.  
  56.       cavr=cavr+avr;
  57.  
  58.  
  59.       outfile << "\tSTUDENT TOTAL: " << st << endl << endl;
  60.  
  61.       outfile << "\tCLASS AVERAGE: " << cavr << endl << endl;
  62.  
  63.     system("PAUSE");
  64.     return EXIT_SUCCESS;
Oct 3 '07 #1
1 2290
hi guys
i new in this section
i have a doubt;
im trying to find the student average on my execise,here a copy

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main(int argc, char *argv[])
{
ifstream infile;
ofstream outfile;
infile.open("filein.dat");
outfile.open("outrep.txt");

outfile << "\t\t\t TURABO UNIVERSITY" << endl;
outfile << "\t\t\tGRADE AVERAGE\n" << endl;
outfile << "\tSTUDENT" << "\t\tFIRST" << "\t\tSECOND" << "\t\tTHIRD" << "\t\tSTUDENT" << endl;
outfile << "\tNUMBER" << "\t\tExam" << "\t\tExam" << "\t\tExam" << "\t\tAVERAGE" << endl;


while (infile)
string sn;
int sn;
int fe=00;
int se=00;
int te=00;
int st=00;
float avr=00.0;
float cavr=00;

sn=458;
fe=90;
se=85;
te=75;
avr=fe+se+te/3;
cavr=cavr+avr;
outfile << "\t" << sn << "\t\t" << fe << "\t\t" << se << "\t\t" << te << endl;

sn=459;
fe=100;
se=88;
te=78;
avr=fe+se+te/3;
cavr=cavr+avr;
outfile << "\t" << sn << "\t\t" << fe << "\t\t" << se << "\t\t" << te << endl;

sn=4510;
fe=67;
se=90;
te=99;
avr=fe+se+te/3;
outfile << "\t" << sn << "\t\t" << fe << "\t\t" << se << "\t\t" << te << endl;


st=st+3;

cavr=cavr+avr;


outfile << "\tSTUDENT TOTAL: " << st << endl << endl;

outfile << "\tCLASS AVERAGE: " << cavr << endl << endl;

system("PAUSE");
return EXIT_SUCCESS;

I'm not sure what exactly all your variables stand for and what they're doing, but I did notice this:

Expand|Select|Wrap|Line Numbers
  1. avr=fe+se+te/3;
Multiplication and division have a higher preference than addition or subtraction, so this would divide te by 3, and then add fe and se to that.

I'm guessing avr means average, so you should probably try:

Expand|Select|Wrap|Line Numbers
  1. avr = (fe+se+te)/3;
Oct 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

35
by: Henry | last post by:
I was doing this program for an exercise in a book. The point was to create a program that would take a numerical grade from a user and convert it to a letter grade (yeah really easy). I tried to...
1
by: sparkid | last post by:
I need immediate help in writing a function program. I have to write a program in functions and use array to store them. I am not familiar with functions and i tried to create it but i fails to...
0
by: hockeyjock | last post by:
I need to develop a grade book program. This is my first programming class. I have learned variables, data types, math operations and precedence, I HAVE not learned methods, I have read about 5 book...
4
by: Madmartigan | last post by:
Hello I have attempted the source code from Chapter 4 in Accelerated C++ page 70 but keep getting the above error. I'm not sure whether it is in the way I have saved the header files or because my...
11
by: C Learner | last post by:
I really need help I have got this program all screwed and cant figure out why I cant access my char grades pleade help C learner Grade.cpp int main(int argc, char *argv) { void...
2
by: yalbizu | last post by:
#include <iostream> #include <string> #include <fstream> #include <iomanip> using namespace std; const int NO_OF_STUDENTS=20; struct studentType { string studentFName; string studentLName;
1
by: mercea | last post by:
Hi all, i have a web page which contains a gridview. On this gridview, the user uses a set of radiobuttonlists to select an option. the selected option is then to be compared with the data in a...
3
by: hanie | last post by:
a student wants to know his grade average for the semester. the grades are give in letter grades with numeric equivalents. develop a solution to calculate a grade average given the letter grades(the...
3
by: blamp | last post by:
I have completed most of the program I just cant get the letter grade to print from the void printGrade function.The output of the program should be: Line 1: Based on the course score, this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.