Question

using C++ make a vending machine that include drinks, snacks etc.. at the end shows me...

using C++ make a vending machine that include drinks, snacks etc.. at the end shows me the final price and also that calculate the tax.

Homework Answers

Answer #1

Programming Language C++ Program for a vending machine.

#include <iostream>
using namespace std;

int main()
{

//variable declaration
int drink = 0;
string more = "y";
float bill = 0.0, cokePrice = 30.0, spritePrice = 42.0, waterPrice = 20, snacksPrice = 60.0, tax = 0.0;
  
while( more == "y" || more == "Y")
{
  
cout << "Your choices of drinks are: " << endl;
cout << "1 - Coke" << endl;
cout << "2 - Sprite" << endl;
cout << "3 - Water" << endl;
cout << "4 - Snacks" << endl;

  
cout << "What drink would you like (1/4): ";
cin >> drink;
cout << endl;
  
switch(drink)
{
case 1 :
cout << "You chose Coke." << endl;
bill = bill + cokePrice;
break;
case 2 :
cout << "You chose Sprite." << endl;
bill = bill + spritePrice;
break;
case 3 :
cout << "You chose Water." << endl;
bill = bill + waterPrice;
break;
case 4 :
cout << "You chose Snacks." << endl;
bill = bill + snacksPrice;
break;
default :
cout << "Invalid Input";
  
}   
cout <<endl<< "Would you like to order more? (Y/N): ";
cin >> more;
}
//calculate tax
tax = (bill * 18) / 100;

//calculate total bill
bill = bill + tax;
cout << endl;
cout <<"total Tax = "<<tax;
cout << endl;
cout <<"Total Bill = "<<bill;
return 0;
}

INPUT:

Your choices of drinks are:                                                                                                     

1 - Coke                                                                                                                        

2 - Sprite                                                                                                                      

3 - Water                                                                                                                       

4 - Snacks                                                                                                                      

What drink would you like (1/4): 1                                                                                               

You chose Coke.                                                                                                                                                                                                                                                 

Would you like to order more? (Y/N): Y                                                                                          

Your choices of drinks are:                                                                                                     

1 - Coke                                                                                                                        

2 - Sprite                                                                                                                      

3 - Water                                                                                                                       

4 - Snacks                                                                                                                      

What drink would you like (1/4): 4                                                                                                                                                                                                                              

You chose Snacks.                                                                                                                   

Would you like to order more? (Y/N): N      

OUTPUT:                                                                                                                                  

Total Tax = 16.2                                                                                                                      

Total Bill = 106.2    

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
You are tasked with evaluating the purchase of a vending machine for the snack room. The...
You are tasked with evaluating the purchase of a vending machine for the snack room. The base price is $4,000 and it would cost another $1,000 to modify the machine to install the machine. The equipment falls in the MACRS 3 year class of depreciation with rates of 33%, 45%, 15% and 7%. The machine would require an investment in snacks (inventory/net operating working capital) of $800. The machine would produce revenue of $3,000 per year with costs of $800...
1. Given a matrix variable "mat", write code using for loops, if statements, etc. that will...
1. Given a matrix variable "mat", write code using for loops, if statements, etc. that will accomplish the same as the following: matsum = sum(mat') Please make sure to store the result in "matsum" and dont use sum. This is what I have so far but it keeps telling me is wrong.... % mat has been initialized for you: mat = randi([-100,100],randi([15,20]),randi([15,20])); % write your statements that accomplish the code above: [r c]=size(mat); for i=1:c matsum=0; for j=1:r matsum=matsum+mat(j,i); end...
** Show all necessary work, and round final answers to three places – all problems can...
** Show all necessary work, and round final answers to three places – all problems can be answered without rounding intermediate steps.** 1. Goodness of Fit – Vending Machines: The Coca-Cola vending machines on the UK campus typically offer six drink options: Coca-Cola, Diet Coke, Coke Zero, Cherry Coke, Mello Yello, and Dasani. Suppose a random sample of 300 credit card transactions at a particular vending machine was taken, and the distribution of drinks sold during those transactions is below....
Differential Analysis for Machine Replacement Kim Kwon Digital Components Company assembles circuit boards by using a...
Differential Analysis for Machine Replacement Kim Kwon Digital Components Company assembles circuit boards by using a manually operated machine to insert electronic components. The original cost of the machine is $54,600, the accumulated depreciation is $21,800, its remaining useful life is five years, and its residual value is negligible. On May 4 of the current year, a proposal was made to replace the present manufacturing procedure with a fully automatic machine that has a purchase price of $113,600. The automatic...
Differential Analysis for Machine Replacement Kim Kwon Digital Components Company assembles circuit boards by using a...
Differential Analysis for Machine Replacement Kim Kwon Digital Components Company assembles circuit boards by using a manually operated machine to insert electronic components. The original cost of the machine is $85,600, the accumulated depreciation is $34,200, its remaining useful life is five years, and its residual value is negligible. On May 4 of the current year, a proposal was made to replace the present manufacturing procedure with a fully automatic machine that has a purchase price of $178,000. The automatic...
Please show all calculations and formulas. If using Excel (or tables), please show data, formulas, etc....
Please show all calculations and formulas. If using Excel (or tables), please show data, formulas, etc. Practice question 14: Calculate the company’s w.a.c.c. using the info below. ***assume this is a corporate bond that pays 2x annually when calculating the PV of the bond Harvey LLC’s capital structure consists of a 25-year bond issued 5 years ago with a coupon of 6% and a par value of $14,000,000. The company’s main competitor just issued a similar bond paying 5%. The...
Kuzzins Fertilizer Inc. is considering buying a machine to produce its new product, the Smelly Spreader....
Kuzzins Fertilizer Inc. is considering buying a machine to produce its new product, the Smelly Spreader. The machine has a 3-year life and a cost of $425,000. This total does not include marketing study costs of $25,000 expensed four months ago. The project will produce sales of $364,000 for each of the 3 years. Cost of the materials and all operations-related expenses to make the final product will be $183,000 each year. The equipment is depreciated over the life of...
Kuzzins Fertilizer Inc. is considering buying a machine to produce its new product, the Smelly Spreader....
Kuzzins Fertilizer Inc. is considering buying a machine to produce its new product, the Smelly Spreader. The machine has a 3-year life and a cost of $425,000. This total does not include marketing study costs of $25,000 expensed four months ago. The project will produce sales of $364,000 for each of the 3 years. Cost of the materials and all operations-related expenses to make the final product will be $183,000 each year. The equipment is depreciated over the life of...
University Inn is planning to replace its washing machine, a major capital expenditure for this year....
University Inn is planning to replace its washing machine, a major capital expenditure for this year. General Manager, John Adams, is reviewing the follow information for decision making. The purchase price of the new washing machine at time 0 = $10,000 Life of the new machine is 10 years (salvage value at the end of year 10 = $0) The new machine is expected to make $25,000 in laundry revenues each year. The expense for operating and maintaining laundry services...
A small factory is considering replacing an existing machine with a newer, more efficient one. Research...
A small factory is considering replacing an existing machine with a newer, more efficient one. Research and development costs associated with the replacement decision were $40,000 last year (2015). The existing machine was purchased three years ago at a cost of $230,000, and it is being fully depreciated according to a 5-year MACRs depreciation schedule. The current book value reflects that the firm has taken three years of depreciation. Because the company actively maintains its machinery and equipment, the CFO...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT