Results 1 to 4 of 4
  1. #1
    Programmer3 is offline Member
    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Default Error in calculator program

    import java.awt.*;
    class Calc
    {
    static String s[]={"MC","MR","Ms","M+","<-","CE","7","8","9","*","C","6","5","4","-","M-","1","2","3","\",".","1\x","0","+","="};
    Frame f;
    Button b;
    TextField tf;
    int i,k=0,j=0,l=0;

    Calc(String s1)
    {
    f=new Frame(s1);
    tf=new TextField();
    tf.setBounds(10,40,290,40);
    f.add(tf);
    for(i=0;i<19;i++)
    {
    b=new Button(s[i]);
    b.setBounds(10+j,100+k,40,40);
    f.add(b);
    l++;
    j+=60;
    if(l%5==0)
    {j=0;
    k=k+60;
    }
    }f.setLayout(null);
    f.setSize(300,400);
    f.setVisible(true);
    }

    public static void main(String s2[])
    {

    Calc c=new Calc("Standard Calculator");

    }

    }



    this is an simple calculator design..but why this is giving error ?? <identifier>excepted at 4th line ....help me out..

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Error in calculator program

    Removed from What are you using to write your code?

    When you have a question, start a new thread. Don't ask it just anywhere.

    Also, go through these:
    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Error in calculator program

    Why, in this day and age, are you using AWT components? AWT was superseded by Swing more than 10 years ago.

    Oh, and learn how code should be formatted for readability: Code Conventions for the Java Programming Language: Contents

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,925
    Rep Power
    19

    Default Re: Error in calculator program

    Please use [code] tags [/code] when posting code.
    Many people will not bother trying to read unformatted code.

    Also please post the full error message you are getting, highlighting the line in your code it is occurring on.
    Many people will not copy, paste and compile your code in order to see the problem.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Calculator Program
    By CODinacup in forum New To Java
    Replies: 4
    Last Post: 09-27-2012, 11:35 PM
  2. Calculator error?
    By RexBox in forum New To Java
    Replies: 5
    Last Post: 09-05-2012, 12:12 PM
  3. Problem with if statement in a calculator program
    By peterhabe in forum New To Java
    Replies: 2
    Last Post: 08-26-2011, 05:07 PM
  4. Calculator program
    By kevzspeare in forum New To Java
    Replies: 6
    Last Post: 03-18-2009, 01:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •