Post a New Question

computers - Programming

posted by on .

Create a program that uses two parallel one-dimensional arrays. The program displays a shipping charge that is based on the number of items ordered by a customer. The shipping charge scale is shown in Figure 1 below. Store the maximum order amounts in a one dimensional int array. Store the shipping charge amounts in a parallel one dimensional int array. The program should allow the user to enter the number of items a customer ordered. It then should display the appropriate shipping charge. Use a sentinel value to stop the program. Save and then run the program. Test the program appropriately.

Min.Order Max.Order ShippingCharge
1 10 15
11 50 10
51 100 5
101 99999 0

  • computers - Programming - ,

    Here's a little perl ditty that should do the trick. Adapt to the language of choice.

    my @max = (10,50,100,99999);
    my @sc = (15,10,5,0);

    do {
     print "enter amount ordered: ";
     my $amt = <>;
     last if $amt <= 0;
     printf "Order: %5d -- Shipping Charge: \$%d\n",$amt,pop grep($amt<$_,@sc);
    }

  • computers - Programming - ,

    my @max = (10,50,100,99999);
    my @sc = (15,10,5,0);

    do {
    print "enter amount ordered: ";
    my $amt = <>;
    last if $amt <= 0;
    printf "Order: %5d -- Shipping Charge: \$%d\n",$amt,pop grep($amt<$_,@sc);
    }

Answer This Question

First Name:
School Subject:
Answer:

Related Questions

More Related Questions

Post a New Question