Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone please check my code because everytime i enter y it keeps prompting me the message please enter your choice (y, n or q)

can someone please check my code because everytime i enter y it keeps prompting me the message please enter your choice (y, n or q) instead of saying great choice goodbye for y

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

#include

char GetInput(void){ /* while this is true. It asks user to input a choice of y, n, or q. If statement checks whether input is y, n, or q. If user inputs a y, n, or q, then it would break out of while loop; Otherwise it would continue to ask the user to print one of the three letters */ while(1){ char input; printf("Please enter your choice (y for yes, n for no, q for quit) "); scanf(" %c", &input); if (input=='y' || input=='n' || input=='q'){ return input; //break; } } } /* while this is true. It asks user if they want an upgrade, keeps printing this message unless they input yes. Once they enter yes the while loop breaks */ void SellUpgrade(int q_limit, int mbps, int mbps_increase, int price, int price_increase){ while(1){ printf("You are eligible for a limited time offer. You can get %d megabits per second for the low promotional rate of $%d a month. Act now while supplies last. ", mbps, price); char x=GetInput(); // x is now getInput int count=0; //sets initial count to 0 if(x=='y'){ //if user inputs y, then it prints the message printf("Great choice. Goodbye. ", x); break; } if(x=='n' || x=='q'){ // if user inputs n or q it continues to print the service upgrade message return; } if (x=='q'){ count++; // increases count if(count>q_limit){ return; } } } } void PayBill(void){ printf("We already have your credit card information and have charged you.Thanks for being a loyal customer! "); }

int main (){ int choice; // user has option to choose 1-4 printf("Welcome to Cablecom! Please make a choice from the following options: "); //opening menu printf("1) Change your password "); printf("2) Cancel your service "); printf("3) Schedule a service call "); printf("4) Pay your bill "); scanf("%d", &choice); if (choice!=1 && choice!=2 && choice!=3 && choice!=4){ // if choice is not between 1 and 4 printf("Please enter a number between 1 and 4. "); // prints the statement if choice is not between 1 and 4 scanf("%d", &choice); //user inputs a choice and feeds it into choice } else if (choice==1){ SellUpgrade(2, 10, 1, 50, 1); } else if (choice==2){ SellUpgrade(5, 100, 10, 80, 20); } else if (choice==3){ SellUpgrade(5, 40, 5, 60, 10); } else if (choice==4){ PayBill(); } return 0; }

You work for a cable company and are designing a software system to automate the customer service system. Your system is archaic, so you can only read in the inputs 1 through4, y n and from your user (the current customer) When your program begins, display the following menu to the user: [prompt]$ ./customer_experience Welcome to CableCom! Please make a choice from the following options: 1) Change your password 2) Cancel your service 3) Schedule a service call 4) Pay your bill For simplicity (to avoid this bug) assume the user always enters a number. If the user enters an incorrect number at the start of the program, print Please enter a numberbetween 1 and 4. and use scanf to obtain another input. WARNING: On the CSIF computers, if you type 3 and then hit enter, there are actually two inputs in the stdin buffer, not one. The buffer contains the character3, and the characterin, (a newline). You must call getchar to clear the buffer

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

More Books

Students also viewed these Databases questions

Question

Describe how data could be transmitted using amplitude modulation.

Answered: 1 week ago

Question

How many three-digit numbers are divisible by 7?

Answered: 1 week ago

Question

What is Indian Polity and Governance ?

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago