Vous êtes sur la page 1sur 3

Assignment No.

02 Semester: Fall 2012 CS201: Introduction to Programming Instructions:

Total Marks: 20 Due Date:14/11/2012

Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if: The assignment is submitted after due date. The submitted assignment does not open or file is corrupt. Assignment is copied(partial or full) from any source (websites, forums, students, etc)

Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Word document) or .txt files, no reward will be given in any case. Objective: The objective of this assignment is to provide hands on experience of: Basic concepts of C/C++ language and Programming Conditional statements if/else structure Repetition Structures in C/C++ Switch statement in C/C++ Function Compiling and executing the program

Guidelines: Code should be properly indented and well commented. Follow C/C++ rules while writing variable names, function names etc Use only dev-C++ for this assignment.

Assignment Problem Statement: Pakistan Electric Supply Company (PESCO) supplies electricity for domestic and commercial usage all over Pakistan. You are required to write a program for calculating the amount of bill paid by the customer for both domestic and commercial usage. User will enter customer number and amount of units consumed, and the program will calculate the amount of bill accordingly. Detailed Description: The program should take customer type as input which must be 1 or 2and the number of units consumed. If the user enters 1 then he/she is a domestic user. If the user enters 2 then he/she is a commercial user. If user enters any other number except 1 or 2, the program should terminate after displaying a message Invalid choice. After taking valid customer type from user, program should ask user to enter the customer number, number of consumed units and number of days. For domestic customer, if the units consumed are between 0 and 100, the price is Rs.5 per unit and there will be no extra charges. If the units consumed are between 101 and 300, the price is Rs.8 per unit plus Rs.100 as extra charges. If the units consumed are between 301 and 500, the price is Rs.10 per unit plus Rs.230 as extra charges. For commercial customers, the price is Rs.15 per unit, which is uniform for any number of units. If user deposits bill within 10 days, he/she will not be incurred for any extra charges. If user deposits bill after 10 days, he/she will be charges for Rs. 200 as extra charges. You are required to write 2 functions. One for calculating the bill for domestic customer, and 2nd to calculate the bill for commercial customer. Use switch structure to determine the customer type. Then pass the customer number, consumed units and number of days to the corresponding function as arguments. These functions will calculate and return the total bill for the customer.

NOTE: The sample output is attached with this assignment named Assignment2.gif.

Vous aimerez peut-être aussi