Write a C++ program that calculates charges based on the parcel's weight and distance to be shipped. The weight charges are:

- 0-5 kilos: 35 dollars per kilo
- 5-6 kilos: 40 dollars per kilo
- 6-7 kilos: 45 dollars per kilo
- Over 7 kilos is not acceptable/invalid.

Answer :

This C++ program shipping charges based on the parcel's weight. It checks the inputted weight and applies the correct rate per kilo for shipping. If the weight is over 7 kilos, it outputs an error message.

The subject of your question is related to the computers and technology field specifically programming in C++. Here is a simple program to calculate the shipping charges based on the parcel's weight.

#include using namespace std; int main () { float weight; cout << "Enter weight of parcel in kilos: "; cin >> weight; float charge; if (weight > 0 && weight <= 5) charge = weight * 35; else if (weight > 5 && weight <= 6) charge = weight * 40; else if (weight > 6 && weight <= 7) charge = weight * 45; else { cout << "Invalid weight. Over 7 kilos is not acceptable."; return 0; } cout << "The charge for shipping is: $" << charge << "\n"; return 0; }

This program first takes the weight of the parcel as input. It then calculates the shipping charge based on the weight. If the weight is between 0 and 5 kilos, the charge is 35 dollars per kilo. For a weight between 5 and 6 kilos, it's 40 dollars per kilo, and for 6 to 7 kilos, it's 45 dollars per kilo. If the weight is over 7 kilos, the program displays an error message and terminates.

Learn more about the topic of C++ program here:

https://brainly.com/question/33180199

#SPJ11

Other Questions