0% found this document useful (0 votes)
12 views2 pages

CS200 Quiz1

Uploaded by

shahid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

CS200 Quiz1

Uploaded by

shahid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CS200 : Introduction to Programming Quiz 1

Time Allowed: 20(15+5 extra) minutes Total Marks: 10


University ID: Name:

1. The manager of a carpet store has asked you to write a program to print customer’s bills.
The manager has given you the following information.

• The store expresses the length and width of a room in terms of feet and tenths of a foot.
For example, the length might be reported as 16.7 feet
• The amount of carpet purchased is expressed as square yards. It is found by dividing the
area of the room (in square feet) by 9. The store does not sell a fraction of the square
yard. Thus, square yards must always be rounded up
• The carpet charge is equal to the number of square yards purchased times the carpet
cost per square yard. Sales tax equal to 4% of the carpet cost must be added to the bill
• The labor cost is equal to the number of square yards purchased times Rs. 22, which is
the labor cost per square yard. No tax is charged on the labor. A fixed fee of Rs. 200
for floor preparation is also added to the bill.
• The customers may be given a discount. The discount may apply only to the carpet
cost(before sales tax is added), only to the labor cost, or to both.

The input to the program is length and width of the room, carpet cost per square yard,
discount on carpet, discount on labor. The sample output of the program is as follow:

Bill
Square yards purchased: 17
Carpet Cost per square yards: 40
Carpet Charge: 680
Labor: 347
Preparation fee: 200
Tax: 27.2
Discount: 54.4
Sub Total: 1227
Sub Total Less Discount: 1172.5
Total(after adding Tax:) 1199.7

You should follow these instructions while developing the program.

• Please make sure you have written your name and roll number on answer
sheet otherwise you will be awarded with straight zero.
• Identify how the program can be divided into subtasks and Write function for each
subtasks identified and use these functions as per your need.
• Each function should have a meaningful name and functionality and can also perform
more than one task.
• I would love to see your creativity in this task, so be careful while choosing data-types of
the variables.

1
1 # include < iostream >
2 using namespace std ;
3 float amountofcarpet ( float length , float width , int & square_yards_purchased ,
4 float cost_per_square , float & carpet_charge ) {
5 s q u a r e _ y a r d s _ p u r c h a s e d = ( length * width ) /9+1;
6 carpet_charge = s q u a r e _ y a r d s _ p u r c h a s e d * cost_per_square ;
7 return carpet_charge *0.04;
8 // if someone has returned c a r p e t _ c o s t _ p e r _ s q u a r e *0.04 then its fine
too and there will be no deductions
9 }
10 int main ()
11 {
12 float length =16.7 , width =9.1 , c a r p e t _ c o s t _ p e r _ s q u a r e _ y a r d =40 ,
13 di sc ou nt _o n_ ca rp et =34.4 , disco unt_on _labor =20;
14 int s q u a r e _ y a r d s _ p u r c h a s e d ;
15 float carpet_charge ;
16 float tax = amountofcarpet ( length , width , square_yards_purchased ,
17 carpet_cost_per_square_yard , carpet_charge ) ;
18 float labor_cost =22* s q u a r e _ y a r d s _ p u r c h a s e d ;
19 int f loor_p repara tion =200;
20 float subtotal = floor _prepa ration + labor_cost + carpet_charge ;
21 float total = subtotal -( di sc ou nt _o n_ ca rp et + disco unt_on _labor ) ;
22 float total_after_tax = total + tax ;
23 cout < < " ******** Bill ******** " << endl ;
24 cout < < " Square yards purchased : " << square_yards_purchased < < endl ;
25 cout < < " Carpet Cost per square yards : " << c a r p e t _ c o s t _ p e r _ s q u a r e _ y a r d <<
endl ;
26 cout < < " Carpet Charge : " << carpet_charge << endl ;
27 cout < < " Labor : " << labor_cost << endl ;
28 cout < < " Preparation fee : " << fl oor_pr eparat ion << endl ;
29 cout < < " Tax : " << tax << endl ;
30 cout < < " Discount : " << d is co un t_ on _c ar pe t + di scount _on_la bor << endl ;
31 cout < < " Sub Total : " << subtotal << endl ;
32 cout < < " Sub Total Less Discount : " << total << endl ;
33 cout < < " Total ( after adding Tax ) : " << total_after_tax << endl ;
34 return 0;
35 }

You might also like