Write a program that will calculate a student's year marks for all his 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 that a student is registered for. Create an input file called assignments.dat
#include <bits/stdc++.h>
#include<iostream>
#include <stdio.h>
#include <string>
#include <set>
#include <stack>
using namespace std;
#define NO_OF_STUDENTS 3
#define NO_OF_SUBJECTS 2
struct Student
{
int ID;
int Marks[NO_OF_SUBJECTS];
int Total;
};
main(void)
{
int n,r,Flag=1,c,FlagID=0;
int Subjects_CODE[NO_OF_SUBJECTS],SID;
struct Student S[NO_OF_STUDENTS];
for(n=0;n<NO_OF_SUBJECTS;n++) Subjects_CODE[n]=n+100;
n=0;
while(Flag)
{
Flag=0;
cout<<"\n\nPress 1 to enter Marks";
cout<<"\nPress 2 to view Marks";
cout<<"\nPress 0 to QUIT";
cout<<"\nEnter Option (0 to 2): "; cin>>Flag;
if(Flag==1)
{
if(n<NO_OF_STUDENTS)
{
cout<<"\nEnter Student ID: "; cin>>S[n].ID;
S[n].Total=0;
for(c=0;c<NO_OF_SUBJECTS;c++)
{
cout<<"\nEnter Marks for Subject Code ("<<Subjects_CODE[c]<<") :"; cin>>S[n].Marks[c];
S[n].Total = S[n].Total + S[n].Marks[c];
}
n++;
}
else cout<<"\nNo more students can be added.";
}
if(Flag==2)
{
cout<<"\n\nEnter the Student ID: "; cin>>SID;
FlagID=0;
for(c=0;c<n;c++)
{
if(SID==S[c].ID)
{
FlagID=1;
for(r=0;r<NO_OF_SUBJECTS;r++)
{
cout<<"\nSubject Code ("<<Subjects_CODE[r]<<") : "<<S[c].Marks[r];
}
cout<<"\nTotal = "<<S[c].Total;
}
}
if(FlagID==0) cout<<"\nNo student with ID = "<<SID<<" found.";
}
if(Flag==0) exit(0);
}
}
Comments
Leave a comment