void setup(){
float cost = cal_charge(1, 0, 15);
}
float cal_charge(int packaging, int services ,float weight){
float add;
println("Type of package (Letter=0/Box=1) is " +packaging);
println("Type of service (Next Day Priority=0/Next Day Standard=1/Two-Day=2) is " +services);
println("Weight is " +weight +" oz");
println();
if(packaging == 0 && services == 0 && weight <= 8) //Letter ,Next Day Priority
{
println("The total is $12.00");
}
else if(packaging == 0 && services == 1 && weight <= 8) //Letter ,Next Day Standard
{
println("The total is $10.50");
}
else if(packaging == 0 && services == 2) //Letter ,Two-Day
{
println("Not avaliable");
}
else if(packaging == 1 && services == 0) //Box ,Next Day Priority
{
if (weight <= 16)
{
println("The total is $15.75"); //Weight at 1 pound
}
else
{
weight = weight/16;
add = 15.75+((ceil(weight)-1)*1.25);
println("The total is $" +add); //Weight over 1 pound
}
}
else if(packaging == 1 && services == 1) //Box ,Next Day Standard
{
if (weight <= 16)
{
println("The total is $13.75"); //Weight at 1 pound
}
else
{
weight = weight/16;
add = 13.75+((ceil(weight)-1)*1.00);
println("The total is $" +add); //Weight over 1 pound
}
}
else if(packaging == 1 && services == 2) //Box ,Two-day
{
if (weight <= 16)
{
println("The total is $7.00"); //Weight at 1 pound
}
else
{
weight = weight/16;
add = 7.00+((ceil(weight)-1)*0.50);
println("The total is $" +add); //Weight over 1 pound
}
}
return weight;
}

No comments:
Post a Comment