Begginner [C Programming] Question home / study / engineering / computer science
ID: 3847644 • Letter: B
Question
Begginner [C Programming] Question
home / study / engineering / computer science / questions and answers / assignment description rite a c program called ...
Your question has been answered
Let us know if you got a helpful answer. Rate this answer
Question: Assignment Description rite a C program called "po...
Bookmark
Begginner [C Programming] Question
Sample Example
Assignment Description rite a C program called "pop" which simulates the operation of a soft drink vending machine. Your program should meet the following requirements. The user running the program will simulate both service and customer actions Service/Maintenance Requirements set the selling price range 30 to $1.05) from a command line argument cents only provide a specific message (as in sample below for the following error cases and return to the operating system o command line argument is missing o prices out of range o price not a multiple of 5 with a valid selling price, put machine in-service for continual sales (See Customer Requirements as a maintenance action hidden from menu), allow service person to shutdown exit the program altogether at the coin prompt by pressing E or e; refund any pending amountExplanation / Answer
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,x,d,m=0;
char c;
clrscr();
printf("welcome to my c pop Machine pop is 50 cents. Please insert any combination of Nickel(N or n)or dime(D or d) or quar");
printf(" Enter coin(NDQR)");
scanf("%c",&c);
while(c!='E'||c!='e')
{
if(c=='n'|| c=='N')
{
printf(" Nickel detected.");
m=m+5;
}
else if(c=='d'||c=='D')
{
printf(" Dimes Detected");
m=m+10;
}
else if(c=='q'||c=='Q')
{
printf(" Quater detected");
m=m+25;
}
else if(c=='R'||c=='r'||c=='e'||c=='E')
{
d=m/10;
n=(m%10)/5;
printf("Change given as %d cent as %d %d",m,d,n);
break;
}
else
{
printf(" unknown coin detected");
}
if(m>=50)
{
printf(" You have inserted a total of %d cents",m);
printf(" Pop has dispensed");
printf(" Thank You for Business. Come again");
}
else if(m<50)
{
x=50-m;
printf(" Please insert %d more cents",x);
}
printf(" Enter coin(NQDR):");
scanf("%c",&c);
}
printf("Good bye");
getch();
}
The above program returns when you enter r or E.All the constrains mentioned in the questioons will be satisfied by the above program.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.