0% found this document useful (0 votes)
96 views10 pages

Final Lab Exam-Programming

The document contains the solutions to two questions on a programming exam. Q1 defines a struct to store student marks in three subjects and includes functions to display the marks and grade based on the marks. Q2 defines bank account and savings account classes to track savings account deposits and interest over three months, and a salary account class to track salary amounts after withdrawals over three months. Functions calculate and display the amounts for each account over the periods.

Uploaded by

Aaila Akhter
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
96 views10 pages

Final Lab Exam-Programming

The document contains the solutions to two questions on a programming exam. Q1 defines a struct to store student marks in three subjects and includes functions to display the marks and grade based on the marks. Q2 defines bank account and savings account classes to track savings account deposits and interest over three months, and a salary account class to track salary amounts after withdrawals over three months. Functions calculate and display the amounts for each account over the periods.

Uploaded by

Aaila Akhter
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 10

Final Lab Exam

Programming Language Lab


Aaila Akhter
200301001
Mat 13-A

Q1.
Solution:
#include<iostream>

using namespace std;

struct grades
{
public:

int marks_of_student[3];

};

void display_marks( grades student1)


{
cout<<"******** PRINTING MARKS ******** \n\n";

cout<<"Marks of student in programming are : ";


cout<<student1. marks_of_student[0];
cout<<endl;
cout<<"Marks of student in Differential equations are : ";
cout<<student1. marks_of_student[1];
cout<<endl;
cout<<"Marks of student in Islamic studies are : ";
cout<<student1. marks_of_student[2];

cout<<"\n*****************************************\n\n";

void getgrades ( grades student2)


{

if ( student2.marks_of_student[0]>60 && student2.marks_of_student[1]>60 &&


student2.marks_of_student[2]>60)
{
cout<<"Stdent has an A grade \n";
cout<<"Student secured above 60 in all subjects \n";

else if ( student2.marks_of_student[0]<60 && student2.marks_of_student[1]<60 &&


student2.marks_of_student[2]<60)
{
cout<<"Stdent has C grade \n";
cout<<"Student secured below 60 in all subjects \n";
}

else if ( student2.marks_of_student[0]>60 || student2.marks_of_student[1]>60 ||


student2.marks_of_student[2]>60)
{
cout<<"Stdent has B grade \n";
cout<<"Student secured above 60 marks in one subject \n";

}
else
cout<<" Wrong Output";

int main()
{
grades student_marks;

cout<<"*****************************************\n\n";

cout<<"Enter the marks of student in programming : ";


cin>>student_marks.marks_of_student[0];

cout<<"Enter the marks of student in Differential equations : ";


cin>>student_marks. marks_of_student[1];

cout<<"Enter the marks of student in Islamic studies : ";


cin>>student_marks. marks_of_student[2];

cout<<"\n*****************************************\n\n";

display_marks(student_marks);
getgrades(student_marks);
}
Q2.
Solution:
#include<iostream>
using namespace std;
class bank_account
{
public:
double saving_account_deposit =6000;

bank_account()
{
cout<<"The bank deposit in saving account in first month of year is ";
cout<<saving_account_deposit;

cout<<" \nInterest rate in saving account is 2% \n ";


cout<<"Salary of first Month is 40000 \n\n";
}

};
class savings_account: public bank_account
{
public:

double first_month=0;
double second_month=0;
double third_month=0;

void calculate_saving()
{
first_month= saving_account_deposit + ((2*saving_account_deposit)/100);
second_month= first_month + ((2*first_month)/100);
third_month= second_month+ ((2*second_month)/100);
}

void display_saving()
{
cout<<" \n\nThe amount in the first month in saving account is : ";
cout<<first_month;
cout<<endl;

cout<<"The amount in the second month in saving account is : ";


cout<<second_month;
cout<<endl;

cout<<"The amount in the third month in saving account is : ";


cout<<third_month;
cout<<"\n\n";
}

};

class salary_account: public bank_account


{
public:

double salary=40000;
double first_month1=0;
double second_month2=0;
double third_month3=0;

void calculate_salary()
{
first_month1= salary-1500;
second_month2=first_month1-1500;
third_month3= second_month2-1500;
}

void display_salary()
{
cout<<"\n\n The salary after withdrawing 1500 from first month is :";
cout<<first_month1;
cout<<endl;

cout<<"\n\n The salary after withdrawing 1500 from second month is :";
cout<<second_month2;
cout<<endl;

cout<<"\n\n The salary after withdrawing 1500 from third month is :";
cout<<third_month3;
cout<<endl;
}

};

int main()
{

bank_account information;

savings_account information1;

information1.calculate_saving();
information1.display_saving();

salary_account information2;
information2.calculate_salary();
information2.display_salary();

return 0;

You might also like