this code for school is really really bugging me. these errors are confusing the hell out of me. someone please give me some help!! i use codewarrior learning edition.. not sure what version though, anyway here it is:
// This program is used to compute the amount due from a
// customer of the Gas-N-Clean Service Station. Constants
// are used for gasoline prices. Note the use of nested
// selection to compute the cost of the car wash.
// Program file: gas.cpp
#include <iostream.h>
#include <iomanip.h>
const double REGULAR_PRICE = 1.149;
const double PLUS_PRICE = 1.199;
const double SUPER_PRICE = 1.289;
// Function: printHeading
// Prints a signon message for program
void printHeading();
// Function: getData
// Get information interactively from the keyboard.
// Outputs: number of gallons purchased, type of gasoline
// a choice as to whether a car wash is desired
void getData(double &numGallons, char &gasType, char &washOption, char &washType);
// Function: computeCharges
// Computes the gas cost, wash cost, and total cost
// Inputs: number of gallons, gas type, wash option
// Outputs: gas cost, wash cost, total cost
void computeCharges (double numGallons, char gasType, char washOption, double &gasCost, double &washCost, double &totalCost);
// Function: printMessage
// Prints a sign-off message for program
void printMessage();
// Function: printResults
// Print the results
//
// Inputs: number of gallons purchased, type of gasoline,
// gas cost, wash cost, total cost
void printResults (double &numGallons, char &gasType, double &gasCost, double &washCost, double &totalCost);
int main()
{
char gasType; //Type of gasoline purchased (R,P,S,N)
char washOption; // Character designating option (Y,N)
char washType; // Type of wash (S,D)
double numGallons; // Number of gallons purchased
double gasCost; // Computed cost for gasoline
double washCost; // Car wash cost
double totalCost; // Total amount due
getData(numGallons, gasType, washOption, washType);
computeCharges(numGallons, gasType, washOption, gasCost, washCost, totalCost);
printResults(numGallons, gasType,
gasCost, washCost, totalCost);
return 0;
}
void printHeading()
{
cout<< setiosflags(ios::right) << endl;
cout<< setw(55)
<< "****************************************"
<< endl;
cout<< setw(55)
<< "* Gas-N-Clean Service Station *"
<< endl;
cout<< setw(55)
<< "* *"
<< endl;
cout<< setw(55)
<< "* July 25, 1997 *"
<< endl;
cout<< setw(55)
<< "* *"
<< endl;
cout<< setw(55)
<< "***************************************"
<< endl;
cout<< endl;
}
void getData(double &numGallons, char &gasType, char &washOption, double &washType)
{
cout<< "Enter number of gallons and press <Enter>. ";
cin>> numGallons;
cout<< "Enter gas type (R, P, S, or N) and press <Enter>. ";
cin>> gasType;
cout<< "Enter Y or N for car wash and press <Enter>. ";
cin>> washOption;
cout<< "Enter either S (Standard) or D (Deluxe) and press <Enter>. ";
cin>> washType;
}
void computeCharges(double numGallons, char gasType, char washOption, double &gasCost, double &washCost, double &totalCost, double &washType)
{
switch (gasType)
{
case 'R': gasCost = numGallons * REGULAR_PRICE;
break;
case 'P': gasCost = numGallons * PLUS_PRICE;
break;
case 'S': gasCost = numGallons * SUPER_PRICE;
break;
case 'N': gasCost = 0.0;
}
if (washOption == 'Y')
if (washType == 'S')
if (gasCost >= 10.0)
washCost = 3.0;
else
washCost = 5.0;
if (washOption =='Y')
if (washType == 'D')
if (gasCost >= 10.0)
washCost = 6.0;
else
washCost = 8.0;
totalCost = gasCost + washCost;
}
void printMessage()
{
cout << endl;
cout << setw(48) << "Thank you for stopping" << endl;
cout << endl;
cout << setw(43) << "Please come again" << endl;
cout << endl;
cout << setw(55)
<< "Remember to buckle up and drive safely"
<< endl;
cout << endl;
}
void printResults(double numGallons, char gasType, double gasCost, double washCost, double totalCost)
{
printHeading();
cout << setiosflags(ios::fixed | ios::showpoint);
cout << setw(43) << "Amount of gasoline purchased "<< setw(12) << setw(6) << setprecision(3) << numGallons << " Gallons" << endl;
cout << setw(31) << "Price per gallon" << setw(22) << "$";
switch (gasType)
{
case 'R': cout << setw(7) << REGULAR_PRICE <<endl;
break;
case 'P': cout << setw(7) << PLUS_PRICE <<endl;
break;
case 'S': cout << setw(7) << SUPER_PRICE <<endl;
break;
case 'N': cout << setw(7) << 0.0 <<endl;
}
cout << setw(34) << "Total gasoline cost"
<< setw(19) << "$"
<< setw(6) << setprecision(2) << gasCost
<< endl;
if (washCost > 0)
cout << setw(28) << "Car wash cost"
<< setw(25) << "$"
<< setw(6) << washCost << endl;
cout << setw(31) << "Total due"
<< setw(22) << "$" << setw(6)
<< totalCost << endl;
printMessage();
}
i just need the errors debugged, thats all. someone, anyone!