Question
Write a C program to compute the cost of shipping luggage one-way using a 5 business Day option from fast track corp services the user
Write a C program to compute the cost of shipping luggage one-way using a 5 business Day option from "fast track corp" services the user should be able to....
Choose a box/flat envelope option with the quantity to ship
use only a delivery time of 4 business days
choose to add insurance of 0, 100, 200 dollars
print the total cost
I am having difficulty making my program work properly I want to fix it so that it will calculate the total cost after insurance is chosen and I also want to make the program change lowercase input to uppercase input I also want the program to loop if the user inputs letters instead of numbers and same thing for numbers instead of letters
Here is what I have done so far
#include
#define _CRT_NO_WARNINGS
#include
int main(void)
{
// Declaration of Variables :
//Bag/Case option :
int carryOn = 69;
int standardBag = 99;
//User Answers
char userAnswer = 'Y';
int answer = 0; //Carry on or Standard Bag
int numItemsStandard = 0;
int numItemsCarry = 0;
int total = 0; //Total of number of items * item type
int newTotal = 0; // Complete total before tax.
//Shipping & Insurance options :
int shippingTime = 4;
int insuranceA = 0;
int insuranceB = 100;
int insuranceC = 200;
int insuranceD = 300;
int insuranceE = 400;
int insuranceF = 500;
// Start of the program.
while(answer!=1,2,3) {
printf("Welcome Please select an option for what you would like to ship. Enter 1 for Carry on or 2 for Standard bag 3 for both ");
scanf("%d", &answer);
//If else statmenets for carry on or bag option
if (answer == 1)
{
printf("You selected : Carry on option How many would you like to ship? \t");
scanf("%d", &numItemsCarry);
total = numItemsCarry * carryOn;
}
else if (answer == 2)
{
printf("You selected : Standard Bag option How many would you like to ship? \t");
scanf("%d", &numItemsStandard);
total = numItemsStandard * standardBag;
}
else if (answer == 3)
{
printf("You selected : Standard Bag option & Carry On option ");
printf("How many Carry on bags will you be bringing? \t");
scanf("%d", &numItemsCarry);
printf("How many Standard Bags will you be brining with you? \t");
scanf("%d", &numItemsStandard);
total = numItemsCarry * carryOn + numItemsStandard * standardBag;
}
else
{
printf(" \tError You can only enter integer values for this response. ");
}
//loop again until user inputs the proper number
}
printf("\tYour total before insurance is $%d ", total);
//Choosing of the insurance option :
while(userAnswer!='A','B','C','D','E','F','a','b','c','d','e','f') {
printf(" Please choose an insurance option : Option A: $0 Option B: $100 Option C: $200 Option D: $300 Option E: $400 Option F: $500 ");
scanf(" %c", &userAnswer);
if (userAnswer == 'A')
{
newTotal = total;
printf("Your total is \t$%d.00 \t", newTotal);
}
else if (userAnswer == 'B')
{
newTotal = total + insuranceB;
printf("Your total is \t$%d.00 \t", newTotal);
}
else if (userAnswer == 'C')
{
newTotal = total + insuranceC;
printf("Your total is \t$%d.00 \t", newTotal);
}
else if (userAnswer == 'D')
{
newTotal = total + insuranceD;
printf("Your total is \t$%d.00 \t", newTotal);
}
else if (userAnswer == 'E')
{
newTotal = total + insuranceE;
printf("Your total is \t$%d.00 \t", newTotal);
}
else if (userAnswer == 'F')
{
newTotal = total + insuranceF;
printf("Your total is \t$%d.00 \t", newTotal);
}
else
{
printf(" ERROR enter in uppercase ");
}
} // loop again if letters were not entered
printf("total trip cost is %d");
return 0;
}
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