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

in java we need to order a list , if we create a program in java...
in java we need to order a list , if we create a program in java what  are the possible ways of telling your program how to move the numbers in the list to make it sorted, where each way provides the required result. list the name of sorting with short explanation
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
I need someone to create a program for me: Create a program that takes as input...
I need someone to create a program for me: Create a program that takes as input an employee's salary and a rating of the employee's performance and computes the raise for the employee. The performance rating here is being entered as a String — the three possible ratings are "Outstanding", "Acceptable", and " Needs Improvement ". An employee who is rated outstanding will receive a 10.2 % raise, one rated acceptable will receive a 7 % raise, and one rated...
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...
Create a program to input the length and width of a rectangle and calculate and print...
Create a program to input the length and width of a rectangle and calculate and print the perimeter and area of the rectangle. To do this you will need to write a Rectangle class and a separate runner class. Your program should include instance variables, constructors, an area method, a perimeter method, a toString method, accessor and mutator methods, and user input. Your runner class should include 3 Rectangle objects. One default rectangle, one coded rectangle, and one user input...
How can we be CERTAIN we know anything at all?
How can we be CERTAIN we know anything at all?
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT