Exclude any existing source code files that may already be in your IDE project and add a new one, naming it C1A5E1_main.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Exclude any existing source code files that may already be in your IDE project and add a new one, naming it C1A5E1_main.

Post by answerhappygod »

Exclude Any Existing Source Code Files That May Already Be In Your Ide Project And Add A New One Naming It C1a5e1 Main 1
Exclude Any Existing Source Code Files That May Already Be In Your Ide Project And Add A New One Naming It C1a5e1 Main 1 (304.35 KiB) Viewed 35 times
Exclude any existing source code files that may already be in your IDE project and add a new one, naming it C1A5E1_main.c. Write code in that file's main function that implements a survey of how shoppers like a product by prompting them to enter a decimal integer rating value within an allowed range of BEST TO WORST. If either all shoppers have entered an in-range value or any one shopper enters a specified number of out-of-range values, the function must display a table of survey results and then return. Define the following five macros to have any integer values within the stated constraints and use them appropriately in your code, but your code must also work with any other integer values within those constraints. Although defining additional macros is unnecessary, you may do so as long as it is not necessary to explicitly change their values if the values of any of the required macros are changed: SHOPPERS - number of participating shoppers ( any value > 0) BEST - highest allowed rating value ( any negative, zero, or positive value) WORST - lowest allowed rating value ( any value <= BEST) CHOICES - the number of integer values from BEST down to WORST For example, if BEST is 3 and WORST IS -2, the value of CHOICES will be 6. The value of CHOICES must be derived from BEST and WORST and not specified as a literal number. The code in its replacement list must not do any comparisons. This is an extremely simple macro. MAX_ERRORS - number of out-of-range ratings from any one shopper that ends prompting (> 0) Your code must: 1. Use a one-dimensional automatic type int array having exactly CHOICES elements. No other arrays are permitted. Each element represents an allowed rating and will contain a count of how many of that rating have been entered so far (similar to note 6.3). 2. Initially output a message that indicates the allowed rating range and the MAX_ERRORS value. Then loop to individually prompt shoppers to enter their ratings. Use a variable named errors to keep count of the current shopper's out-of-range ratings: If an in-range rating is entered, set errors back to 0, increment the array element that represents that rating, and prompt the next shopper. If an out-of-range rating is entered, notify the shopper, increment errors, then compare it to MAX_ERRORS. If they are not equal, reprompt the same shopper. Else, if they are equal, go to step 3 below. 3. Return from main after first displaying a table like that below. The table must list all allowed rating values in the "Rating" column and the number of each that shoppers entered in the "Quantity" column. Entries must be in best to worst rating order and the least significant digits of all values must be aligned: Rating Quantity . 10 9 8 25 50 100 - 1239 0 . If you believe you need more than one array or an array having other than CHOICES elements, you have not understood the requirements and should reread them as well as note 6.3. Do not test if the values of the required macros are actually valid. Do not use a loop or call a function to initialize your array to Os. Do not produce the absolute value of anything. . .
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply