Only able to do the 1st question..but got syntac error. No sure where's the problem.
Question 1 (Answer)
Code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
main ()
{
int a, b, e, account;
double gallon, total1, total2;
char selection, h, c, i;
printf("Below are the type of places that covered by city water company.\n");
printf("Please enter your account number:");
scanf("%d", &account);
printf("Press <h> for House use.\n");
printf("Press <c> for Commercial use.\n");
printf("Press <i> for Industrial use.\n");
printf("Please specify the type of place:");
scanf("%c %c %c", h, c, i);
if(selection=h)
printf("Please enter the total gallon used:");
scanf("%f", &gallon);
a=gallon*0.0005;
total1=a+5;
printf("The total bill is:");
scanf("%f", &total1);
Z else if(selection=c)
printf("Please enter the total gallon used:");
scanf("%f", &gallon);
b=gallon-4000000;
e=b*0.00025;
total2=1000+e;
printf("The total bill is:");
scanf("%f", &total2);
else if(selection=i)
printf("Please enter the total gallon used:");
scanf("%f", &gallon);
{
if(gallon<4000)
printf("The total bil is: RM1000");
else if(gallon>4000000 & gallon<10000000)
printf("The total bil is: RM2000");
else if(gallon>1000000)
printf("The total bil is: RM3000");
else
printf("Not been billed");
}
else
print("You have enter wrong code");
getch();
return (0);
}