0% found this document useful (0 votes)
20 views

CS Assignment

The document contains code for a C++ program that takes in a student's VU ID and marks in four subjects, calculates the total and average marks, determines the grade based on the average, and prints out the results. It prompts the user for input, stores the input in variables, performs calculations, uses if/else statements to determine the grade based on thresholds, and outputs the VU ID, total marks, average marks, and grade.

Uploaded by

mustufaismail36
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

CS Assignment

The document contains code for a C++ program that takes in a student's VU ID and marks in four subjects, calculates the total and average marks, determines the grade based on the average, and prints out the results. It prompts the user for input, stores the input in variables, performs calculations, uses if/else statements to determine the grade based on thresholds, and outputs the VU ID, total marks, average marks, and grade.

Uploaded by

mustufaismail36
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Name:

Id:

#include <iostream>
using namespace std;

int main() {
// Variables to store user input
string vuId;
int csMarks, mathMarks, pakStudyMarks, mgtMarks;

// Prompt the user to enter VU-ID and marks for each subject
cout << "Enter your VU-ID: ";
cin >> vuId;

cout << "Enter marks for CS: ";


cin >> csMarks;

cout << "Enter marks for Math: ";


cin >> mathMarks;

cout << "Enter marks for Pak Study: ";


cin >> pakStudyMarks;

cout << "Enter marks for MGT: ";


cin >> mgtMarks;

// Calculate total and average marks


int totalMarks = csMarks + mathMarks + pakStudyMarks + mgtMarks;
double averageMarks = totalMarks / 4.0;

// Determine the final grade based on the average marks


string grade;
if (averageMarks >= 91 && averageMarks <= 100) {
grade = "A+";
} else if (averageMarks >= 81 && averageMarks < 91) {
grade = "A";
} else if (averageMarks >= 71 && averageMarks < 81) {
grade = "B+";
} else if (averageMarks >= 61 && averageMarks < 71) {
grade = "B";
} else if (averageMarks >= 51 && averageMarks < 61) {
grade = "C";
} else if (averageMarks >= 41 && averageMarks < 51) {
grade = "D";
} else if (averageMarks >= 35 && averageMarks < 41) {
grade = "E";
} else if (averageMarks >= 0 && averageMarks < 35) {
grade = "Fail";
} else {
cout << "Invalid average marks!";
return 0;
}

// Print the results


cout << endl;
cout << "VU-ID: " << vuId << endl;
cout << "Total Marks: " << totalMarks << endl;
cout << "Average Marks: " << averageMarks << endl;
cout << "Grade: " << grade << endl;

return 0;
}

You might also like