write c program to each questions below

rznazna
timer Asked: Nov 29th, 2015

Question Description

1.  Taach Hotel offers accommodation services to customers for fees.  There are two types of accommodation services namely, SUP and DOW which cost Sh.2000 and Sh.1200 per day respectively.  A customer who goes for accommodation for at least 3 days but not exceeding 5 days gets a discount of 20% on accommodation cost. For accommodation of at least 5 days, a customer gets discount of 25% on accommodation cost. There is no discount for accommodation of less than 3 days unless athe customer goes for SUP accommodation service in which case the discount would be 10%. Write a C++ program to input for each customer, name, type of accommodation paid for, and number of days required of accommodation, and to determine and output for each customer, accommodation charge, discount (if any) and net charge. Output should also include total (accumulated) net charges. Net charge is charge less discount. The program should work for any number of customers, and its execution should stop when either “XXX” is entered instead of customer name. The program should use function for determining discount.

2.  ABC deals in 3 kinds of products (X, Y and Z) and has several customers. Write a C++ program to accept for each sale, entries of customer name, type of products purchased by the customer and the number of units of each product.  Prices per unit of the products are sh 50, sh 75 and sh 92 for X, Y and Z respectively. Only purchases of product X any Y attract VAT of 18% of the purchase value. VAT increases amount paid by the customer. Discount is 10% of purchase value for value of at least sh. 10000 charge to a customer. A customer may buy one, two or three types of products. The output for each customer is amount to be paid by the customer.The program should make use of function is determining discount and should run till “X” is entered instead of customer name. At end of execution, the program should output purchase value for each kind of product and the accumulated (total) VAT.

3.  Study the program below and answer the questions that follow.  (The program is numbered for your convenience.  The numbers are not part of it.)

  1. return.CPP
  2. function returns a value
  3. # include <iostream.h>;
  4. float xfun(float);
  5. void main()
  6. {
  7. float shillings dollar;
  8. cout<<” How many shillings? :“;
  9. cin>> shillings
  10. dollars=xfunction(shillings);
  11. cout<<”\nShs. “<<shillings<<”=” <<“ $ “<<dollars;
  12. };
  13. int xfun(float shs);
  14. {
  15. doix = shs/69.5;
  16. return xfunction;
  17. }

  (i)  Explain the purpose of line 3, 5, 15 and 16. 

  (ii)  Identify and correct five errors 

4.  Write a C++ program to determine S given that:

S= +(2/1)-(4/3)+(8/6)-(16/9)+(32/12)- … -(1048576/57)

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors