AP Create Task PDF
AP Create Task PDF
#include <iomanip>
#include <string>
//Functions
int menu();
int items(int);
int age();
int repeat();
int giftCard();
int main() {
//Declaration Block
int itemNo;
bool cont = 1;
bool orderAgain = 1;
bool seniorDiscount = 0;
cout << "Please enter the price of the item you wish to buy (ex. 5.99): ";
seniorDiscount = age();
if(seniorDiscount > 0) {
orderAgain = repeat();
itemPrice = 0.00;
finalPrice = totalPrice;
gift = giftCard();
finalPrice = finalPrice - gift;
"------------------------------------------------\n"
"Total of all items:" << " $" << setprecision (2) << fixed << totalPrice << endl;
if (ageDiscountTotal > 0) {
cout << "Total senior discounts:" << " -$" << setprecision (2) << fixed
<< ageDiscount << endl;
cout << "Taxes:" << " +$" << setprecision (2) << fixed << tax
<< endl;
if (gift > 0) {
cout << "Gift card amount applied:" << " -$" << setprecision (2) << fixed << gift
<< endl;
"Bill:" << " $" << setprecision (2) << fixed << finalPrice <<
endl;
system("pause");
return 0;
}
//Asks the user their age to determine if the age discount should be applied
int age()
bool ageDiscount = 0;
int ageLoop = 1;
ageDiscount = 1;
ageDiscount = 0;
} else {
cout << "Invalid choice. Are you 65 years old or older (Y or N)? ";
ageLoop = ageLoop + 1;
}
return ageDiscount;
//Asks the user for if they want another item until they say no
int repeat()
bool orderAgain = 0;
int orderLoop = 1;
cout << "Would you like to order another item (Y or N)? ";
orderAgain = true;
orderAgain = false;
} else {
cout << "Invalid choice. Would you like to order another item (Y or N)? ";
orderLoop = orderLoop + 1;
return orderAgain;
int giftCard()
bool giftDiscount = 0;
int giftLoop = 1;
giftDiscount = true;
cout << "How much money would you like to apply from card? (ex. 5.99): ";
cin >> giftAmount;
giftDiscount = false;
} else {
cout << "Invalid choice. Do you have a gift card (Y or N)? ";
giftLoop = giftLoop + 1;
return giftAmount;