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

15. Complete the program below so that it computes the price of a piece of glass

ID: 3936391 • Letter: 1

Question

15. Complete the program below so that it computes the price of a piece of glass. Pieces of glass are usually priced based on the type of glass and the area of the piece, but there is a minimum charge of $2.00. For clear glass (glass type 1), the charge is $6.00 per square meter; for frosted glass (type 2), the price is $10.00 per square meter. For example, the cost of a 0.25-square-meter piece of clear glass is 2.00 since 0.25 * $6.00 is $1.50, an amount less than the minimum charge. The price ofa 2.4-square-meter piece of frosted glass is $24.00 (2.4 * 10.00). You do not need to do error checking in the program. #include #define CLEAR #define SQMETER-CLEAR 6.00 #define FROSTED #define SQMETER-FROSTED 10.00 #define MINIMUM 2.00 int main(void) double price, area; int type; printf("Enter glass type: %d (clear) or 96d (frosted)> ", CLEAR, FROSTED); 14 scanf("%d", &type;); printf("Enter area in square meters> "): scanff"nlf". &area;: 16

Explanation / Answer

#include<stdio.h>
#define CLEAR 1
#define SQMETER_CLEAR 6.00

#define FROSTED 2
#define SQMETER_FROSTED 10.00

#define MINIMUM 2.00

int main()
{
   double price, area;
   int type;

   printf("Enter glass type:< %d(clear) or %d(frosted)> ",CLEAR, FROSTED);
   scanf("%d",&type);
   printf("Enter area in square meters ");
   scanf("%lf",&area);
   switch(type)
   {
   case 1:
           price = SQMETER_CLEAR * area;
           break;
   case 2:
           price = SQMETER_FROSTED * area;
           break;
   default:
           printf("type is invalid try again..... ");
           break;
   }
   if( price < 2)
   {
       printf(" Minimum charge is $%.2lf ", MINIMUM);
       printf("price for %.2lf square meter = $%.2lf ",area,MINIMUM);
   }
   else
       printf("price for %.2lf square meter = $%.2lf ",area,price);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote