I'm new to this and cannot get the program to execute... Any help would be appreciated.
Trying to write a program that will use functions to calculate and display the final price of three purchases. For each price the program should get the initial value from the user, adjust it with the appropriate discount, add taxes and then display the final cost using functions. Three prices are processed in the following way. The initial price value should be from 10 to 1000 dollars (use a loop for input validation.) The rate of the discount should be10% on a price under $200, 15% on a price from $200 up to but not including $500, and 20% on a price of $500 or above. The rate of taxes should be 5.5%.
***************************************************************
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
double initialprice (double &price);
{
cout << "Enter an amount to process for discounts. This must be between 10 and 1000." << endl;
cin >> price << endl;
while (price > 1000 || price < 10);
{
cout << "The discount is..." << endl;
}
cout << "Please re-run the program and enter a value BETWEEN 10 and 1000." << endl;
}
double discount (double &price);
{
if (&price < 200)
{
cout << "Initial Price" << price << endl;
cout << price * 0.9 << endl;
}
if else (&price >= 200 || &price < 500);
{
cout << "Initial Price" << price << endl;
cout << price * 0.85 << endl;
}
if else (&price >= 500);
{
cout << "Initial Price" << price << endl;
cout << price * 0.8 << endl;
}
else;
{
cout << "There is no discount for your item, or you entered an invalid price." << endl;
}
}
Your code doesn't execute because you have compile errors.
Line 10: main() must be type int.
Line 18,31: Extraneous ;
Line 23: This while loop does nothing. The ; terminates the loop.
Line 33,38,43: You're comparing the address of price. Get rid of the &.
Line 38,43: The ; terminates the if statement. The following statements will be executed unconditionally.
Line 43: The ; terminates the else. The following cout will be executed unconditionally.
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.