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.
Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
#include <stdio.h>
#include<stdlib.h>
int main(void)
{
double amt=0.0;
int flag=1;
while(flag!=0)
{
printf("Enter product selection: ");
scanf("%d",&flag);
double wt;
switch(flag)
{
case 0:
break;
case 1:
printf("Enter product weight (lb): ");
scanf("%lf",&wt);
amt=amt+1.99*wt;
break;
case 2:
printf("Enter product weight (lb): ");
scanf("%lf",&wt);
amt=amt+2.39*wt;
break;
case 3:
printf("Enter product weight (lb): ");
scanf("%lf",&wt);
amt=amt+1.69*wt;
break;
case 4:
printf("Enter product weight (lb): ");
scanf("%lf",&wt);
amt=amt+1.49*wt;
break;
case 5:
printf("Enter product weight (lb): ");
scanf("%lf",&wt);
amt=amt+1.89*wt;
break;
default:
printf("Invalid selection, select from 1 to 5, enter 0 to stop
selection\n");
break;
}
}
printf("Amount due ($): %.2f\n",amt);
printf("Enter cash received ($): ");
double cash;
scanf("%lf",&cash);
printf("Your change is $%.2f\n",cash-amt);
}
Kindly revert for any queries
Thanks.
Programming language C. A small U-Pick farm sells five different U-Pick citrus fruit products whose retail...
Project 1, Program Design 1. Write a C program replace.c that asks the user to enter a three-digit integer and then replace each digit by the sum of that digit plus 6 modulus 10. If the integer entered is less than 100 or greater than 999, output an error message and abort the program. A sample input/output: Enter a three-digit number: 928 Output: 584 2. Write a C program convert.c that displays menus for converting length and calculates the result....
ELEC 1520 Homework - Integer Operations, Selection Statements Instructions Write C++ programs to solve the following two problems. Upload your source code files to Canvas. The file names must be of the form coins_your_name.cpp and bonus_your_name.cpp for problems 1 and 2, respectively. Substitute your first and last name for "your_name" in the file name. Problem Statements 1. Given a value V in cents, you need to make change using a minimum number of coins. Assume you have an infinite supply...