Question: *HELP ME CREATE/DESIGN A FLOWCHART FOR THIS C++ CODING* *PLEASE CREATE/DESIGN IT NEATLY AND COMPLETE* *I WILL DOWNVOTE IF I DONT UNDERSTAND THE ANSWER* *THE

*HELP ME CREATE/DESIGN A FLOWCHART FOR THIS C++ CODING*

*PLEASE CREATE/DESIGN IT NEATLY AND COMPLETE*

*I WILL DOWNVOTE IF I DONT UNDERSTAND THE ANSWER*

*THE CODING IS ABOUT VENDING MACHINE MANAGEMENT SYSTEM*

#include #include #include #include using namespace std;

//define structure drinkinfo struct drinkinfo { char name[20]; //name of drink float price; //price of drink int quantity; //quantity Available };

//zero argument function of showDetails void showDetails() { cout << "Cola" << endl; cout << "Root Beer" << endl; cout << "Lemon Lime" << endl; cout << "Grape Soda" << endl; cout << "Cream Soda" << endl; }

//main function int main() { //1D array of structure //ARRAY data structure to implement this program drinkinfo drink[4]; //defining variable of structure

//copy drink details into the array variable strcpy(drink[0].name,"Cola"); drink[0].price = 0.65; drink[0].quantity = 30; strcpy(drink[1].name,"Root Beer"); drink[1].price = 0.70; drink[1].quantity = 30; strcpy(drink[2].name,"Lemon Lime"); drink[2].price = 0.71; drink[2].quantity = 30; strcpy(drink[3].name,"Grape Soda"); drink[3].price = 0.82; drink[3].quantity = 30;

std::cout << std::fixed; std::cout << std::setprecision(4); int choice = 1; //variable for taking the choice

//loop to execute and display menu iteratively //LOOP while(choice != 5){ //menu display cout << " 1) "<< drink[0].name << "\t\t" << drink[0].price << "\t(" << drink[0].quantity << ") remaining"; cout << " 2) "<< drink[1].name << "\t\t" << drink[1].price << "\t(" << drink[1].quantity << ") remaining"; cout << " 3) "<< drink[2].name << "\t\t" << drink[2].price << "\t(" << drink[2].quantity << ") remaining"; cout << " 4) "<< drink[3].name << "\t\t" << drink[3].price << "\t(" << drink[3].quantity << ") remaining"; cout << " 5) Leave the drink machine "; cout << " Choose one:"; cin >> choice; //INPUT FROM USER

//if choice is between 1 to 4 if(choice >= 1 && choice <= 4) { if(drink[choice - 1].quantity == 0) { cout << " No more " << drink[choice - 1].name << " Available .."; getchar(); getchar(); continue; } } //if choice is 5, then exit if(choice == 5) cout << "Thank for using it !!"; else if(choice <= 4) { float money; cout << " Enter any amount of money: "; cin >> money;

float price; if(choice >= 1 && choice <= 3) { price = .75; if((money < price)) { cout << " Enter sufficient amount "; getchar(); getchar(); continue; } } else if(choice == 4) { price = .80; if((money < price)) { cout << " Enter sufficient amount "; getchar(); getchar(); continue; } } cout << " Enjoy your beverage, Have a nice day and SODA SODA :) "; cout << " Change calculated : " << money - price; cout << " You change, "< drink[choice - 1].quantity = drink[choice - 1].quantity - 1; cout << " There are " << drink[choice-1].quantity <<" drinks of that type left"; getchar(); getchar(); } //if choice not match then we display error type message else { cout << " Please enter the right choice !!! "; } } return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!