Final Lab Exam-Programming
Final Lab Exam-Programming
Q1.
Solution:
#include<iostream>
struct grades
{
public:
int marks_of_student[3];
};
cout<<"\n*****************************************\n\n";
}
else
cout<<" Wrong Output";
int main()
{
grades student_marks;
cout<<"*****************************************\n\n";
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;
};
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;
};
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;