Pages

CS304P ASSIGNMENT NO. 1 FALL 2022 || 100% RIGHT SOLUTION || OBJECT ORIENTED PROGRAMMING (PRACTICAL) || BY VuTech

CS304P ASSIGNMENT NO. 1 FALL 2022 || 100% RIGHT SOLUTION || OBJECT ORIENTED PROGRAMMING (PRACTICAL) || BY VuTech

CS304P ASSIGNMENT NO. 1 FALL 2022

KINDLY, DON’T COPY PASTE

CS304P ASSIGNMENT NO. 1 FALL 2022 || 100% RIGHT SOLUTION || OBJECT ORIENTED PROGRAMMING (PRACTICAL) || BY VuTech

SEND WHATSAPP OR E-MAIL FOR ANY QUERY

0325-6644800

kamranhameedvu@gmail.com 


Objective

The objective of this assignment is:

To give you the idea of practical implementation of the following concepts of the Object Oriented Programming (OOP):

·         Access Specifiers, Data Members and Member Functions

·         Access Functions

·         Default and Parameterized Constructors

·         Dynamic Memory allocation using new operator

Uploading instructions:

  • Your assignment should be in .CPP format (Any other formats like scan images, PDF, zip, doc, rar and bmp etc. will not be accepted).
  • Save your assignment with your ID (e.g. bc000000000.CPP).
  • No assignment will be accepted through email.

Rules for Marking:

 

It should be clear that your assignment will not get any credit if:

 

·         The assignment is submitted after due date.

·         The submitted assignment does not open, execute or file is corrupted.

·         Your assignment is copied from internet, handouts or from any other student.

      (Strict disciplinary action will be taken in this case).

 

Lectures Covered:

 

This assignment covers Lecture # 7-12.



Assignment No. 1

Virtual University of Pakistan is an institute which offers technical and non-technical courses based on the distance learning model where one can join any of the courses just by using a computer system. Consider that you are enrolled in a course, OOP (Object Oriented Programming) and you have been given a task to develop a program in C++ which will take marks of different assessments as input and displays total marks as an output.

Step by step instructions:

·    Write a C++ class name Student with the following attribute: Student Id, Student name, quiz marks (for 4 quizzes), assignment marks (for 2 assignments), Mid Term Marks, Final Term Marks, Total Marks

·         Write a parameterized constructor which passes all the data members of the Student class?

·         Write an appropriate copy constructor for the student class

·         Write member functions for the following requirements:


Function Name

Description

enterData()

To input data from the user through console as mentioned in the screenshot.

calculateResult()

To calculate the result according to the grading scheme.

displayData()

To print data on the screen as mentioned in the screenshot.







Grading Scheme:

Activity

Weightage

Number of activities

Formulation

Quiz

10%

4

 * 10

Assignment

20%

2

 * 20

Mid Term Exam

30%

1

 * 30

Final Term Exam

40%

1

 * 40


Perform the following tasks in main():

o   Create an array of size 3 of Student objects using new operator

o   Initialize the index [0] using parameterized constructor

o   Enter data for the index [1] through enterData()

o   Copy index[1] object into index [2] by using  copy constructor

o   Display all the Records by using displayData()


Note:

Apply all the validations on the marks at the time of input mentioned in the screenshot.

After running your program, the following screen should display.

 



Best of luck!

NOTE:  Do not put any query on MDB about this assignment, if you have any query then email at cs304p@vu.edu.pk.  Furthermore, if any student found cheating from any other student or from online forums then he/she will be awarded ZERO right away and strict disciplinary action will be taken against the student.

 

Deadline: Your assignment must be uploaded/submitted on or before December 05, 2022 .

KINDLY, DON’T COPY PASTE

SUBSCRIBE, SHARE, LIKE AND COMMENTS FOR MORE UPDATES

SEND WHATSAPP OR E-MAIL FOR ANY QUERY

0325-6644800

kamranhameedvu@gmail.com 



SOLUTION


#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 Mid_Term_Marks, int Final_Term_Marks);

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, 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)

{

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;

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()

{

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;

string student_name, student_id;

bool flagquiz = true;

bool flagAssignment = true;

bool flagMidTerm = true;

bool flagFinalTerm = true;

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;

}

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;

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;

}

  } 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;

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);

 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;

}


KINDLY, DON’T COPY PASTE

SUBSCRIBE, SHARE, LIKE AND COMMENTS FOR MORE UPDATES

SEND WHATSAPP OR E-MAIL FOR ANY QUERY

0325-6644800

kamranhameedvu@gmail.com