#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    14
    Rep Power
    0

    i got tis so far! help me out!


    #include <iostream>
    using namespace std;

    int main()
    {
    float distance,cost,weight;
    cout<<"Weight of Package (in Kg) "<<"Rate Per 500 Miles Shipped"<<endl;
    cout<< "what is the distance shipped? ";
    cin>> distance;
    cout<< "what is the weight of the package? ";
    cin >> weight;
    if(weight<2)
    cout<<"2Kg or less "<<"$1.10"<<endl;
    else if (weight<6)
    cout<<"Over 2 Kg but not more than 6 Kg "<<"$2.20"<<endl;
    else if (weight<10)
    cout<<"Over 6 Kg but not more than 10 Kg "<<"$3.70"<<endl;
    else if (weight<20)
    cout<<"Over 10 Kg but not more than 20 KG "<<"$4.80"<<endl;
    else if (weight<30)
    cout <<"dont accept"<<endl;
    return 0;
    }

    help me with this program plz.
    Shipping Charges
    The Fast Freight Shipping Company charges the following rates:

    Weight of Package (in Kg) Rate Per 500 Miles Shipped
    2Kg or less $1.10
    Over 2 Kg but not more than 6 Kg $2.20
    Over 6 Kg but not more than 10 Kg $3.70
    Over 10 Kg but not more than 20 KG $4.80

    Write a program that asks for the weight of the package and the distance it is
    to be shippped and then displays the charges.

    Input validation: do not accept values of 0 or less for the weight of the
    package. Do not accept weights of more than 20 Kg. Do not accept distances of
    less than 10 miles or more than 3000 miles. These are the company's minimum and
    maximum shipping distances.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    121
    Rep Power
    12
    That is not very good code at all. You should use proper formatting, it makes it much more readable. Use proper indentation, etc..

    Your boolean expressions are not correct, you should re-do that one.

    As a moderator said in your last post, I am not going to do your homework for you. You should re-read the chapter though. I am betting this thread will get closed also...
  4. #3
  5. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    To follow up Ed's reply:

    Your subject title still is unacceptable, read the sticky thread I refered you to in your first thread for more information on how to post a question.

    If you get stuck with a particular problem, have questions, etc, then this forum is a great place to come and people will not generally hesitate to help you. When you come here and want someone to do your homework for you, well you're just likely to get flamed.

    Once again, I'm closing this thread.

IMN logo majestic logo threadwatch logo seochat tools logo