Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Computer Programming

Fall 2022
Assignment-1
Selection Control Structures

OBJECTIVE

1) To understand the logical expressions and their use in selection statements of C++
2) To understand and practice
a. If statement
b. If – else statement
c. Switch statement

READING ASSIGNMENT

Before starting this assignment, students should read/revise at-least handouts & slides given on topics
presented in the class. Students can find these handouts from course webpage on LMS.

This assignment must hold the following items for each Question attempted.

 Source Code
 Dry Run
 Output window with debugging environment ( https://www.youtube.com/watch?v=0br6VAjoxg8 )

REPORT

You will have to complete and submit a report for this assignment before Submission deadline.
The report will be submitted as a [soft copy] of word document and will consist of following parts:
1) A proper title page
2) Source code, output screens, dry run and explanation (if asked) for each question.

To copy the output screen that shows your output, press shift +“print screen”. Paste the Result in
a Paint document where you can copy a portion of the screen which can then be pasted in a word
document. Or you can paste the result directly in a word document.

Statements:

1. Write and run a program that reads a character and writes out a name corresponding to the
character:
if the character is ‘F’ or ‘f’ then the name is ‘Fahad’
if the character is ‘S’ or ‘s’ then the name is ‘Sulman’
if the character is ‘A’ or ‘a’ then the name is ‘Ahmed’
if the character is ‘B’ or ‘b’ then the name is ‘Bilal’
otherwise, the name is just the character.
2. Write a program for XYZ-Electric billing company. First understand the following situation.
This program calculates a customer’s bill for XYZ-Electric billing company. There are two types
of customers: residential and commercial. There are two rates for calculating a bill: one for
residential customers and one for commercial customers.

For residential customers, the following rates apply:


• Bill processing fee: Rs.4.50/-
• Basic service fee: Rs.20.50/-
• Unit Rate: Rs.7.50 per Unit
For commercial customers, the following rates apply:
• Bill processing fee: Rs.10.50/-
• Basic service fee: Rs.50.50/-
• Unit Rate: Rs.12.50 per Unit

The program should ask the user for an account number (an integer) and a customer code. Assume
that R or r stands for a residential customer, and C or c stands for a commercial customer

Input:
The customer’s account number, customer code & number of units consumed for a particular
month.

Output:
Customer’s account number and the billing amount.

Algorithm:

1. Prompt the user for the account number and customer type.
2. Prompt the user for the number of units consumed.
3. Based on the customer type, compute the bill, and print the bill

3. The local t-shirt shop sells shirts that retail for Rs.50/-. Quantity discounts are given as follow:
Number of Shirts Discount
5–10 10%
11–20 15%
21–30 20%
31 or more 25%

Write a program that prompts the user for the number of shirts required and then computes the total
price. Make sure the program accepts only non-negative input.

Sample Run:
How many shirts would you like?
4
The cost per shirt is Rs.50/- and the total cost is Rs.200/-

4. The ABC University of Pakistan charges Rs.30000/- per semester for on-campus tuition and
Rs.45000/- per semester for off-campus tuition. In addition, miscellaneous charges are Rs.2500/-
per semester for on-campus students and Rs.3500/- per semester for off-campus students. Write a
program that prompts the users for their status (i.e., on-campus or off-campus).The program should
then compute and output their bill for that semester.
Sample Run 1:
Please input "A" if you are on-campus or "Z" if you are off-campus student:
A
Your total bill for this semester is Rs.32500/-

Sample Run 2:
Please input "A" if you are on-campus or "Z" if you are off-campus student:
Z
Your total bill for this semester is Rs.49000/
CSC 113 – Computer Programming

Assignment # 01

Submitted by
(Name)
(Enrollment #)
(Class & Section)

Submitted To

Tuesday, October 18, 2022

Department of Computer Science


Bahria University Islamabad
2022

You might also like