The practical exercise for this session will be to create a cash register program that you input the cost of an item, the number purchased and if a sales tax applies to the item. If a tax does apply to the item, the tax value will be ten percent of the items cost.

In the example, the bread costs $2, it does not have sales tax on it, so its final price is $2. The shirt on the other hand, has a cost of $20, and does have tax on it, so ten percent of 20 is 2, making the final price of the shirt $22.00. The program will then calculate the cost of all the items. This will be in a loop so that a number of different items can be inputed and when finished the program it will produce a grand total.

here is my code so far

// iostream is needed for this cout statement.
#include <iostream>
#include <cstdlib>
using namespace std;

// functions in program
float total = 0.0;
float grandtotal = 0.0;
float rrp = 0.0;
float taxinc = 0.0;
float subtotal = 0.0;
//float numberpurchd = 0;
//float num = 0;

//void item();
//float numberpurch();
//float orig();
//float tax();
//float totals();
char itemn;
int rrpd;
int numberpurchd;
char ans;

/*
* The main function is the starting point for the program. It contains all of
* the statements in this program.
*/
int main()
{
char itemn;
// char rrpd;
char ans;
char response;

cout << "Cash Register Program\n\n";
do{
cout << "Item: ";
cin >> itemn;
cout << "How Many Item being purchased: ";
cin >> numberpurchd;
cout << "Input original Price: $";
cin >> rrpd;
// num = rrp * rrpd;
rrp = rrpd * numberpurchd;
cout << "Before GST: $" << rrp << endl;

cout << "Does GST apply to item (t = yes or f = no): ";
cin >> ans;

switch(ans)
{
case 't':
// taxinc;
//taxinc = (rrp * 10 / 100);
taxinc = rrp * (.10/100);
break;
rrp;
case 'f':
break;
} // close switch

// taxinc = (rrp * GST);
cout << "Total including GST: $" << taxinc << endl;
subtotal = taxinc + rrp;
cout << "Complete Subtotal including GST: $" << subtotal << endl;
total = subtotal + total;
cout << "Next item? y = yes or n = no: ";
cin >> response;
}while(response != 'n'); // close do loop


grandtotal = total ;

cout << "Total Amount: $" << grandtotal << endl;
cout << "Thank You for ordering and Have a nice day!" << endl;

system("PAUSE");
return 0;
} // close main function

help would be appreciated

So do you have a specific question or are you asking for me to do your homework for you?

no its not home work, i am actually stuck on this,
1. is when inserted for rrp price 1.20 doesn't work and its has now since gone weird in the loop section.

1.20 is not an "int"
Change "int" to "double"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.