CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c that implements the following features. Implement this program in stages using stepwise refinement to ensure that it will compile and run as you go. This makes it much easier to debug and understand. This program presents the user a menu of operations that it can perform. The choices are listed and a prompt waits for the user to select a choice by entering a number. This kind of menu is a common feature of command-line programs. It can be implemented to execute in the main() function or it can be implemented in a function known as the commandchooser function that returns a numeric value for a choice that can be passed to another function known as the command-dispatcher. 1. Define symbolic constants for FALSE and TRUE 2. Define an int main() function • int done = FALSE; is a flag defined inside int main and used to determine if the user has finished using the program or not. 3. while-loop not done • Loop while the done flag is equal to false /* command chooser */ 4. Implement printf() statements which list menu choices • The first part of the command chooser prints a menu that lists choices for the user. Each choice is a string that begins with the value to be entered on the keyboard to make the choice and ends with a brief description of an operation. • Example: “3 - Operation 3” 5. Next, implement a do-while loop with the result of the scanf() function part of the while condition. • scanf()returns an integer whenever it is called usually this value is not important, but for the command chooser it is essential. • If an improper value was input, scanf() will return a value less than 1. This allows us to create a do-while loop which validates the users input. • See Formatted I/O lecture slides for an example 6. Once implemented, place the printf() statements from step 4 into the do-while loop body. /* command dispatcher */ 7. Implement if else logic where each logical branch corresponds to a menu choice. 8. One choice must set done TRUE. • The command choice to exit the program sets the done flag to TRUE • HINT: This implies one of the menu choices must be to quit the application. If the quit choice was chosen, setting the done flag to TRUE prevents any further action from being taken. 9. All other choices are program operations • All other command choices perform an operation either inline or by calling a function with or without arguments. • For this lab, all command choices should simply printout which operation was selected. No external methods need to be called. 10. Default case prints invalid choice message • The scanf() logic cannot stop all invalid choices, but an else statement of the if else logic can catch the others and print a message. 11. After executing the users chosen command, the while-loop will then continue prompting the user to select an operation or to quit. 12. At the end of the while-loop print “Goodbye” to the console Once completed, please submit lab8.c to Blackboard. An example of this programs expected output is attached below. 1 - Operation 1 2 - Operation 2 3 - Operation 3 4 - Operation 4 5 - Quit 3 //user inputted value Doing operation 3 1 - Operation 1 2 - Operation 2 3 - Operation 3 4 - Operation 4 5 - Quit 1 //user inputted value Doing operation 1 1 - Operation 1 2 - Operation 2 3 - Operation 3 4 - Operation 4 5 - Quit 5 //user inputted value Goodbye
Please find the program below:
lab8.c
#include<stdio.h>
#include<conio.h>
const int FALSE = 0;
const int TRUE = 1;
int main() {
int done = FALSE; // Setting done to false as user is
not done entering choice yet
int ch;
while(!done) { // Looping until not done
do {
// Printing the
Menu of choices (command chooser)
printf("1 -
Operation 1\n");
printf("2 -
Operation 2\n");
printf("3 -
Operation 3\n");
printf("4 -
Operation 4\n");
printf("5 -
Quit\n");
printf("Enter
your choice: ");
} while(scanf("%d", &ch) <
1); // Checking if the input choice is valid
// Printing the corresponding
choive chose by the user (command dispatcher)
if (ch == 1) {
printf("Operation 1 is Selected\n");
} else if (ch == 2) {
printf("Operation 2 is Selected\n");
} else if (ch == 3) {
printf("Operation 3 is Selected\n");
} else if (ch == 4) {
printf("Operation 4 is Selected\n");
} else if (ch == 5) {
done = TRUE; //
Quitting the program
break;
} else {
printf("Invalid
choice\n");
}
}
printf("Good Bye...");
return 1;
}
Sample Output:

CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c...
***C++ Program ONLY*** Menu driven program First load an array(lists) with the values 3, 4, 84, 5, 2, 47, and 7 in this order Then sort the array(list) Create a program with a menu, with choices 1 for factorial (single value, which everyone will use 20!), 2 for median value , 3 for average, 4 for maximum, 5 for minimum, and 6 to end the program. Use a do loop (not while) Python does not have a Do loop, so...
***C++ ONLY*** Menu driven program First load an array(lists) with the values 3, 4, 84, 5, 2, 47, and 7 in this order Then sort the array(list) Create a program with a menu, with choices 1 for factorial (single value, which everyone will use 20!), 2 for median value , 3 for average, 4 for maximum, 5 for minimum, and 6 to end the program. Use a do loop (not while) Python does not have a Do loop, so instead...
C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...
Design program so that it correctly meets the program specifications given below. Specifications: Create a menu-driven program that finds and displays areas of 3 different objects. The menu should have the following 4 choices: 1 -- square 2 -- circle 3 -- right triangle 4 -- quit If the user selects choice 1, the program should find the area of a square. If the user selects choice 2, the program should find the area of a circle. If the user...
Objectives: Integer arithmetic, Functions, menus. Write a C++ program that displays the following menu of choices. 1. Find the number of digits in an integer. 2. Find the nth digit in an integer. 3. Find the sum of all digits of an integer. 4. Is the integer a palindrome? 5. Quit Enter a choice: Page 1 of 4 For each of the choices (1, 3, 4), Read a positive integer number and call a function that processes the menu choice...
Create a menu-driven program (using the switch) that finds and displays areas of 3 different objects. The menu should have the following 4 choices: 1 -- rectangle 2 -- circle 3 -- triangle 4 -- quit If the user selects choice 1, the program should find the area of a rectangle. rectangle area = length * width If the user selects choice 2, the program should find the area of a circle. circle area = PI * radius * radius...
Write a Program that has a menu with a layout below, that asks the user if they want to: 1. Converts from feet and inches to meter and centimeters 2. Converts from meter and centimeters to feet and inches 3. Quit the program The program should continue as long as the user asks it to. The program will use a switch statement for the menu option selection. Either a do loo or a do-while loop can be used for the overall...
This is done in c programming and i have the code for the
programs that it wants at the bottom i jut dont know how to call
the functions
Program 2:Tip,Tax,Total
int main(void)
{
// Constant and Variable Declarations
double costTotal= 0;
double taxTotal = 0;
double totalBill = 0;
double tipPercent = 0;
// *** Your program goes here ***
printf("Enter amount of the bill: $");
scanf("%lf", &costTotal);
printf("\n");
// *** processing ***
taxTotal = 0.07 * costTotal;
totalBill...
Write this program using C++ , (Rock, Paper, Scissors Game – Page 373) This programming assignment is from the textbook with some slight modifications and clarifications. Here is what I am going to except from you. Your program should include at least the following functions: getComputerGuess(): this function should return a random value generated by the computer using rand function (read more about random numbers in Chapter 3 pages 126 – 128). getUsersChoice(): this function will ask the user to...
In basic c develop the code below: (a) You will write a program that will do the following: prompt the user enter characters from the keyboard, you will read the characters until reading the letter ‘X’ You will compute statistics concerning the type of characters entered. In this lab we will use a while loop. We will read characters from stdin until we read the character ‘X’. Example input mJ0*5/]+x1@3qcxX The ‘X’ should not be included when computing the statistics...