//Exercise 2.3 Calculating Volume price of alternative products//The only problem here's to devise a by determine the price//For the product type. Here I used the product type of value to does this.#include <stdio.h>intMainvoid){ DoubleTotal_price =0.0;// Total Price intType =0;//Product Type intQuantity =0;//Quantity ordered Const DoubleType1_price =3.50; Const DoubleType2_price =5.50; //Get the Product typeprintf"Enter the type (1 or 2):"); scanf ("%d", &type); //Get The order quantityprintf"Enter The quantity:"); scanf ("%d", &quantity); //Calculate The total priceTotal_price = quantity* (Type1_price + (Type-1) * (Type2_price-type1_price)); //Output the areaprintf"The price for %d of type%d is $%.2f\n", quantity, type, total_price); return 0;}
Most Important:
Total_price = quantity* (Type1_price + (type-1) * (Type2_price-type1_price));
Exercise 2.3 Calculating volume price of alternative products