Question
In C code, Shipping by Land or Air Program. Costs .90 cents per ounce to ship a package with a $7.00 fee for each package
In C code, Shipping by Land or Air Program. Costs .90 cents per ounce to ship a package with a $7.00 fee for each package shipped by air. To ship by ground is costs
depending on the zip code- 23145 zip code .15 cents per ounce $3.15 fee
23149 & 23149 zip code .17 cents per ounce $3.25 fee
All other zip codes .40 cents per ounce $4.00 fee
If you are a senior (over 65) you get a 12% discount on the shipping price.
The Program first asks you for your name, as input. Use void printHeader for a welcome header message with no parameters and returns nothing. Use main() to ask for how many packages they want mailed. In a For loop, ask if they are a Senior, ask for the weight of one package, ask whether they want to ship by air or ground. Use a Switch statement to call the function named either calAir (enter A) or calGround (enter G). If they are sending by Air, send the package weight and their discount if applicable to the calAir function. If they are sending by ground, ask for the zipcode and send the weight, zipcode and if they get a discount to a function called calGround. If they do not choose either Air (A) or Ground (G) for shipping display an Error Message. Use the function calAir() which takes the inputted weight of the package and calculates and prints the shipping cost for the package, including the 12% discount if they choose Senior Customer. Use the function calGround which takes the inputted weight of the package and the zipcode and calculates and prints the shipping cost of that package. Include one symbolic constant in the program.
This is what I have so far, need to finish the rest- the actual figures are not crucial to me, I am studying the form and the proper formation and application of the functions, variables, swtich, input, prototype for constructing C programs.
#include
//prototype int calGround(int); int calAir(int); void printHeader();
int main() {
char name;
char zipCode;
float groundFee:
float groundCostOunce;
float airCostOunce;
char shipBy;
int numPackages;
int package;
float weight;
float cost;
calAir();
calGround();
printHeader();
printf("What is your name?");
scanf("%c", &name);
printf("How many packages to mail?");
scanf("%d", &numPackages");
for(package =1; package <= numPackages; package++)
printf("Are you a senior? (Y or N): ");
printf("Enter the weight of the package: ");
scanf("%f", &weight);
printf("Ship by Air or Ground (A or G only choose one)");
scanf("%c", &shipBy);
switch(shipBy)
if A:
break;
if G:
printf("What is your zip?");
scanf("%c", zipCode);
break;
default:
printf("Error");
}
calAir()
{
weight
printf("The cost to ship, by air, with discount (if applicable)", cost);
}
calGround()
{
printf("The cost to ship, by ground, with discount (if applicable) is", cost):
}
void printHeader()
{
printf("Welcome to United Shipping");
}
thanks-
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started