Write a menu-driven program called p2.c that allows the user to enter and display data about...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a menu-driven program called p2.c that allows the user to enter and display data about a single American politician: Program Operation The program should keep track of the following quantities for a single politician: ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● Prefix: a string of at most three characters and can be null. First Name: a single string with a maximum of 32 characters. Middle Initial: a single character and can be null. Last Name: a single string with a maximum of 32 characters. Suffix: a string of at most three characters and can be null. Age: an integer from 18 to 99 years inclusive. Sex: a single character, 'M' or 'F'. Office Held: a string of at most 32 characters. (Can include spaces). Years Served: a two-digit integer from 0 to 99. Political Party: should be stored and displayed as a three-letter string as given below: Constitution: CON Democratic: DEM Green: GRE, Libertarian: LIB Republican: REP State: two-character abbreviation for home state (e.g., AL, SC) to be chosen from a list displayed. Twitter Account: a string with a maximum of fifteen characters. (Ampersand is not entered but is shown when displayed, e.g. "@CheathamMoore") Phone Number: a ten-digit number input and displayed as (666) 555-4444. Donations Received: a floating-point number from 0.0 to 1.0x105⁰, inclusive, displayed in USD. Total Wealth: a floating-point number from 0.0 to 1.0x101000, inclusive, displayed in USD. Note: Initially, all quantities are to be initialized as an "unknown value" and should be denoted as such when displayed. It's up to the programmer to decide what values to store to represent unknown values. Menu The program should have eight input options in the menu which perform the following tasks: ● Enter Name Display all Data Enter Years, Party, Office, and State Clear all Data ● Enter Age and Sex ● Quit ● ● Enter Contacts ● Enter Contributions and Wealth ● The specific format of the menu and its display is not specified, but it must be straight- forward and readable. ● Input The program should allow the user to select only one of the above options at a time. An error message should be displayed if an invalid option is chosen. For the options requiring data input, the program should prompt for the appropriate data when the option is selected. All inputs should be checked for validity, and if the data input is invalid, an appropriate error message should be given allowing the user to try again. Upon completing any option (except "Quit"), the program should redisplay the menu. Use the following line to compile your program Output The program should only display data if that option is selected. When it is selected, the program should print all data indicating which-if any-data is unknown. gum -Wall -g p2.c -o p2 [-1m] Write a menu-driven program called p2.c that allows the user to enter and display data about a single American politician: Program Operation The program should keep track of the following quantities for a single politician: ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● Prefix: a string of at most three characters and can be null. First Name: a single string with a maximum of 32 characters. Middle Initial: a single character and can be null. Last Name: a single string with a maximum of 32 characters. Suffix: a string of at most three characters and can be null. Age: an integer from 18 to 99 years inclusive. Sex: a single character, 'M' or 'F'. Office Held: a string of at most 32 characters. (Can include spaces). Years Served: a two-digit integer from 0 to 99. Political Party: should be stored and displayed as a three-letter string as given below: Constitution: CON Democratic: DEM Green: GRE, Libertarian: LIB Republican: REP State: two-character abbreviation for home state (e.g., AL, SC) to be chosen from a list displayed. Twitter Account: a string with a maximum of fifteen characters. (Ampersand is not entered but is shown when displayed, e.g. "@CheathamMoore") Phone Number: a ten-digit number input and displayed as (666) 555-4444. Donations Received: a floating-point number from 0.0 to 1.0x105⁰, inclusive, displayed in USD. Total Wealth: a floating-point number from 0.0 to 1.0x101000, inclusive, displayed in USD. Note: Initially, all quantities are to be initialized as an "unknown value" and should be denoted as such when displayed. It's up to the programmer to decide what values to store to represent unknown values. Menu The program should have eight input options in the menu which perform the following tasks: ● Enter Name Display all Data Enter Years, Party, Office, and State Clear all Data ● Enter Age and Sex ● Quit ● ● Enter Contacts ● Enter Contributions and Wealth ● The specific format of the menu and its display is not specified, but it must be straight- forward and readable. ● Input The program should allow the user to select only one of the above options at a time. An error message should be displayed if an invalid option is chosen. For the options requiring data input, the program should prompt for the appropriate data when the option is selected. All inputs should be checked for validity, and if the data input is invalid, an appropriate error message should be given allowing the user to try again. Upon completing any option (except "Quit"), the program should redisplay the menu. Use the following line to compile your program Output The program should only display data if that option is selected. When it is selected, the program should print all data indicating which-if any-data is unknown. gum -Wall -g p2.c -o p2 [-1m]
Expert Answer:
Answer rating: 100% (QA)
Heres a basic example of a menudriven program in C that follows the specifications you provided Note that this is a simple consolebased program and you may want to add more error handling and refineme... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
At a local discount store 5 toasters ovens and 8 slow cookers cost $350 while 9 toaster ovens and 5 slow cookers cost $395. How much does one toaster oven cost? How much is one slow cooker? Cost of a...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Solve S - log5x+log5(4x 1) = 1
-
On January 1, 2012, Albert invested $1,000 at 6 percent interest per year for three years. The CPI (times 100) on January 1, 2012, stood at 100. On January 1, 2013, the CPI was 105; on January 1,...
-
Was Vanguard's failure to open walk-in sales outposts a mistake and an example of misplaced frugality? Why or why not?
-
max = 247, range = 93, 10 classes In Exercises 1114, use the given information about the data set and the number of classes to find the class width, the lower class limits, and the upper class limits.
-
The following additional information is available for the variable overhead costs in question 2: Standard cost per unit of product 2 liters of raw materials @ \($16\) per liter Actual use of raw...
-
Create a time-phased resource-loading table for this project, identifying the activity early start and late finish points. Consider a project with the following information: Activitv Duration...
-
19. Find all the complex cube roots of -8 +83i, then plot the in the complex plane.
-
Raymond Constructions trial balance at December 31, 2020, is presented as follows. All 2020 transactions have been recorded except for the items described below. Unrecorded transactions: 1. On May 1,...
-
With the above procedures, we have data in the Excel file "Data_MomContrarian.xlsx". The data sample is monthly from 1931.01-2011.12. The variable definition for each column is described in the...
-
For the current period, Kay Company's manufacturing operations show a $4,500 unfavorable direct materials price variance. The actual price per pound of material is $84; the standard price is $83.50...
-
Zortek Corp. budgets production of 420 units in January and 350 units in February. Each finished unit requires four pounds of raw material Z, which costs $3 per pound. Each month's ending inventory...
-
Randall Company produces golf clubs. If the fixed cost per club is $11 when 37900 clubs are produced, what is the fixed costs per unit when 26900 rackets are produced? Round your answer 2 decimal...
-
AMF Products Ltd. had annual net income of $20,000, CCA of $35,000, a 40 percent tax rate, a discount rate of 10 percent, and annual cash sales of $200,000. The depreciable assets of AMF Products...
-
What is the nominal annual rate of interest compounded quarterly if a loan of $20,500 is repaid in seven years by payments of $1000 made at the end of every three months? The nominal annual rate of...
-
A national staffing firm has hired you as an HR consultant. The General Manager (GM) is concerned that the firm is losing its competitive position in the technology industry, specifically staffing...
-
Which of the following gives the range of y = 4 - 2 -x ? (A) (- , ) (B) (- , 4) (C) [- 4, ) (D) (- , 4] (E) All reals
-
In this exercise, you will modify the program from Computer Exercise 12. If necessary, create a new project named ModifyThis14 Project, and save it in the Cpp8\Chap09 folder. Enter (or copy) the...
-
Some credit card companies assign a special digit, called a check digit, to the end of each customers credit card number. Many methods for creating the check digit have been developed. One very...
-
You expose a member of a class by recording the member below the _____________________ keyword in the class statement. a. Common b. Exposed c. Public d. Unrestricted
-
Given the probabilities of expected states of the economy shown here, and the expected returns to stocks A and B in those states, what is the standard deviation of a portfolio with weights of 40...
-
The controller of Getty Industries has collected the following monthly expense data for use in analysis the cost behavior of maintenance costs. Instructions (a) Determine the fixed and variable cost...
-
Stock W has an expected return of 12.4 percent and a beta of 1.8. If the expected market return is 10 percent, what is the risk-free rate? a. -5.6% b. 3.0% c. 5.6% d. 7.0%
Study smarter with the SolutionInn App