0% found this document useful (0 votes)
2K views11 pages

CS304P Assignment 1 Solution by M.junaid Qazi

The document provides instructions for Assignment Solution #01 for an Object Oriented Programming practical course. It notes that students should not copy solutions and should contact the provided phone number with any questions. It then provides C++ code for a Student class that defines data members for student details, calculates grades and totals, and displays output. The main function tests the class by creating Student objects, collecting input, and printing a table of results.

Uploaded by

Asmar Dhair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views11 pages

CS304P Assignment 1 Solution by M.junaid Qazi

The document provides instructions for Assignment Solution #01 for an Object Oriented Programming practical course. It notes that students should not copy solutions and should contact the provided phone number with any questions. It then provides C++ code for a Student class that defines data members for student details, calculates grades and totals, and displays output. The main function tests the class by creating Student objects, collecting input, and printing a table of results.

Uploaded by

Asmar Dhair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Total marks = 20

Object Oriented Programming (Practical) Deadline


CS304P th
5 of DEC, 2022
Assignment Solution # 01
FALL 2022

Please carefully read the following instructions before attempting the assignment Solution.

NOTE
Don't copy-paste the same answer.
Make sure you can make some changes to your solution file before submitting copy paste
solution will be marked zero.
If you found any mistake then correct yourself and inform me.
Before submitting an assignment/GDB check your assignment requirement file.

For any query, feel free to Contact at Whatsapp:


+923074960034

Provide by M.JUNAID QAZI

Student id: ……………….


Code:

#include <iostream>
#include <string.h>
#include <conio.h>
using namespace std;
class Student
{
public:
Student() {}
Student(string Student_Id, string Student_name, int quiz_marks1, int quiz_marks2, int
quiz_marks3, int quiz_marks4, int assignment_marks1, int assignment_marks2, int

CONTACT ON WHATSAPP
+923074960034

+92 3074960034
Mid_Term_Marks, int Final_Term_Marks);
private:
string Student_name, Student_Id;
float
quiz_marks1,
quiz_marks2,
quiz_marks3,
quiz_marks4,
assignment_marks1,
assignment_marks2,
Mid_Term_Marks,
Final_Term_Marks,
Total_Marks;
float totalQuiz, TotalAssignment, TotalMidterm, TotalFinalterm;
public:
void enterData(string Student_Id, string Student_name, int quiz_marks1, int quiz_marks2,
int quiz_marks3, int quiz_marks4, int assignment_marks1, int assignment_marks2, int
Mid_Term_Marks, int Final_Term_Marks);
void calculateQuiz();
void calculateAssignment();
void calculateMidterm();
void calculateFinalterm();
void calculateTotalMarks();
void displayData();
Student(Student &obj)

CONTACT ON WHATSAPP
+923074960034

+92 3074960034
{
this->Student_Id = obj.Student_Id;
this->Student_name = obj.Student_name;
this->quiz_marks1 = obj.quiz_marks1;
this->quiz_marks2 = obj.quiz_marks2;
this->quiz_marks3 = obj.quiz_marks3;
this->quiz_marks4 = obj.quiz_marks4;
this->assignment_marks1 = obj.assignment_marks1;
this->assignment_marks2 = obj.assignment_marks2;
this->Mid_Term_Marks = obj.Mid_Term_Marks;
this->Final_Term_Marks = obj.Final_Term_Marks;
}
};
Student::Student(string Student_Id, string Student_name, int quiz_marks1, int
quiz_marks2, int quiz_marks3, int quiz_marks4, int assignment_marks1, int
assignment_marks2, int Mid_Term_Marks, int Final_Term_Marks)
{
enterData(Student_Id, Student_name, quiz_marks1, quiz_marks2, quiz_marks3,
quiz_marks4, assignment_marks1, assignment_marks2, Mid_Term_Marks,
Final_Term_Marks);
}
void Student::enterData(string Student_Id, string Student_name, int quiz_marks1, int
quiz_marks2, int quiz_marks3, int quiz_marks4, int assignment_marks1, int
assignment_marks2, int Mid_Term_Marks, int Final_Term_Marks)
{
this->Student_Id = Student_Id;
this->Student_name = Student_name;
CONTACT ON WHATSAPP
+923074960034

+92 3074960034
this->quiz_marks1 = quiz_marks1;
this->quiz_marks2 = quiz_marks2;
this->quiz_marks3 = quiz_marks3;
this->quiz_marks4 = quiz_marks4;
this->assignment_marks1 = assignment_marks1;
this->assignment_marks2 = assignment_marks2;
this->Mid_Term_Marks = Mid_Term_Marks;
this->Final_Term_Marks = Final_Term_Marks;
}
void Student::calculateQuiz()
{
this->totalQuiz = (((this->quiz_marks1 + this->quiz_marks2 + this->quiz_marks3 +this-
>quiz_marks4)) / 40) * 10;
}
void Student::calculateAssignment()
{
this->TotalAssignment = (((this->assignment_marks1 + this->assignment_marks2)) / 40) *
20;
}
void Student::calculateMidterm()
{
this->TotalMidterm = ((this->Mid_Term_Marks) / 40) * 30;
}
void Student::calculateFinalterm()
{

CONTACT ON WHATSAPP
+923074960034

+92 3074960034
this->TotalFinalterm = ((this->Final_Term_Marks/ 60 ) * 40);
}
void Student::calculateTotalMarks()
{
this->Total_Marks = (this->totalQuiz + this->TotalAssignment + this->TotalMidterm +
this->TotalFinalterm);
}
void Student::displayData()
{
calculateQuiz();
calculateAssignment();
calculateMidterm();
calculateFinalterm();
calculateTotalMarks();
cout << this->Student_Id << "\t\t\t" << this->Student_name << "\t\t" << this-
>TotalMidterm << "\t\t" << this->TotalFinalterm << "\t\t" << this->Total_Marks <<endl;
}

