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

Tutorial 4 Lab Report 7 & 8

The document contains code for two programming lab reports. The first program calculates bonus salary based on an employee's grade. It provides a 50% bonus if the grade is above 15 and a 25% bonus if the grade is 15 or below. The second program calculates an electricity bill based on consumption units. It determines the per-unit rate based on a tiered system and includes a fixed line rent and optional 5% surcharge if the bill exceeds 2000 rupees. Both programs take input from the user and output the calculated total amount.

Uploaded by

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

Tutorial 4 Lab Report 7 & 8

The document contains code for two programming lab reports. The first program calculates bonus salary based on an employee's grade. It provides a 50% bonus if the grade is above 15 and a 25% bonus if the grade is 15 or below. The second program calculates an electricity bill based on consumption units. It determines the per-unit rate based on a tiered system and includes a fixed line rent and optional 5% surcharge if the bill exceeds 2000 rupees. Both programs take input from the user and output the calculated total amount.

Uploaded by

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

SMME NUST

Fundamentals of Programming
Lab Report 7 & 8
For Tutorial 4
Submitted By: Osama Jarrar Haider
ME 12 C, 340116
Submitted to: Dr. Omer Gillani
Lab Report No 7
Write a program that takes the input of salary and grade, from the user.

1. It adds 50% bonus if the grade is greater than 15.


2. It adds a 25% bonus if the grade is 15 or less.
3. It outputs (displays) the total salary.

#include<iostream>
#include<cmath>
using namespace std;
int main() {
float salary;
int grade;

cout << "Enter salary of the employee in rupees \n";


cin >> salary;
cout << "Enter grade :\n";
cin >> grade;
if (grade > 15)
{
salary = salary + (0.5 * salary);
cout << "The salary with 50% bonus = " << salary << " Rupees"<<endl;
}
else
{
salary = salary + (0.25 * salary);
cout << "The salary with 25% bonus = " << salary <<" Rupees"<< endl;

}
}
Lab Report No 8
Write a program that takes an input of consumed units, from the user, and shows the total
electricity bill. The per-unit rate, line rent, and surcharge are as follows:

1. If the units consumed are less than or equal to 300, then the cost is 2 PKR per unit.
2. If the units consumed are more than 300 but less than or equal to 500, then the cost
is 5 PKR per unit.
3. If the units consumed exceed 500, then the cost per unit is 7 PKR
4. A line rent is 150 PKR
5. A surcharge of 5% is added if the bill exceeds 2000 PKR

#include<iostream>
using namespace std;
int main() {
int units, rate;
float bill;
cout << "Enter the units of electricity consumed: \n";
cin >> units;
if (units <= 300) {
rate = 2;
}
else if (units <= 500) {
rate = 5;
}
else if (units > 500) {
rate = 7;
}
bill = (units * rate) + 150;
cout << "The bill is (This is the amount of bill excluding surcharge even if it is
applicable): " << bill << endl<<endl;
if (bill > 2000) {
bill = bill + (0.05 * bill);
cout << "The total electricity bill for " << units << " units is " << bill
<< " at the rate of " << rate << " rupees per unit and surcharge "
"at the rate of 5%" << endl;
}
}

You might also like