Question: Programming language C. A small U-Pick farm sells five different U-Pick citrus fruit products whose retail prices are: 1. Sugarbells - $1.99/lb, 2. Honeybells -
Programming language C.
A small U-Pick farm sells five different U-Pick citrus fruit products whose retail prices are: 1. Sugarbells - $1.99/lb, 2. Honeybells - $2.39/lb, 3. Red Grapefruit $1.69/lb, 4. Navel Oranges - $1.49/lb, 5. Pomelo - $1.89/lb. Write a program that allows the user to select one or more products, input the weights of each product, and calculate the total amount due. The farm only accepts cash. Your program will take input of the cash received and calculate the change. A sample input/output: Please select from the following menu: 1. Sugarbells - $1.99/lb, 2. Honeybells - $2.39/lb, 3. Red Grapefruit $1.69/lb, 4. Navel Oranges - $1.49/lb, 5. Pomelo - $1.89/lb. Enter 0 to stop selection. Enter product selection: 1 Enter product weight (lb): 4.8 Enter product selection: 3 Enter product weight (lb): 2 Enter product selection: 7 Invalid selection, select from 1 to 5, enter 0 to stop selection Enter product selection: 5 Enter product weight (lb): 1.6 Enter product selection: 0 Amount due ($): 15.96 Enter cash received ($): 20 Your change is $4.04 1. Name your program upick.c 2. When user enters 0, the program should exit from the loop for selection. 3. Use a switch statement to compute the amount due according to the product selection. Before you submit: 1. Compile with Wall. Wall shows the warnings by the compiler. Be sure it compiles on student cluster (sc.rc.usf.edu) with no errors and no warnings. gcc Wall upick.c 2. Test your program with the shell script on Unix: chmod +x try_upick ./try_upick 3. Download the program upick.c from student cluster and submit upick.c on Canvas>Assignments.
Programming Style Guidelines: The major purpose of programming style guidelines is to make programs easy to read and understand. Good programming style helps make it possible for a person knowledgeable in the application area to quickly read a program and understand how it works. 1. Your program should begin with a comment that briefly summarizes what it does. This comment should also include your name. 2. In most cases, a function should have a brief comment above its definition describing what it does. Other than that, comments should be written only needed in order for a reader to understand what is happening. 3. Variable names and function names should be sufficiently descriptive that a knowledgeable reader can easily understand what the variable means and what the function does. If this is not possible, comments should be added to make the meaning clear. 4. Use consistent indentation to emphasize block structure. 5. Full line comments inside function bodies should conform to the indentation of the code where they appear. 6. Macro definitions (#define) should be used for defining symbolic names for numeric constants. For example: #define PI 3.141592 7. Use names of moderate length for variables. Most names should be between 2 and 12 letters long. 8. Use underscores to make compound names easier to read: tot_vol or total_volumn is clearer than totalvolumn.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
