|
-
October 12th, 2005, 08:16 PM
#1
Errors in my program
Hi, I am trying to write my C++ program for my OOP class and my program keeps giving me multiple errors and I am getting really frustrated. My code is pasted below. Can someone please help and give me the corrections? By the way this is the beginning of the class so we have not learned everything yet. This program is based on before even knowing anything about classes, structures, etc.
code(formatting is messed up since I copied and pasted):
Code:
#include <iostream>
using namespace std;
//Collects data for adding/dropping item
void getData(double& regularPrice, double& VIPPrice, double& qty);
//This function adds/drops items
double addDrop(regularPrice, VIPPrice, qty, double& totalAmt, double& totalSavings);
//This function makes a payment
double payment(double& dailyTotal, totalAmt, totalSavings, double& VIP);
//This function dispenses change
double totalChange(double& due, double& paid, double& change);
int main()
{
//variable declarations
int employeeCode, regularPrice, VIPPrice, qty, change_in_cents, dollars, quarters,
dimes, nickels, pennies;
char quit, function;
double totalAmt, totalSavings, VIP, dailyTotal, due, paid, change;
cout<< "Welcome to the POS System of Min's Food!\n";
cout<< "Enter your employee code:";
cin>> employeeCode;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
dailyTotal = 0;
VIP = false, totalAmt = 0, totalSaving = 0;
//repeatedly process transactions
do
{
cout<< "Function:";
cin>> function;
switch(function){
case 'a':
case 'A':
getData(regularPrice, VIPPrice, qty);
addDrop(regularPrice, VIPPrice, qty, totalAmt, totalSavings);
break;
case 'd':
case 'D':
getData(regularPrice, VIPPrice, qty);
addDrop(regularPrice, VIPPrice, qty, totalAmt, totalSavings);
break;
case 'v':
case 'V':
VIP = true;
break;
case 'p':
case 'P':
payment(dailyTotal, totalAmt, totalSavings, VIP);
break;
default:
cout<< "Please enter correct function(A,D,V,P)!/n";
}
do
{
cout<< "Do you want to quit the program(Y/N)?:";
cin>> quit;
quit = toupper(quit);
}while (quit != 'Y' && quit != 'N');
}while (quit != 'Y');
cout<< "Cashier:" << employeeCode << "Your total sales today are $"
<< dailyTotal << endl;
cout << "Thank you for using the program. Good Bye!";
return(0);
}
void getData(regularPrice, VIPPrice, qty)
{
cout<< "Regular Price:";
cin>> regularPrice;
while(regularPrice < 0)
{
cout << "VIPPrice:";
cin>> VIPPrice;
if(regularPrice < 0)
cout << "Please enter a non-negative number";
cout << "Regular Price:";
}
while(VIPPrice < 0)
{
cout << "Quantity:";
if (VIPPrice < 0)
cout << "VIP Price shouldn't be higher than regular price!";
}
}
double addDrop(regularPrice, VIPPrice, qty, totalAmt, totalSavings);
{
totalAmt = totalAmt + qty * Price;
totalSavings = totalSavings + (regularPrice - VIPPrice)* qty;
return 0;
}
double payment(dailyTotal, totalAmt, totalSavings, VIP);
{
if(VIP=true)
due = totalAmt - totalSavings;
else
due = totalAmt;
dailyTotal = dailyTotal + due
cout << "Amount Due:";
cin >> due;
cout << "Amount Paid:";
cin >> paid;
while(paid < due)
{
change = paid-due;
change_in_cents = static_cast<int>(change * 100 + 0.5);
//+ 0.5 because of precision problems.
dollars = change_in_cents/100;
change_in_cents -= dollars * 100;
quarters = change_in_cents/25;
change_in_cents -= quaters * 25;
dimes = change_in_cents/10;
change_in_cents -= dimes * 10;
nickels = change_in_cents/5;
change_in_cents -= nickels * 5;
pennies = change_in_cents;
cout << "Your change:" << dollars << "dollars"
<< quarters << "quarters"
<< dimes << "dimes"
<< nickels << "nickels"
<< pennies << "pennies." << endl;
Last edited by Ejaz; October 12th, 2005 at 11:59 PM.
Reason: Code tag added
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|