Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me to draw a flowchart and psedou code for this coding? #include #include //structure to store data about drinks struct Drink{ char

Can someone help me to draw a flowchart and psedou code for this coding?

#include #include

//structure to store data about drinks struct Drink{ char *name; float cost; int quantitiy; };

int main(){ int i,choice; float moneyInserted,totalRevenue=0; struct Drink drinks[5];//structure variable with array size 5 //initializing data drinks[0].name= "CocaCola"; drinks[0].cost = 2.50;drinks[0].quantitiy=5; drinks[1].name= "Pepsi Vanilla"; drinks[1].cost = 2.50;drinks[1].quantitiy=3; drinks[2].name= "Grape Fanta";drinks[2].cost = 2.00;drinks[2].quantitiy=3; drinks[3].name= "Sprite Soda"; drinks[3].cost = 2.00;drinks[3].quantitiy=5; drinks[4].name= "Mineral Water "; drinks[4].cost = 0.90;drinks[4].quantitiy=1; do{ //displays data to the user printf("Drink No DrinkName\t\tCost\t\t quantity "); for(i=0;i<=4;i++){ printf("%d\t",(i+1)); printf("%s\t\tRM %f \t Qty : %d ",drinks[i].name , drinks[i].cost , drinks[i].quantitiy ); } printf("6.\tquit "); printf("Select a drink <1-5> or enter 6 to quit : "); scanf("%d",&choice); //choice is not 6 and the quantity is present then we will ask user to enter money if(choice!=6 && drinks[choice-1].quantitiy>0){ printf("Enter money you want to insert : "); scanf("%f",&moneyInserted); if(moneyInserted<0 || moneyinserted> 1) printf("Can't accept money "); else if(moneyInserted >= drinks[choice-1].cost){ printf("Change : RM %f ",(moneyInserted-drinks[choice-1].cost)); totalRevenue = totalRevenue + drinks[choice-1].cost; drinks[choice-1].quantitiy--; } else printf("Insufficient Funds "); } else if (choice == 6){ printf("Total Revenue : RM %f ", totalRevenue); printf("Drink \t Number Left "); for(i=0;i<=4;i++){ printf(" %s \t %d ",drinks[i].name , drinks[i].quantitiy); } } else{ printf("SORRY, CURRENTLY SOLD OUT! "); } }while(choice!=6); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions

Question

How is the NDAA used to shape defense policies indirectly?

Answered: 1 week ago