Vous êtes sur la page 1sur 3

National University

OF COMPUTER AND EMERGING SCIENCES CHINIOT-FAISLABAD CAMPUS

Department of Computer Science


CL 101 ITC Lab-9 (Fall-2015)
Learning outcomes

Basic elements of a C++ program , input/output


Writing simple C++ programs using different data types, special characters and basic use
of arithmetic expressions.

Instructions

First understand the problem and then start working on it.


All tasks should be submitted within the lab timing no late submission would be
accepted in any case.
Write C++ code for all the problems using MS Visual studio and submit them in a MS
Word document with output screen shots.

Task 1:
Write a C++ program to calculate electricity bill of a person. Your program should ask the user
to enter units of electricity consumed this month and meter type (c for commercial and p for
personal), the program should then calculate and display the total bill in rupees the customer
needs to pay using the following bill calculation rules.
For first 100 units the rate is 5 Rs. /unit, for units 101 to 300 the rate applied would be 8 Rs.
/unit and 10 Rs. /unit rate should be applied for units 300. E.g. if units are 450 three different
rates would be applied Rs. 5 for first 100 units Rs. 8 for next 200 units and Rs. 10 for remaining
150 units.
If the meter type is commercial then 3.5% tax should be also be added in the calculated bill.
Sample Program Run-1:
Enter units consumed: 450
Enter meter type: C

Instructor: Saqib Hayat


ITC

National University
OF COMPUTER AND EMERGING SCIENCES CHINIOT-FAISLABAD CAMPUS

Bill Breakup:
1-100 Units

= 500 Rs.

101-300 Units = 1600 Rs.


301-450 Units = 1500 Rs.
Tax Applied: 126 Rs.
This months total electricity bill is: 3726 Rs.
Sample Program Run-2:
Enter units consumed: 112
Enter meter type: P
Bill Breakup:
1-100 Units

= 500 Rs.

101-112 Units = 96 Rs.


This months total electricity bill is: 596 Rs.

Task-2:
Write a C++ program that will always take 5 digit number as input and will check that it is
palindrome or not. e.g. 12321, 76867 are palindrome numbers because first digit match with
last and 2nd with 2nd last.
Sample Program Run 1:
Enter the number: 12321
Output: It is a palindrome number
Sample Program Run 2:
Enter the number: 12325
Output: It is not palindrome number

Instructor: Saqib Hayat


ITC

National University
OF COMPUTER AND EMERGING SCIENCES CHINIOT-FAISLABAD CAMPUS

Task-3:
Write a C++ program to input and calculate the salary of employee. There are two types of
employees one is hourly and other is monthly. Your program should ask the user to enter what
type of employees salary he/she wants to calculate where h represents hourly employee and
m represents monthly employee. If user wants to calculate hourly employees salary, you will
take following inputs Rate/hours, No of hours worked and bonus. If user wants to calculate the
salary of monthly employee, you will take following inputs Salary/month and bonus. Below are
two sample program runs one for monthly employee and one for hourly.

Sample Run 1:
Enter employee id: 12
Enter type of employee: h
Enter Rate/Hour: 25.28
Enter No of hours worked: 45
Enter Bonus: 455.32
Your salary is: 1592.92 Rs.
Sample Run 2:
Enter employee id: 195
Enter type of employee: m
Enter Salary/Month: 22000
Enter Bonus: 2350.30
Your salary is: 24350.30 Rs.

Instructor: Saqib Hayat


ITC

Vous aimerez peut-être aussi