Help with assignment (ifstream and ofstream)

3 views (last 30 days)
Justin
Justin on 5 Mar 2014
Hello, out there. I started my first programming class this year, which C++ with Microsoft Visual Studios 2012. I was doing ok until I hit a roadblock while doing my lab assignment. I was wondering if any can help me out with this so I can turn it in for class.
Here my work so far:
if true
% code
// Justin Collins
// CIS 251 - Spring 2013
// Laboratory Assignment 7
// 2/27/2014
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int student_number;
char last_name[50], first_name[35], middle_name[1], major_code[1];
double gpa = 0.00;
ifstream cisdegree;
ofstream appmajors;
ofstream netmajors;
ofstream progmajors;
ofstream webmajors;
cisdegree.open("cisdegree.txt", ios::app);
if (cisdegree.fail())
{
cout << "Error opening input file.\n";
exit(1); // 1 indicates an error
}
appmajors.open("appmajors.txt", ios::app);
cout.setf(ios::fixed); // number formatting
cout.setf(ios::showpoint);
cout.precision(2);
netmajors.open("netmajors.txt", ios::app);
cout.setf(ios::fixed); // number formatting
cout.setf(ios::showpoint);
cout.precision(2);
progmajors.open("progmajors.txt", ios::app);
cout.setf(ios::fixed); // number formatting
cout.setf(ios::showpoint);
cout.precision(2);
webmajors.open ("webmajors.txt", ios::app);
cout.setf(ios::fixed); // number formatting
cout.setf(ios::showpoint);
cout.precision(2);
return 0;
}
I stopped at step 5. The pdf of the assignment is attached with this post. Any help would be appreciated before I have to turn it in tomorrow at 9:00pm 3/5/14.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!