/* File: Kilowatt-hours.c
Calculate and print bills for the city company.*/

#include <stdio.h>

int main()
{   
    int account_number;
    char code;
    double bills, kilowatt_hours, peak_hours, off_peak_hours;

    printf("Please enter Your account number: \n");
    scanf("%d", &account_number);
    printf("Enter Your user code [R/C/I]: \n");
    printf("R = Residential\n");
    printf("C = Commercial\n");
    printf("I = Industrial\n");
    printf("\nCode = ");
    scanf("&c", &code);

    do
    {
        printf("Invalid code!!!\n");

        if(code != 'R' && code != 'C' && code != 'I')
        {
            printf("Please enter your code again: \n");
            scanf("%c", &code);
        }
    }while(code != 'R' && code != 'C' && code != 'I');

    if(code == 'R')
    {
        printf("Please enter number of the kilowatt-hours: ");
        scanf("%lf", &kilowatt_hours);

        bills = 6.00 + kilowatt_hours*0.045;
        printf("Your bills is RM%.2f\n", bills);
    }

     else if(code == 'C')
    {
        printf("Please enter number of the kilowatt-hours: ");
        scanf("%lf", &kilowatt_hours);
        {
            if(kilowatt_hours <= 1000.00)
            {
                bills = 60.00/1000.00*kilowatt_hours;
                printf("Your bills is RM%.2f\n", bills);
            }
            else
            {
                bills = 60.00 + kilowatt_hours*0.045;
                printf("Your bills is RM%.2f\n", bills);
            }  
        }
    }

    else if(code == 'I')
    {   
        printf("Enter the number for the peak hours: \n");
        scanf("%lf", &peak_hours);
        {
            if(peak_hours <= 1000.00)
            {
                peak_hours = 76.00/1000*peak_hours;
            }
            else
            {
                peak_hours = 76.00 + peak_hours*0.065;

            }  
        }

        printf("Enter the number for the off peak hours: \n");
        scanf("lf", &off_peak_hours);
        {
            if(off_peak_hours <= 1000.00)
            {
                off_peak_hours = 40.00/1000*off_peak_hours;
            }
            else
            {
                off_peak_hours = 40.00 + off_peak_hours*0.028;
            }  
        }

        bills = peak_hours + off_peak_hours;
        printf("Your bills is RM%.2f", bills);
    }   

    return 0;
}

Any coment vf my proram?

Please post your question.
Please use English which every one can understand.
What is vf?

1. Use code tags.
2.

scanf("&c", &code);

3. Your do while will print invalid code even if someone inputs a valid code.
4. Use switch statements instead of if-else.
5. For double I think the format specifier is %f only and not %lf, but not sure.
6. Indent your code properly.

I forget the question already...hehe^^
Oups, sory...I always use sms language...
This is malaysian language, haha!!!

I forget the question already...hehe^^
Oups, sory...I always use sms language...
This is malaysian language, haha!!!

Rubbish! Since when is SMS Malaysian?

I'll give you a tip mate, no one likes a smart a**, especially when:

1) they post unformatted code (USE CODE TAGS!)
2) they whine for help
3) they use stupid titles for their threads - what exactly do you want me to "have a look at"?
4) they refuse to listen to advice given to them about how to post correctly i.e. ask a question and use proper English.

Quite frankly, until I see an improvement in your posting style, I personally will not even waste a second about even thinking about helping you out.

Sory, i am not not good in english, i apologice for my broken language.
I will improve myself, so hope u can excuse me.

Its ok hket89, our point is use the english whatever you know, don't make it like SMS language, even if you are not understandable it is OK, but don't use SMS like language.
Now, if you dont have question just mark this thread as solved, so that people will stop posting here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.