It wont display the order total
// JumpinJava.cpp - This program looks up and prints the names and prices of coffee orders.
// Input: Interactive
// Output: Name and price of coffee orders or error message if add-in is not found
#include
#include
using namespace std;
int main()
{
// Declare variables.
string addIn; // Add-in ordered
const int NUM_ITEMS = 5; // Named constant
// Initialized array of add-ins
string addIns[] = {"Cream", "Cinnamon", "Chocolate", "Amaretto", "Whiskey"};
// Initialized array of add-in prices
double addInPrices[] = {.89, .25, .59, 1.50, 1.75};
bool foundIt = false; // Flag variable
int x; // Loop control variable
double orderTotal = 2.00; // All orders start with a 2.00 charge
// Get user input
cout <>
cin >> addIn;
// Write the rest of the program here.
while(addIn != "XXX") //loop until user enters XXX
{
bool foundIt = false; //before searching intializes found it as False
x = 0;
while (x < num_items) { > num_items) { >
if (addIn == addIns[x]) {
foundIt = true; //if match is found
orderTotal = orderTotal + addInPrices[x]; //add price of the item to the total
cout <><><><><>< endl; > endl; >
}
x++;
}
if(!foundIt){ //if item not found
cout <><>
}
cout <><>
cin >> addIn;
}
cout <><>< endl; > endl; >
cout <><>
return 0;
} // End of main()
Extracted text: Checks Test Case • Incomplete Test for valid flavors Input Cream Whiskey XXX Output Enter coffee add-in or XXX to quit: Cream The price of Cream is 0.89. Enter coffee add-in or XXX to quit: Whiskey The price of Whiskey is 1.75. Enter coffee add-in or XXX to quit: XXX Order total: 4.64 Вye! Results .89 |1.75 Order Total is $4.64 Show Details >