Monday, 8 April 2013
case
#include<stdio.h>
#define LEVEI1 0.10
#define LEVEI2 0.15
#define LEVEI3 0.20
#define LEVEI4 0.25
void main()
{
float meterReading;
double price;
char choice;
printf("-------------------------------------------------------------------------------\n");
printf("Syarikat Air Darul Aman Sdn. Bhd. <SADA>\n");
printf("Compute and display the water bill for the given meter readings\n");
printf("-------------------------------------------------------------------------------\n");
printf("1. Compute and display water bill\n");
printf("2. About\n");
printf("0. Exit \n");
printf("-------------------------------------------------------------------------------\n");
printf("Please enter your choice=");
scanf("%c",&choice);
switch(choice)
{
case 'x':{}
case '1':{
printf("--------------------------------------------------------------\n");
printf("\nPlease enter the meter reading<unit>=");
scanf("%f", &meterReading);
if(meterReading>=0 && meterReading<=1000)
{
price=meterReading*LEVEI1;
printf("for meter reading is %.2f unit(s), the water bill is RM %.2f\n",meterReading,price);
}
else if(meterReading>=1001 && meterReading<=2000)
{
price=1000*LEVEI1 + (meterReading-1000)*LEVEI2;
printf("for meter reading is %.2f unit(s), the water bill is RM %.2f\n",meterReading,price);
printf("-------------------------------------------------------------------------\n\n");
}
else if(meterReading>=2001 && meterReading<=3000)
{
price=1000*LEVEI1 + 1000*LEVEI2 + (meterReading-1000)*LEVEI3;
printf("for meter reading is %.2f unit(s), the water bill is RM %.2f\n",meterReading,price);
printf("-------------------------------------------------------------------------\n\n");
}
else if(meterReading>3001)
{
price=1000*LEVEI1 - 1000*LEVEI2 - 1000*LEVEI3 + (meterReading-1000)*LEVEI4;
printf("for meter reading is %.2f unit(s), the water bill is RM %.2f\n",meterReading,price);
}
else
{
printf("You type the wrong number please try again");
}
break;
}
case 'y':{}
case '2':{
printf("-------------------------------------------------------------------------------\n");
printf("**********************************ABOUT****************************************\n");
printf("-------------------------------------------------------------------------------\n");
printf("Syarikat Air Darul Aman Sdn. Bhd. <SADA>\n");
printf("Compute and display the water bill for the given meter readings\n");
printf("Version 2.1, Copyright 2012\n");
printf("Developer Name:Yosof Kadase, ykadase@gmail.com\n");
printf("-------------------------------------------------------------------------------\n");
break;
}
case 'o':{}
case '0':{
printf("BYE!\n");
break;
}
default:{
printf("Wrong/invalid input!\n");
printf("bye bye ! !\n");
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment