Wednesday, March 7, 2012

The courier company (C++)


Assignment 3

The courier company charge their customers base on the weight of the items they send and the distance.

Consider the table below:

Weight
Charges Rate ( RM/Kilogram)
First 10 Kg
RM 2.00
Next 20 Kg
RM 3.00
Every next 1 kg
RM 4.00

Distance Table

Distance
Charges Rate ( RM/Kilometer)
First 50 km
RM 0.50
Next 100 km
RM 1.00
Next 150 km
RM 2.00
Every next 1 km
RM3.00

The company will not accept any item with weight exceeds 60 kg and also distance that exceeds 500 km.
Write a modular program to count the total charges of each customer, and your program will accept the following input:-

(i)                 total item that should be send
(ii)               weight in kg
(iii)             distance in km


 //PROGRAMMER : Victor.
//DATE : 18 Febraury 2011
//PURPOSE : This programme is used by a curier company
//            to calculate the supposed charge on thier customer
//            weight and distance of the goods based on the


#include "iostream"

    int TotItem, Dis,  Wgt;
    double WgtChr, DisChr, GndChr;

void main()
{
    std::cout<<"\n###########################################"<<std::endl;
    std::cout<<"Please enter the number of items to be curiered ";
    std::cin>>TotItem;//gets the number of goods to be curiered to the entered distance

    std::cout<<"Please enter the weight of the goods ";
    std::cin>>Wgt;//gets the weight of the goods

    if ((Wgt <= 10) && (Wgt < 20))
        WgtChr = 2;
    else if ((Wgt >= 20) && (Wgt <= 20))
        WgtChr = 3;
    else if (Wgt > 20)
        WgtChr = Wgt * 4;
    else
        std::cout<<"Sorry, your goods is an over-wieght"<<std::endl;
   

    std::cout<<"Please enter the distance ";
    std::cin>>Dis;//gets the distance to be travelled

    if (Dis == 50)
    {
            if (Dis == 50)
                DisChr = 0.5;
            else if ((Dis >50)  && (Dis < 100))
                DisChr = 0.5 * Dis; //calculates over distance
    }
    else if (Dis == 100)
    {
            if (Dis == 100)
                DisChr = 0.5;
            else if ((Dis >100) && (Dis <150))
                DisChr = 0.5 * Dis;//calculates over distance
    }
    else if (Dis == 150)
    {
            if (Dis == 150)
                DisChr = 0.5;
            else if ((Dis >150) && (Dis <=500))
                DisChr = 0.5 * Dis;//calculates over distance
    }
    else
    std::cout<<"Sorry, the distance is out of range of our service"<<std::endl;

    GndChr = (WgtChr + DisChr) * TotItem; //calculates the customer's charge

    std::cout<<"\n###########################################"<<std::endl;
    std::cout<<"The services order is :\n\tTotal item is "<<TotItem<<", \n\tWeight is "<<Wgt<<"kg \n\tDistance is "<<Dis<<"km"<<std::endl;
    std::cout<<"The cost of this service is RM"<<GndChr<<".\nPLease pay. Thank you."<<std::endl;
    std::cout<<"\n###########################################"<<std::endl;

    system("PAUSE");
}

No comments:

Post a Comment