Jarreds 0 Newbie Poster

Write a program that calculates a students year marks for all her subjects. The program must
read the subject code, the assignment marks for two assignments and the percentage that each
assignment contributes towards the year mark, for each subject the student is registered for.
Create an input file called assignments.dat that contains the following information for a student:
Code....percentage contribution..1stMark..% contr....2ndmark
SC110 40 66 60 50
CS250 35 76 65 50
SC569 20 64 80 35
DF248 40 46 60 65
NF061 25 96 75 70
DE573 30 45 70 46

Here's my code: (please tell me if its upto std)

#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int main()
{
    ifstream in_file;
    ofstream out_file;
    string subject;
    double ass1m, ass1p, ass2m, ass2p, percent;

    in_file.open("assignments.dat");
    if(in_file.fail())
    {
        cout << "input file opening failed";
        exit(1);
    }

    out_file.open("yearmark.dat");
    if(out_file.fail())
    {
        cout << "output file opening failed";
        exit(1);
    }

    while(!in_file.eof())
    {
        in_file >> subject >> ass1p >> ass1m >> ass2p 
        >>ass2m;

        percent = ((ass1m * ass1p)/ 100   (ass2m * 
        ass2p)/ 100);

        out_file.setf(ios::fixed);
        out_file.setf(ios::showpoint);
        out_file.precision(2);
        cout.setf(ios::fixed);
        cout.setf(ios::showpoint);
        cout.precision(2);
        cout << subject << " " << percent << "%" << endl;
    }
    in_file.close();
    out_file.close();

    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.