• fullscreen
  • multiplication.pde
  • PFont f;
    int x=0;
    int y=0;
    int input=0;
    String typing ="";
    String saved ="";
    
    void setup() {
      size(900,600);
      background(200);
     f = loadFont("Serif-48.vlw");
    }
    
    void draw() {
    background(200);
    int indent = 30;
    textFont(f);
    fill(0);
    if (input%2==0) {
      int Keyy=int(saved);
      y=Keyy;
    }else{
    int Keyx=int(saved);
    x=Keyx;
    }
     //Set text
     text("Multiply "+x+" and "+y,indent, 100);
     text ("The answer is "+x*y, indent, 350);
     text ("Enter x, press enter and then enter y", indent,250);
     text("Press Enter twice to restart",indent,500);
    }
    
    void keyPressed() {
    if (key == '\n' ) {
        saved = typing;
        input=input+1;
        typing = ""; 
     } else {
         typing = typing + key; }
     }
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Ananya

    Multiply numbers

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    You need to login/register to comment.