Results 1 to 4 of 4
Thread: Error in calculator program
- 10-02-2012, 11:07 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 1
- Rep Power
- 0
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..
- 10-02-2012, 12:42 PM #2
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
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 10-02-2012, 12:48 PM #3
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
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 10-02-2012, 12:49 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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.
Similar Threads
-
Calculator Program
By CODinacup in forum New To JavaReplies: 4Last Post: 09-27-2012, 11:35 PM -
Calculator error?
By RexBox in forum New To JavaReplies: 5Last Post: 09-05-2012, 12:12 PM -
Problem with if statement in a calculator program
By peterhabe in forum New To JavaReplies: 2Last Post: 08-26-2011, 05:07 PM -
Calculator program
By kevzspeare in forum New To JavaReplies: 6Last Post: 03-18-2009, 01:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks