Thursday, 14 March 2013
/*
Name : Muhammad Ifwat Bin Sallehuddin
Student ID : 51110113197
Group : L01
Date : 27/02/2013
Question ID : trial
*/
#include<stdio.h>
#define LEVEI1 0.07
#define LEVEI2 0.09
#define LEVEI3 0.15
#define LEVEI4 0.20
void main()
{
float bacaanmeter;
double harga;
char pilihan;
printf("---------------------------------------------------------------------\n");
printf("Sabah Water Services Sdn. Bhd.\n");
printf("Compute and display the water bill for the given meter readings\n");
printf("---------------------------------------------------------------------\n");
printf("X. Compute and display water bill\n");
printf("Y. About\n");
printf("O. Exit \n");
printf("---------------------------------------------------------------------\n");
printf("pilih pilihan anda");
scanf("%c",&pilihan);
switch(pilihan)
{
case 'x':{}
case 'X':{
printf("--------------------------------------------------------------\n");
printf("\nmasukan bacaanmeter<unit>=");
scanf("%f", &bacaanmeter);
if(bacaanmeter>=0 && bacaanmeter<=1000)
{
harga=bacaanmeter*LEVEI1;
printf("untuk bacaanmeter adalah %.2f unit(s), bil air ialah RM %.2f\n",bacaanmeter,harga);
}
else if(bacaanmeter>=1001 && bacaanmeter<=2000)
{
harga=1000*LEVEI1 + (bacaanmeter-1000)*LEVEI2;
printf("untuk bacaanmeter ialah %.2f unit(s), bil air ialah is RM %.2f\n",bacaanmeter,harga);
printf("-------------------------------------------------------------------------\n\n");
}
else if(bacaanmeter>=2001 && bacaanmeter<=3000)
{
harga=1000*LEVEI1 + 1000*LEVEI2 + (bacaanmeter-1000)*LEVEI3;
printf("untuk bacaanmeter ialah %.2f unit(s), bil air ialah RM %.2f\n",bacaanmeter,harga);
printf("-------------------------------------------------------------------------\n\n");
}
else if(bacaanmeter>3001)
{
harga=1000*LEVEI1 + 1000*LEVEI2 + 1000*LEVEI3 + (bacaanmeter-1000)*LEVEI4;
printf("untuk bacaanmeter ialah %.2f unit(s), bil air ialah RM %.2f\n",bacaanmeter,harga);
printf("-------------------------------------------------------------------------\n\n");
}
else
{
printf("makmlumat salah,sila isi kembali");
}
break;
}
case 'y':{}
case 'Y':{
printf("-------------------------------------------------------------------------------\n");
printf("ABOUT\n");
printf("-------------------------------------------------------------------------------\n");
printf("Sabah Water Services Sdn. Bhd.\n");
printf("Compute and display the water bill for the given meter readings\n");
printf("Version 1.1, Copyright 2011");
printf("-------------------------------------------------------------------------------\n");
break;
}
case 'o':{}
case 'O':{
printf("Assalamualaikum and good morning. ");
break;
}
default:{
printf("ATTENTION! You give us the wrong numbers\n");
}
}
}
Subscribe to:
Post Comments (Atom)
QUIZ
ReplyDelete