Just post is a new courier service company which services all provinces in the South Africa. They charge
their customers based on the weight of the parcel as indicated in the table below. However, if kilograms
are above 50, the cost is charged according to the number of hours it took to deliver. Although the time
is entered in minutes but they are charged R95.00 per hour. Clients may also add some extras to the
delivery such as insurance which is charged 8.5% and priority is charged at 5% of the charge.
Distance Weight Cost (R)
Local Under 5 kg R125.00
Local 5 kg up to 20 kg R175.00
Local Over 20 Kg R250.00
Long Under 5 kg R390.00
Long 5 kg up to 20 kg R450.00
Write a program that will assist with calculating the postage amount.
2.1 Create a C++ source file called Postage and save it in a file called Postage.cpp.
2.2 Create the following functions:
#include<iostream>
using namespace std;
int main(){
float post,time, rate, total_price;
cout<<"\n Please enter the weight of the courier \n"<<endl;
cin>>post;
cout<<"\n The weight of the courier is: \n"<<post<<endl;
cout<<"\n Please enter the total time taken to deliver the courier: \n"<<endl;
cin>>time;
if(0<post && post<5){
total_price=125+125*0.085+125*0.05;
cout<<"\n The rate of the courier will be:"<<total_price<<endl;
}else{
if(post<0){
cout<<"Post is invalid"<<endl;
}else{
if(5<=post && post<20){
total_price=175+175*0.085+175*0.05;
cout<<"\n The rate of the courier will be:"<<total_price<<endl;
}else{
if(20==post){
total_price=250+250*0.85+250*0.05;
cout<<"\n The rate of the courier will be:"<<total_price<<endl;
}else{
if(20<post&&post<=25){
total_price=390+390*0.085+390*0.05;
cout<<"\n The rate of the courier will be:"<<total_price<<endl;
}else{
if(25<post && post<50){
total_price=450+450*0.085+450*0.05;
cout<<"\n The rate of the courier will be:"<<total_price<<endl;
}else{
total_price=450+95*time;
total_price=total_price+total_price*0.085+total_price*0.05;
cout<<"\n The rate of the courier will be:"<<total_price<<endl;
}
}
}
}
}
}
return 0;
}
Comments
Leave a comment