bool checkRange(int low, int high, int x)


{
return ((x - high) * (x - low) <= 0);
}
int main()
{
int quizmarks[4], assignment[2], midTerm, finalTerm;

CONTACT ON WHATSAPP
+923074960034

+92 3074960034
string student_name, student_id;
bool flagquiz = true;
bool flagAssignment = true;
bool flagMidTerm = true;
bool flagFinalTerm = true;
cout<<" Solution By M.junaid Qazi "<<endl;
cout << " TO Get Solution Contact On +923074960034 "<<endl;
cout<<"---------------------------------------------------------------------------------------------------
-------------------"<<endl;

cout << "Enter Student Id :";


cin >> student_id;
cout << "Enter Student name :";
cin >> student_name;

for (int i = 0; i < 4; i++)


{
cout << "Enter marks for Quiz" << (i + 1) << " <out of 10>";
cin >> quizmarks[i];
do
{
if (checkRange(0, 10, quizmarks[i]))
{
flagquiz = false;
}

CONTACT ON WHATSAPP
+923074960034

+92 3074960034
else
{
cout << "Invalid Marks,Quiz Marks should be between 0-10." << endl;
cout << "Enter marks for Quiz" << (i + 1) << " <out of 10>";
cin >> quizmarks[i];
flagquiz = true;
}
}
while (flagquiz);
}

for (int i = 0; i < 2; i++)


{
cout << "Enter marks for Assignment" << (i + 1) << " <out of 20>";
cin >> assignment[i];
do
{
if (checkRange(0, 20, assignment[i]))
{
flagAssignment = false;
}
else
{
cout << "Invalid Marks, Assignment Marks should be between 0-20." << endl;

CONTACT ON WHATSAPP
+923074960034

+92 3074960034
cout << "Enter marks for Assignment" << (i + 1) << " <out of 20>";
cin >> assignment[i];
flagAssignment = true;
}
}
while (flagAssignment);
}

cout << "Enter marks for Mid term <out of 40>";


cin >> midTerm;
do
{
if (checkRange(0, 40, midTerm))
{
flagMidTerm = false;
}
else
{
cout << "Invalid Marks, Mid term Marks should be between 0-40." << endl;
cout << "Enter marks for Mid term <out of 40>";
cin >> midTerm;
flagMidTerm = true;
}
}

CONTACT ON WHATSAPP
+923074960034

+92 3074960034
while (flagMidTerm);

cout << "Enter marks for Final term <out of 60>";


cin >> finalTerm;
do
{
if (checkRange(0, 60, finalTerm))
{
flagFinalTerm = false;
}
else
{
cout << "Invalid Marks, Final term Marks should be between 0-60." << endl;
cout << "Enter marks for Final term <out of 60>";
cin >> finalTerm;
cout <<endl<<endl;
flagFinalTerm = true;
}
}
while (flagFinalTerm);

Student *std = new Student[3];


std[0] = Student("Bc0000000", "name", 2, 4, 6, 8, 11, 17, 0, 0);
std[1].enterData(student_id, student_name, quizmarks[0], quizmarks[1], quizmarks[2],
quizmarks[3], assignment[0], assignment[1], midTerm, finalTerm);

CONTACT ON WHATSAPP
+923074960034

+92 3074960034
std[2] = Student(std[1]);
cout << "Sutdent ID"
<< "\t\t"
<< "StudentName"
<< "\t"
<< "MidTermMarks"
<< "\t"
<< "FinalTermMArks"
<< "\t\t"
<< "TotalMarks" << endl;
cout << "--------------------------------------------------------------------------------------------------
--------" << endl;
std[0].displayData();
std[1].displayData();
std[2].displayData();
delete []std;
return 0;
}

CONTACT ON WHATSAPP
+923074960034

+92 3074960034
Out Put:

Every assignment/GDB is change due to unique Student ID so Don’t


Copy That is truly perfect step by step idea solution get help easily.

M.juniad Qazi
WHATSAPP +923074960034

CONTACT ON WHATSAPP
+923074960034

+92 3074960034

You might also like