write a c++ program that prompts the user to enter the shipement weight in kilograms and the distance to the shipment destination, the program reads the weight and distance, calculate the shipment cost, displays this cost on the screen, invalid disply if the distance is in negetive, shipmennt rate per kg
distance
more than 1000 rate = 20
between 500 and 1000 rate = 15
between 0-500 rate = 10
less than 0 rate = --
#include<stdio.h>
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float weight;
int distance;
cout << "\n Shippment Rate Per kg";
cout<<"\n -----------------------";
cout << "\n Distance Shipment Charges";
cout <<
"\n____________________________________";
cout << "\n More than 1000 km 20";
cout << "\n Between 500 and 1000 km 15";
cout << "\n Between 0 and 500 km 10";
cout << "\n Less then 0 km Nil";
cout <<
"\n____________________________________";
cout << "\n Enter the weight in Kilograms:
";
cin >> weight;
cout<<"\n Enter the Distance to the Shipment
Destination:";
cin>>distance;
if(distance >= 1000)
{
float ship_cost = (20 * weight)/distance;
printf("\n The Rate is:20");
printf("\n Total cost = %f",ship_cost);
}
else
if(distance >=500 && distance <
1000)
{
float ship_cost = (15 * weight)/distance;
printf("\n The Rate is: 15");
printf("\n Total cost = %f", ship_cost);
}
else
if(distance >=0 && distance <500)
{
float ship_cost = (10 * weight)/distance;
printf("\n The Rate is : 10");
printf("\n Total cost = %f",ship_cost);
}
else
printf("\n Invalid Display ");
return(0);
}
Get Answers For Free
Most questions answered within 1 hours.