Question

In: Computer Science

I have to write a c program for shipping calculator. anything that ships over 1000 miles,...

I have to write a c program for shipping calculator. anything that ships over 1000 miles, there is an extra 10.00 charge. I have tried everything. no matter what I put, it will not add the 10.00. please help here is my code

#include <stdio.h>
#include <stdlib.h>

int main()
{
double weight, miles, rate, total;

printf("Enter the weight of the package:");
scanf("%lf", &weight);

if (weight > 50.0) {
puts("we only ship packages of 50 pounds or less.");
return 0;

}
if ( miles > 1000 ){
total = rate + 10.00;
printf("rate is $%.2lf \n", rate);

}
printf("Enter the amount of miles it would take:");
scanf("%lf", &miles);

if (weight <= 10.0)
rate = 3.00;

else
rate = 5.00;


printf("Shipping charge is $%.2lf \n", (int)((miles + 499.0) / 500.0) * rate);
if (miles >= 1000){
("shipping charge + 10.00");
}
system("pause");
}

Solutions

Expert Solution

** I request you to Please Provide the positive Rating**

SOURCE CODE:
#include <stdio.h>
#include <stdlib.h>

int main()
{
double weight, miles, rate;

printf("Enter the weight of the package:");
scanf("%lf", &weight);
if (weight <= 10.0)
rate = 3.00;

else
rate = 5.00;
if (weight > 50.0) {
puts("we only ship packages of 50 pounds or less.");

exit(0);

}
printf("Enter the amount of miles it would take:");
scanf("%lf", &miles);
if ( miles < 1000 ){
printf("Shipping charge is $%.2lf \n", (float)(((miles + 499.0) / 500.0) * rate));
}
else
{//total = rate + 10.00;
//printf("rate is $%.2lf \n", total);
printf("Shipping charge is $%.2lf \n", (float)(((miles + 499.0) / 500.0) * rate)+10);
}
return 0;
}

OUTPUT1:

Enter the weight of the package:46
Enter the amount of miles it would take:1254
Shipping charge is $27.53

OUTPUT2:

Enter the weight of the package:23
Enter the amount of miles it would take:780
Shipping charge is $12.79


OUTPUT3:

Enter the weight of the package:78
we only ship packages of 50 pounds or less.



Related Solutions

Project 1: Frequent Flyer Miles Calculator Write a Ruby program that calculates how many frequent flyer...
Project 1: Frequent Flyer Miles Calculator Write a Ruby program that calculates how many frequent flyer miles are needes for a free ticket on a new startup airline, CorsairAir. Frequent flyer miles are charged for a free ticket depending on the class of service (more for first class, less for coach), depending on the day flying (more if flying on Friday, Saturday or Monday, less for other days of the week), depending on the distance traveled, and a surcharge if...
1. Specification Write a C program to implement a simple calculator that accepts input in the...
1. Specification Write a C program to implement a simple calculator that accepts input in the following format and displays the result of the computation: calc [operand_1] [operator] [operand_2] The operands operand_1 and operand_2 are non-negative integers. The operator is one of the following: addition (+), subtraction (-), multiplication (x), division (/) and modulo (%). Note: For the multiplication operator, use letter ‘x’. If you use the asterisk ‘*’, your program will not work properly 2. Implementation • The program...
REVERSE POLISH CALCULATOR C++ ONLY. For this assignment, you are to write a program, which will...
REVERSE POLISH CALCULATOR C++ ONLY. For this assignment, you are to write a program, which will calculate the results of Reverse Polish expressions that are provided by the user. You must use a linked list to maintain the stack for this program (NO array implementations of the stack). You must handle the following situations (errors): Too many operators (+ - / *) Too many operands (doubles) Division by zero The program will take in a Polish expression that separates the...
Miles to Kilometers ASSIGNMENT: Write a program to convert miles to kilometers. Put the entire program...
Miles to Kilometers ASSIGNMENT: Write a program to convert miles to kilometers. Put the entire program in a sentinel-controlled loop that runs until the user enters a negative number. Use both a pre-test sentinel-controlled loop and a post-test sentinel-controlled loop in the program. There are 1.6 kilometers in 1.0 mile. Store the value of 1.6 in a constant and use the constant in the calculations. There is 1 blank line after the descriptions, and 2 blanks lines between the pre-test...
I need this in java A6 – Shipping Calculator Assignment Introduction In this part, you will...
I need this in java A6 – Shipping Calculator Assignment Introduction In this part, you will solve a problem described in English. Although you may discuss ideas with your classmates, etc., everyone must write and submit their own version of the program. Do NOT use anyone else’s code, as this will result in a zero for you and the other person! Shipping Calculator Speedy Shipping Company will ship your package based on the weight and how far you are sending...
C++ Write a program that displays the follow menu: Geometry Calculator    1. Calculate the Area...
C++ Write a program that displays the follow menu: Geometry Calculator    1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle    3. Calculate the Area of a Triangle 4. Quit Enter your choice (1-4): If the user enters 1, the program should ask for the radius of the circle then display it's area using the following formula: area = PIr2 Use 3,14159 for PI and the radius of the circle for r. If the...
write a program to make scientific calculator in java
Problem StatementWrite a program that uses the java Math library and implement the functionality of a scientific calculator. Your program should have the following components:1. A main menu listing all the functionality of the calculator.2. Your program should use the switch structure to switch between various options of the calculator. Your Program should also have the provision to handle invalidoption selection by the user.3. Your calculator SHOULD HAVE the following functionalities. You can add any other additional features. PLEASE MAKE...
Write a program to determine the shipping costs for an online purchase.
C++13.2 Lab13 - using if-else if to calculate sales tax and shipping costsThe ConceptReal world problems often involve complex logical conditions. Today we learned two techniques to deal with complexity – the else if construct and logical operators. Use these new tools to below (really you only need one of these tools).The ExerciseWrite a program to determine the shipping costs for an online purchase.Prompt the user for the number of items using the following prompt:Enter the number of items:Prompt the...
Write a C++ program that displays the numbers between 1000 and 9999, which are divisible by...
Write a C++ program that displays the numbers between 1000 and 9999, which are divisible by sum of the digits in them. For example, 2924 is divisible by (2+9+2+4 = 17). Your program should display all these possible numbers in the given range, and each number should be separated from the other by a space.
IN BASIC C# If It Fits, It Ships! OVERVIEW In this program you will be calculating...
IN BASIC C# If It Fits, It Ships! OVERVIEW In this program you will be calculating the total amount the user will owe to ship a rectangular package based on the dimensions and we will add in insurance based on the prices of the items inside of the package.. INSTRUCTIONS: 1. Welcome the user and explain the purpose of the program. 2. In the Main, prompt the user for the width, length and height of their package. a. Each of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT