Asked by DJ
Create a program that determine the shipping cost for an order based on the following table:
From
$0.00
$20.00
$50.00
$75.00
To
$19.99
$49.99
$79.99
$1000.00
Price
$2.95
$3.95
$4.95
Free
From
$0.00
$20.00
$50.00
$75.00
To
$19.99
$49.99
$79.99
$1000.00
Price
$2.95
$3.95
$4.95
Free
Answers
Answered by
Steve
here's some perl. Modify to suit your needs:
@cost = (0.00,0.00,20.00,50.00,75.00);
@ship = (0.00,2.95,3.95,4.95,0.00);
while (1) {
print "Enter order amount: \$";
$c = <STDIN>;
for ($i = $#cost ; $i > 0 ; $i--) {
last if $c >= $cost[$i];
}
printf "Shipping: \$%4.2f\n",$ship[$i];
}
@cost = (0.00,0.00,20.00,50.00,75.00);
@ship = (0.00,2.95,3.95,4.95,0.00);
while (1) {
print "Enter order amount: \$";
$c = <STDIN>;
for ($i = $#cost ; $i > 0 ; $i--) {
last if $c >= $cost[$i];
}
printf "Shipping: \$%4.2f\n",$ship[$i];
}
Answered by
DJ
My teacher said this is not the right. Were doing Raptor Program.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.