Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help

    I am developing a short program of electricity bill where i taking input Reidential or commercial but i have face many problems kindly see my program code and correct the code and show my mistakes.Thanks
    import java.io.*;
    public class Final
    {
    public static void main(String args[]) throws IOException
    {
    InputStreamReader reader = new InputStreamReader(System.in);
    BufferedReader input = new BufferedReader(reader);
    System.out.print("Please Enter your Units: ");
    String userInput=input.readLine();
    int userUnits=Integer.parseInt(userInput);
    System.out.print("Please Enter your Units type Residential Commercial : ");
    String userUnitstype=input.readLine();
    int unitcostC=0;
    int unitcostR=0;
    if
    (userUnits<100 & userUnits>1)
    {
    unitcostC=12;
    unitcostR=5;
    }
    else if (userUnits>=100 & userUnits<200)
    {
    unitcostC=17;
    unitcostR=7;
    }
    else if (userUnits>=200 & userUnits<500)
    {
    unitcostC=22;
    unitcostR=11;
    }
    else{
    unitcostC=30;
    unitcostR=15;
    }
    int totalamount1=userUnits*unitcostC;
    int totalamount2=userUnits*unitcostR;
    if
    (userUnitstype=="C")
    totalamount1=userUnits*unitcostC;
    else
    totalamount2=userUnits*unitcostR;
    System.out.println("Your Total amount is: "+totalamount1);
    System.out.println("Your Total amount is: "+totalamount2);

    }
    }

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,066
    My Mood
    Mellow
    Thanks
    184
    Thanked 652 Times in 639 Posts

    Default Re: Help

    Please post your code in code tags. You can learn how by viewing the Announcements at the top of the What's Wrong With My Code forum. If you're getting errors, post them. If you have questions, ask them. Don't expect us to beta test/debug, correct, and post fixed code.