Question
Asked by:
omerres75
omerres75
Rating : No Rating
Questions Asked: 6
Tutorials Posted: 0
 

$4.00 Happy Hacker 3

Q:
Use the following functions :

main ( ) should be few lines (i.e. calling the other functions)

customer_info ( )

purchase_discount ( )

age_discount ( )

lucky_num_discount ( )

rebate ( )

sales_tax ( )

display_invoice ( )


The HAPPY HACKER Discount Computer Store has a rather unique discount policy which is as follows:

(1) If a customer's total purchases before sales tax is greater than $100 but less than $200 then a 10% discount will be applied. If a customer's total purchases before sales tax is at least $200 but less than $500 then a 15% discount will be applied. If a customer's total purchases before sales tax is at least $500 then a 20% discount will be applied.

(2) The proprietor is sympathetic to the financial plight of students and senior citizens on a fixed income, therefore an additional discount of 8% will be applied to a customer's net purchases after the initial discount described in [1] has been applied if the customer's age is less than 20 or greater than 60.

(3) The store identifies customers by using an ID number derived from the last four digits of the social security number. The proprietor is somewhat superstitious and considers the number '7' lucky, therefore if the customer's ID number contains a '7'
or is divisible by '7' an additional discount of 7% will be applied to a customer's net purchases after the initial discounts described in [1] and [2] have been applied.

(4) The Happy Hacker Computer Store is appalled by the un- bridled use of credit in the United States today. In an effort to encourage responsible buying, customers making purchases with cash or check rather than credit will receive a rebate equal to 6% of the net purchases (after discounts [1],[2],and [3] have been applied).

(5) A sales tax of 7.85% is charged on the net purchases (after all discounts excluding the rebate).


The generated invoice should be similar to the following:

HAPPY HACKER DISCOUNT COMPUTER CO.

CUSTOMER ID: 1237 CUSTOMER AGE: 35 PAID BY: CASH

TOTAL PURCHASES ............................ $ 478.25

PURCHASE DISCOUNT (15%) ........ $ 71.74
AGE DISCOUNT ( 0%) ........ $ 0.00
LUCKY NUM DISCOUNT ( 7%) ........ $ 28.46

TOTAL DISCOUNT APPLIED (21.0%) ............. $ 100.20


NET PURCHASES .............................. $ 378.05
SALES TAX (7.85%) .......................... $ 29.68
-------------------------------------------------------
TOTAL COST ................................. $ 407.73
===============================================================
CASH REBATE ................................ $ 22.68

( THANKS FOR SHOPPING WITH THE HAPPY HACKER )




 


   
   
   
   
Lorraine1994 asked: Please be more specific on what you need, such as I need a program for this or what ever, thanks.
To which omerres75 said: i need a C+++ program on that.
 
Available Tutorials to this Question
Posted by:
rainman
rainman
Rating (40): A+
Questions Asked: 2
Tutorials Posted: 174, earned $906.64
 

$20.00 Happy Hacker. Displays An Invoice As Described, Commented, Compiled, Tested.

  • This tutorial was purchased 1 time and hasn't been rated yet.
  • Posted on Feb. 17, 2009 at 03:05:04AM
A:
Preview: ... <br><br>//we don't need to pass customer by reference because the rebate<br>//isn't really applied to the amount he owes, it is given back<br>//at the end.<br>double rebate(Customer c)<br>{<br> if (c.paytype == "CASH")<br> return c.owed*0.06;<br><br> return 0.0;<br>}<br><br>//calculate the tax owed and then add it to the amount owed<br>double sales_tax(Customer &c)<br>{<br> double tax = (7.85/100.0) * c.owed;<br> c.owed += tax;<br> return tax;<br>}<br><br>void display_invoice(Customer c)<br>{<br> double initial = c.owed;<br> double discount = 0.0;<br> double totaldiscount = 0;<br><br> cout << endl << endl;<br> cout << "INVOICE" << endl;<br> cout << "------------------------------------" << endl << endl;<br><br> cout << "HAPPY HACKER DISCOUNT COMPUTER CO." << endl << endl;<br><br> cout << "CUSTOMER ID: " << c.id << " ";<br> cout << "CUSTOMER AGE: " << c.age << " ";<br> cout << "PAID BY: " << c.paytype << endl << endl;<br><br> //only display 2 digits after the decimal<br> cout.precision(2);<br> cout.setf(ios::fixed);<br><br> cout << "TOTAL PURCHASES ................. $ " << c.owed << endl << endl;<br><br> cout << "PURCHASE DISCOUNT (" << purchase_discount(c, discount) << "%) ...... $ ";<br> cout << discount << endl;<br><br> totaldiscount += disco ...

The full tutorial is about 1435 words long plus attachments.

Attachments:
main.cpp (5K)
   
Join Now or Log In
Get Tutoring
Get Paid
Academic Honesty