Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m trying to code part of a Amazon/Ebay-esque delivery program. The part I nee

ID: 3581218 • Letter: I

Question

I'm trying to code part of a Amazon/Ebay-esque delivery program. The part I need help with is the part that requires there to be a delivery charge added to the total cost. The delivery charge varies based on the total cost. If the total cost (before delivery and tax) is between $0 to $5, the delivery charge is $5. If the total cost is between $5.01 to $10, then the delivery charge is $3. If the total cost is greater than $10, then there is no delivery charge ($0.00). How would I code this part of the program?

Explanation / Answer

I am not sure on which paltform and using which language you are trying to implement this scenario, but based on the given conditions I can say that it can be implemented easily.

you can use If else combination for this like..

initialTotalCost ; //cost without delivery and tax

finalCost;

if(initialTotalCost >=0 and initialTotalCost <=5){

finalCost = initialTotalCost +5; //5 is the delivery cost

}

else if(initialTotalCost >=5.01 and initialTotalCost <=10){

finalCost = initialTotalCost +3; //3 is the delivery cost

}

else if(initialTotalCost >10){

finalCost = initialTotalCost ;

}