basic cashier program for c++

What is the correct answer for this program? Kinda new to programming. I need help.

Program Description:
Cashier 1.0 is a C++ program that displays on the screen “Sweet and minty Lollipops! How many would you want to buy?” Then, the user enters the quantity. Moreover, it displays the text, “You have bought [quantity] Sweet and minty Lollipops! Please pay, PhP [Amount due]. ” Then, the user will enter the amount of cash. Finally, it will display a summary of the transaction by displaying the amount due, VAT (12%), VATable amount, amount of cash and the change.

Each lollipop costs PhP 5.00.

//for example you bought 7 lollipops




Sample Run:
Sweet and minty Lollipops! How many would you want to buy? 7
You have bought 7 Sweet and minty Lollipops! Please pay PhP 35.00.

Please examine the transaction details below: (this transaction detail should display on the program)

Amount Due(VAT VAT(12%): PhP 35.00
VAT(12%): PhP 3.75
VATable Amount: PhP 31.25
Amount of Cash: PhP 100.00
Change: PhP 65.00

“Thanks and enjoy your lollipops!"




This is my program, it produces garbage value and its not complete. Its wrong.

#include <iostream>
using namespace std;
int main()

{
//declarations
double Price = 5;
int i;
double AmountDue;
double VatableAmount;

float VatRate = 0.12;

cout<<"Welcome to Minty Lollipops!"<<endl;
cout<<"Sweet and minty Lollipops! How many would you want to buy?"<<endl;
cin>>i;
cout<<"You have bought"<< i <<"Minty Lollipops"<<"Please pay"<< VatableAmount <<endl;

int AmountofCash;
cout<<"Enter Amount of Cash"<<endl;
cin>> AmountofCash;

AmountDue = i*Price;
VatableAmount = (i*Price)*VatRate;
double change;
change = VatableAmount - AmountofCash;

return 0;
}
After you have the user input the 'i' value, you need to calculate the VatableAmount

You need to move VatableAmount = (i*Price)*VatRate; to right after cin>>i



This is my changed program. The AmountDue does not produce the right value. What do you think is wrong?

#include <iostream>
using namespace std;
int main()

{
//declarations
double Price = 5;
int i;
long double AmountDue;
double VatableAmount;
double Vat;
Vat = Price*0.12;

double VatRate = 0.12;
//AmountDue = i*Price;

cout<<"Welcome to Minty Lollipops!"<<endl;
cout<<"Sweet and minty Lollipops! How many would you want to buy?"<<endl;
cin>>i;
AmountDue = ((i*Price)*VatRate)+Price;
VatableAmount = AmountDue-Vat;
cout<<"You have bought"<< i <<"Minty Lollipops"<<"Please pay"<< AmountDue <<endl;

int AmountofCash;
cout<<"Enter Amount of Cash"<<endl;
cin>> AmountofCash;


double change;
change = AmountofCash - VatableAmount;
cout<<"Amount Due(VATinclusive): "<< AmountDue <<endl;
cout<<"VAT(12%): "<< Vat <<endl;
cout<<"VATable Amount: "<< VatableAmount <<endl;
cout<<"Amount of Cash: "<< AmountofCash<<endl;
cout<<"Change: "<< change<<endl;

cout<<"Thanks and Enjoy our lollipops!"<<endl;

return 0;
}
you changed your amount due... it should be what you had in the first post
AmountDue = i*Price


Also, check all you equations, I don't think any of them are going to give you the values you want.
Topic archived. No new replies allowed.