1.#include<stdio.h>
int main(void)
{
int area;
float weight,price,x1,x2;
scanf("%d,%f",&area,&weight);
if (weight<=1)
{
x1=1.0;
}
else
{
x1=1.0;
x2=ceil(weight-1);
}
if (area>0&&area<=4)
{
switch(area)
{
case(0):price=x1*10+x2*3;break;
case(1):price=x1*0+x2*4;break;
case(2):price=x1*15+x2*5;break;
case(3):price=x1*15+x2*6.5;break;
case(4):price=x1*15+x2*10;break;
}
printf("Price: %5.2f\n",price);
}
else
{
printf("Error in Area\n");
printf("Price: 0.00\n");
}
return 0;
}
2.
#include<stdio.h>
int main(void)
{
printf("Enter item number:\n");
int n;
scanf("%d",&n);
printf("Enter unit price:\n");
float p;
scanf("%f",&p);
printf("Enter purchase date (mm/dd/yy):\n");
int m,d,y;
scanf("%d/%d/%d",&m,&d,&y);
printf("Item Unit Purchase\n");
printf("%-9d$ %-9.2f%02d%02d%02d\n",n,p,m,d,y);
return 0;
}