0 Replies - 1500 Views - Last Post: 26 October 2008 - 09:50 AM Rate Topic: -----

#1 duskmon10  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 100
  • Joined: 01-October 08

Computing GPA and Output with Formatting

Posted 26 October 2008 - 09:50 AM

I need some help with the input on this problem.

-Write a program to read from an input file(StudentFile2.txt) for 15 students, which contains each individual student ID, the course code, grade points (4 for A, 3 for B, 2 for C, 1 for D, and 0 for anything else) and credit hours for five courses. It should then compute the total credit hours, the grade point average for the first 5 students and output them to a file with the following format:

Student ID: 11111
Course Credit-Hours Grade
EN100 3 C
CS155 4 A
UI100 3 B
PH120 5 A
AR101 3 D
Total Credit hours: 18
GPA is: 3.0

---(Note: There should be tabs where each space is after teh first line.)

So I also need help with how to calculate GPA and I also need to know how to create a new file to output the information to. But most of all my problem is the input.

Here's the code I've got so far:

#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
void input(int & studentid, int & hours, int & coursecode, int & grade);
void output(int studentid, int hours, int coursecode, int grade;)
int main()
	int studentid, hours;
	char coursecode; 
	char grade;
	ifstream instream;
	ofstream outstream;
	if (instream.fail())
		cout<<"Input file opening failed.\n";
	if (outstream.fail())
		cout<<"Output file opening failed.\n";
	input(studentid, hours, coursecode, grade);
	return 0;
void input(int & studentid, int & hours, int & coursecode, int & grade)

Thanks for any help.

This post has been edited by duskmon10: 26 October 2008 - 09:51 AM

Is This A Good Question/Topic? 0
  • +

Page 1 of 1