Question

In: Computer Science

At We Ship Anything, we need to create a program that will calculate the charges associated...

At We Ship Anything, we need to create a program that will calculate the charges associated with the weight of a specific package. We charge a base rate of $54.03 for any package and then add a premium to it based on the package weight. The additional costs are as follows: • If the package weighs less than 2.5 kg then we charge an additional $2.00. • If the package weighs 2.5kg to 5kg then we charge an additional $3.00. • If the package weighs more than 5kg we charge an additional $4.00. Create a program that will ask the user to enter the destination and weight of their package. We will then display the destination, the package weight, the base rate, additional package charge and total charge owing. Display it with each of the values on a separate line

Solutions

Expert Solution

Pseudocode:

Here i am attaching the pseudocode for the given problem. SO that you can execute in any programming language

Code in Python:

# Taking destination and weight from the user
destination = input("Enter Destination: ")
weight = float(input("Enter weight of package: "))

# Initialization of variables
B_rate = 54.03
add_charge = total_charge = 0

# Calculation of additional charge
if weight < 2.5:
add_charge = 2.0
elif weight >=2.5 and weight <=5.0:
add_charge = 3.0
else:
add_charge = 4.0

# Calculating total charge
total_charge = B_rate + add_charge

# Printing the results
print("Destination is: ",destination)
print("Weight is: ",weight)
print("Base rate is: ",B_rate)
print("Additional charge is: ",add_charge)
print("Total charge is: ",total_charge)

OUTPUT:

Code in C language:

# include<stdio.h>
# include<conio.h>

void main()
{
   char destination[50];
   float weight, B_rate = 54.03, add_charge = 0.0, total_charge = 0.0;
  
   printf("Enter Destination: ");
   scanf("%s",&destination);
  
   printf("Enter package weight: ");
   scanf("%f",&weight);
  
   if(weight < 2.5)
   {
       add_charge = 2.0;
   }
   else if(weight >= 2.5 && weight <= 5.0)
   {
       add_charge = 3.0;
   }
   else
   {
       add_charge = 4.0;
   }
  
   total_charge = B_rate + add_charge;
  
   printf("\nDestination is: %s",destination);
   printf("\nWeight is: %.2f",weight);
   printf("\nBase rate is: %.2f",B_rate);
   printf("\nAdditional Charge is: %.2f",add_charge);
   printf("\nTotal charge is: %.2f",total_charge);
}

OUTPUT:


Related Solutions

We need to create basic program that will simply display a menu and allow the user...
We need to create basic program that will simply display a menu and allow the user to select one of the choices. The menu should be displayed such that each option will be numbered, as well as have one capital letter so as to indicate that either the number or the designated letter can be entered to make their choice. Once the choice is made, the sub-menu for that selection should be displayed. Colors with an odd number of letters...
Create a program that stores the information of up to 50 containers loaded on ship. The...
Create a program that stores the information of up to 50 containers loaded on ship. The program should contain a menu to do the following: A or a     to add a container. R or r      to retrieve the information of one container. T or t      to retrieve the information of all containers. W or w   to retrieve the total weight of the loaded containers. X or x      to exit the program Ask the user for the number of containers to...
a) Create a program for the msp430FR6989 .You will use need to program it to be...
a) Create a program for the msp430FR6989 .You will use need to program it to be able to use a external pulse switch to start/stop the blinking of LED1, and a second pulse switch to control the blinking of LED2. b) Modify Program #1 (b) to blink the number of times on the data switches once the pulse switch is engaged
What we want the program to do: We need to write a program, in Java, that...
What we want the program to do: We need to write a program, in Java, that will let the pilot issue commands to the aircraft to get it down safely on the flight deck. The program starts by prompting (asking) the user to enter the (start) approach speed in knots. A knot is a nautical mile and is the unit used in the navy and by the navy pilots. After the user enters the approach speed, the user is then...
In java Create a program to calculate interest rate and total balance - the program consists...
In java Create a program to calculate interest rate and total balance - the program consists of (a) A class that encapsulates the interest rate and total balance calculation Constructor should accept initial balance and interest rate Methods: Returns interest rate Returns total balance Set interest rate Set initial balance (b) A test program that uses class from step (A) to perform the following: Set interest rate to 5% and initial balance to 1000 Print interest amount and total balance...
Suppose, we need to debug somebody else’s program. We suspect that there is a problem with...
Suppose, we need to debug somebody else’s program. We suspect that there is a problem with the method wizbang() in class Widget or with how that method is called. We cannot modify class Widget, nor can we modify the client code that contains the calls to Widget.wizbang(), since we don’t have those sources. However, we can modify the code where Widget objects are created and we can create new classes. In order to better understand what this method does, we...
Java program. Need to create a class names gradesgraph which will represent the GradesGraphtest program. Assignment...
Java program. Need to create a class names gradesgraph which will represent the GradesGraphtest program. Assignment Create a class GradesGraph that represents a grade distribution for a given course. Write methods to perform the following tasks: • Set the number of each of the letter grades A, B, C, D, and F. • Read the number of each of the letter grades A, B, C, D, and F. • Return the total number of grades. • Return the percentage of...
How can we be CERTAIN we know anything at all?
How can we be CERTAIN we know anything at all?
In Java, need to create a program with Body Mass Index (BMI) is a measure of...
In Java, need to create a program with Body Mass Index (BMI) is a measure of health on weight. It can be calculated by taking your weight in kilograms and dividing, by the square of your height in meters. Write a program that prompts the user to enter a weight in pounds and height in inches and displays the BMI. Note one pound is 0.45359237 kilograms and one inch is 0.0254 meters. Here is a sample run: Enter weight in...
Use Visual Basic Language In this assignment you will need to create a program that will...
Use Visual Basic Language In this assignment you will need to create a program that will have both a “for statement” and an “if statement”. Your program will read 2 numbers from the input screen and it will determine which is the larger of the 2 numbers. It will do this 10 times. It will also keep track of both the largest and smallest numbers throughout the entire 10 times through the loop. An example of the program would be...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT