for loop problem
in
Programming Questions
•
4 months ago
on line 24 i keep getting "unexpected token: i" error, if I put
int before the "i" it says "expected COLON found =" please help.
thanks.
- String input="";
- String error="";
- boolean done=false;
- float a=0;
- float b=0;
- float c=0;
- int var=1;
- int i=0;
- void setup(){
- size(640,360);
- }
- void draw(){
- background(256,256,256);
- fill(0,0,0);
- text("Input numbers:", 20, 40);
- text(a+"x^2+"+b+"x+"+c, 20, 60);
- text(input,110,40);
- fill(256,0,0);
- text(error,256,80);
- if (done==true){
- for(i = (-(b)/2(a))-2; i < (-(b)/2(a))+2; i++){
- float[] points;
- points.add(i);
- }
- }
- }
- void keyPressed(){
- if((key >= '0' && key <= '9')||key == '.'){
- input += key;
- }else if(key == BACKSPACE){
- if(input==""){
- }else{
- input = input.substring( 0, input.length()-1 );
- }
- }else if(key == ENTER){
- switch (var){
- case 1:
- if(input.equals("")){
- error = "Pleas input a number";
- break;
- }else{
- a = Float.parseFloat(input);
- input = "";
- error ="";
- println(a);
- var++;
- }
- break;
- case 2:
- if(input.equals("")){
- error = "Pleas input a number";
- break;
- }else{
- b = Float.parseFloat(input);
- input = "";
- error ="";
- println(b);
- var++;
- }
- break;
- case 3:
- if(input.equals("")){
- error = "Pleas input a number";
- break;
- }else{
- c = Float.parseFloat(input);
- input = "";
- error ="";
- println(c);
- var++;
- }
- done = true;
- break;
- }
- }
- }
1