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

Integer value calculator: Write a program using C++ that acts as a calculator. The program should...
Integer value calculator: Write a program using C++ that acts as a calculator. The program should ask the user for two numbers and an operator. Then the program must print the result using the two input values and the operator. Prompts and input requirements. Ask the user for two integer values and a value that indicates the operation. Likely you will want to choose the normal operators: + - * / %. Output Requirements: Make your output easy to understand,...
Please use original C++ code for this. This is for visual studio. Program 5: Shipping Calculator...
Please use original C++ code for this. This is for visual studio. Program 5: Shipping Calculator The Speedy Shipping Company will ship packages based on how much they weigh and how far they are being sent. They will only ship small packages up to 10 pounds. You have been tasked with writing a program that will help Speedy Shipping determine how much to charge per delivery. The charges are based on each 500 miles shipped. Shipping charges are not pro-rated;...
For this assignment you will develop pseudocode and write a C++ program for a simple calculator....
For this assignment you will develop pseudocode and write a C++ program for a simple calculator. You will create both files in Codio. Put your pseudocode and C++ code in the files below. PSEUDOCODE FILE NAME: Calculator.txt C++ SOURCE CODE FILE NAME : Calculator.cpp DESCRIPTION: Write a menu-driven program to perform arithmetic operations and computations on a list of integer input values. Present the user with the following menu. The user will choose a menu option. The program will prompt...
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...
Write a C program that runs on ocelot for a mini calculator using only the command...
Write a C program that runs on ocelot for a mini calculator using only the command line options. You must use getopt to parse the command line. Usage: minicalc [-a num] [-d num] [-m num] [-s num] [-e] value • The variable value is the starting value. • Value should be validated to be an integer between 1 and 99. Error message and usage shown if not. • -a adds num to value. • -d divides value by num. •...
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...
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...
who to write a program c++ that reads in an integer between 0 and 1000 and...
who to write a program c++ that reads in an integer between 0 and 1000 and adds all the digits in the integer?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT