having a real hard time with this script here is all the info it is due the 19th and would be a really big help thanks
Prompt the user to enter the number of items purchased and the cost of the item. Remember to parse
each of the inputs as you will use them in calculations.
You have 2 different options for shipping, either a flat rate of 10% of total cost or a shipping schedule.
You have to determine the total price of the item using each shipping method and output which shipping
method is cheaper.
First, calculate the subtotal of the transaction by multiplying the amount of items purchased by the cost
of the item. Store this value into a variable called subtotal.
Second, calculate the cost of the flat rate shipping option and store the result in a variable called total1.
Calculation should look like this…
total1 = subtotal + (subtotal * .1);
Next, calculate the cost of shipping using the second method. Use the following shipping schedule.
Subtotal Shipping Cost
Under 25 dollars $4.56
Over 25 dollars $7.39
To do this, use an if statement to determine the amount of shipping to add onto the item. If the subtotal
is under $25, add $4.56 onto the subtotal and store the result in a variable called total2. If the subtotal is
over $25, add $7.39 onto the subtotal and store the result into total2.
Your if statement should look like this…
if( subtotal > 25 )
{
total2 = subtotal + 7.39;
}
else
{
total2 = subtotal + 4.56;
}
Print the cost per item, the number of items purchased, the subtotal, total1, and total2 all on separate
lines.
Page 2 of 2
Last, determine which was the cheaper shipping method and print a suitable message. Compare total1
and total2 using
if( total1 < total2 )
{
print a message stating flat rate shipping method is cheapest.
}
else
{
print a message stating shipping schedule is cheapest.
}
Sample Output
Cost of item: 5.50
Number of items: 6
Subtotal: 33
Flat rate shipping total: 36.30
Shipping schedule total: 40.39
Flat rate shipping is cheaper!!!