import java.util.Scanner;
package p1;
class Electricity
{
    int cread=18634,fix_rate,due,ub_tax,curr_charge,bill,to_bill ;
    int pread,unit ;
    System.out.println("fix_rate=");
    Scanner sc=new Scanner(System.in);
    int fix_rate=sc.nextInt();  
    System.out.println("due=");
    int due= sc.nextInt();
    System.out.println("ub_tax=");
    int ub_tax= sc.nextInt();
    System.out.println("curr_charge=");
    int curr_charge= sc.nextInt();
    System.out.println("unit=");
    int unit=sc.nextInt();
    public void calc()
    {
    do
    {
    pread=cread-unit;
    System.out.println("fix_rate=" +pread);
    }
    while(unit<200)
        {
            int c1=2.75*unit;
            System.out.println(c1);
        }
    while(200< unit >300)
        {
            int c2=3.00*unit;
            System.out.println(c2);
        }
    while(300< unit > 450)
        {
            int c3= 4.65*unit;
            System.out.println(c3);
        }
    }
    public static void main (String[] arg)
    {
      Electricity e=new Electricity();
      e.calc();
    }
}   

**Errors are:**   

Electricity.java:2: class, interface, or enum expected
package p1;
^
Electricity.java:7: <identifier> expected
    System.out.println("fix_rate=");
                      ^
Electricity.java:7: illegal start of type
    System.out.println("fix_rate=");
                       ^
Electricity.java:10: <identifier> expected
        System.out.println("due=");
                          ^
Electricity.java:10: illegal start of type
        System.out.println("due=");
                           ^
Electricity.java:12: <identifier> expected
        System.out.println("ub_tax=");
                          ^
Electricity.java:12: illegal start of type
        System.out.println("ub_tax=");
                           ^
Electricity.java:14: <identifier> expected
        System.out.println("curr_charge=");
                          ^
Electricity.java:14: illegal start of type
        System.out.println("curr_charge=");
                           ^
Electricity.java:16: <identifier> expected
        System.out.println("unit=");
                          ^
Electricity.java:16: illegal start of type
        System.out.println("unit=");
                           ^
Electricity.java:25: ';' expected
        while(unit<200)
                       ^
12 errors

Exactly what errors? - post the complete text of all your error message, don't expect people to guess.
[edit] Thank you. You should expect some answers now.

certain code must be within a method, for instance the

System.out.println(); statements

and the package statement must be the very first in your code, before any import statements.

what is the error in "Do-while" code ?

for each while, you need a do. after each while (which is the end of the statement) you need to put a ;
also: you are trying to assign double values to an int. your compiler won't like that very much. and, you are twice instantiating the same variable (which is something you do a lot).

my advice, erase that code and start over. refactoring it (for someone with little experience in Java) will be just as much work as rewriting it.
write and test it in small blocks. then you know when you run into errors exactly where the problem lies.

don't keep writing until you are finished with what you think might work, I assume that's the approach you used before, but the result you got is why you shouldn't have done that.

^ excellent advice. You can, and should, test code as early and as often as possible. Waiting until all the code is "finished" makes it really hard to tell where things are going wrong - it could be anywhere. If you test code as you go then any problems are most likely to be in the most recent additions.

okk...i'll try now
n Thanxx for d advice :)

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.