well i finally decided to try out this site, for the reason of my problem.
i don't understand why my code is not working properly every thing looks to be in place, i could use some help : (
#include<iostream>
#include<iomanip>
using namespace std;
int main ()
{
double weight,miles,total;
cout << "Welcom to fast-A$$ shiping" <<endl;
cout << "Please enter the weight then miles you wish ship:";
cin >> weight;
cout << "now miles ";
cin >> miles;
cout << setprecision(2) << fixed << showpoint;
if (miles >= 3000)
{
cout <<"you dont know anyone that far away " <<endl;
return 0;
}
if (miles <= 10)
{
cout <<"well if its that close why dont you walk?" <<endl;
return 0;
}
if (weight <= 0)
{
cout <<"we dont ship one half sheet of paper, sorry " <<endl;
return 0;
}
if (weight <= 2)
{
total = 500 / miles * 1.10;
cout <<"your cost for delivery is:$"<< total <<endl;
return 0;
}
if (weight <= 6)
{
total = 500 / miles * 2.20;
cout <<"your cost for delivery is:$"<< total <<endl;
return 0;
}
if (weight <= 10)
{
total = 500 / miles * 3.70;
cout <<"your cost for delivery is:$"<< total <<endl;
return 0;
}
if (weight >= 20)
{
total = 500 / miles * 4.80;
cout <<"your cost for delivery is:$"<< total <<endl;
return 0;
}
if (weight <= 21)
{
cout <<"sorry your mail is to heavy"<< total <<endl;
return 0;
}
Actually as I see, it has to be with if...else statements.
Because a number less than 2 is less than 6, less than 10 and so on.
So you have to use if...else to calculate only for one of those.
not neccessarily. Notice in the end of each of his if statements he returns.
This will skip all the rest of the if statments or any code following for that matter. it returns out of the function call, or if used in main, exits out of the program completely.
well i tried out the program and its acting odd its should work like this every 500 miles it ads money on to the delivery but it does not work instated, the farther you go and the more weight the delivery is the less it cost, to ship a 10 pound box 44 miles cost $10.00 but to send a 3 pound box 2000 miles its like $1.50 how do i turn this around?
On my system the 10 pound box would cost $42.05
By the way the further the distance the smaller the calculation 500/miles will become.
so for 2000 miles - 500/2000 = 0.25 so that 3 pound box will cost
0.25 * $2.2 which is 55 cents. ($0.55).
So for any given weight the further you ship it the cheaper it becomes.
(Those figures are calculated from the code you posted)