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

I have a question about a homework assignment. int number_of_items=3; double[] p

ID: 674190 • Letter: I

Question

I have a question about a homework assignment.

int number_of_items=3;
double[] price=new double[number_of_items];
double[] shipping_and_handling=new double[number_of_items];
price[0]=15.35; shipping_and_handling[0]=3.99;
price[1]=38.25; shipping_and_handling[1]=7.75;
price[2]=12.99; shipping_and_handling[2]=2.50;

int number_of_states=50;
int ALABAMA_ID=0;
int ALASKA_ID=1;
int CALIFORNIA_ID=2;
int FLORIDA_ID=3;
....
int WASHINGTON_ID=49;
float[] sales_tax=new float[number_of_states];
sales_tax[0]=0.06.5;
sales_tax[1]=0.0575;
sales_tax[2]=0.125;
sales_tax[3]=0.0675;
....
sales_tax[49]=0.075;

double total_price=0;
for(int i=0;i<number_of_items;i=i+1)
total_price=total_price+price[i];

double total_shipping_and_handling=0
for(int i=0;i<number_of_items;i=i+1)

total_shipping_and_handling=total_shipping_and_handling+shipping_and_handling[i];

if(total_price>35.00)
total_shipping_and_handling=0

double grand_total=(total_price+total_shipping_and_handling)*(1+sales_tax[CALIFORNIA_ID]);

Based on the above program, select ALL statements that are correct:

1.) In this purchase, the cart has 2 products
2.) In this purchase, the total "shipping and handling" is $14.24 (i.e) 3.99+7.75+2.50
3.) All purchases of $35 or more have free shipping
4.) The tax in this purchase is 12.50%
5.) This transaction takes place in California

Explanation / Answer

Based on the above program.

1.) In this purchase, the cart has 2 products

Answer: Not correct(as per the above program the cart has 3 products i.e "int number_of_items=3;")


2.) In this purchase, the total "shipping and handling" is $14.24 (i.e) 3.99+7.75+2.50

Answer: correct (shipping_and_handling[0]=3.99; shipping_and_handling[1]=7.75;shipping_and_handling[2]=2.50;)


3.) All purchases of $35 or more have free shipping

Answer: Correct (if(total_price>35.00)total_shipping_and_handling=0))
4.) The tax in this purchase is 12.50%

Answer: Correct (sales_tax[2]=0.125; here transaction takes place in California and its id is2)
5.) This transaction takes place in California

Answer: Correct(double grand_total=(total_price+total_shipping_and_handling)*(1+sales_tax[CALIFORNIA_ID]);)

So The statements that are correct are 2,3,4,5