# Help with operator "&&"

**URL:** <https://discourse.processing.org/t/help-with-operator/29103>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [April 4, 2021, 12:07am UTC](https://discourse.processing.org/t/help-with-operator/29103 "2021-04-04T00:07:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dialias](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dialias](https://discourse.processing.org/u/Dialias)\
**Post date:** [April 4, 2021, 12:07am UTC](https://discourse.processing.org/t/help-with-operator/29103/1 "2021-04-04T00:07:01Z")

</div>

Hey i have a problem with my code.  
the console says , unexpected tocen ,&&" in th lower code.

```auto
import processing.pdf.*;

int money;
int mpc; //money per click
int owned1; //owned first upgrade
boolean buy1;
int rx1 = 200;
int ry1 = 300;
int rwidth1 = 300; 
int rheight1 = 150;
int rx2 = 1000;
int ry2 = 300;
int rwidth2 = 1200; 
int rheight2 = 150;

PImage pic1;
PImage pic2;

void setup() {
  pic1 = loadImage("foto_1.png");
  pic2 = loadImage("foto_2.png");
  size(1200, 750);
}

void mousePressed() {
  if (rx1 <= mouseX && mouseX <= rx1 + rwidth1 &&
    ry1 <= mouseY && mouseY <= ry1 + rheight1) {
    money = money + mpc;
    }
    
      if (rx2 <= mouseX && mouseX <= rx2 + rwidth2 &&
    ry2 <= mouseY && mouseY <= ry2 + rheight2) {
    buy1 = true;
    }
}

void draw() {

      fill(0,0,0);
      background(200);
      println(money);
      textSize(40);
      fill(0);
      
      image(pic1, 200, 300);
      pic1.resize(0, 150);
      image(pic2, 1110, 0);
      pic2.resize(0, 800);
      
      fill(1,0,0);
      text("Money:", 240, 246);
      textSize(40);
      text(money, 390, 250);

    }
    
public static void main(String[] args) {
  if(buy1) && money >= 10 {
  money = money - 10;
  owned1 + 1;
  mpc = mpc + 1;
  }
}

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 4, 2021, 12:10am UTC](https://discourse.processing.org/t/help-with-operator/29103/2 "2021-04-04T00:10:18Z")

</div>

Hello,

Please format your code as per:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

This helps us help you.

Check your brackets in the if statement.  
_[if \ Language (API) \ Processing 3+](https://processing.org/reference/if.html)_

`:)`

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 4, 2021, 12:17am UTC](https://discourse.processing.org/t/help-with-operator/29103/4 "2021-04-04T00:17:35Z")

</div>

> [@Dialias](#):
>
> ```auto
> public static void main(String[] args) {
> if(buy1) && money >= 10 {
> money = money - 10;
> owned1 + 1;
> mpc = mpc + 1;
> }
> 
> ```

For starters…

Correct the brackets in the if statement.  
The _if statement_ (and only that) belongs in the draw.

``:)~`

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 4, 2021, 12:22am UTC](https://discourse.processing.org/t/help-with-operator/29103/5 "2021-04-04T00:22:04Z")

</div>

There are resources (tutorials, examples and references) here to assist you with programming with Processing:  
_[https://processing.org/](https://processing.org/)_

The [`public static void main(String[] args)`](https://www.google.com/search?q=public+static+void+main(String%5B%5D+args)&rlz=1C1CHBF_enCA822CA822&oq=public+static+void+main(String%5B%5D+args)&aqs=chrome..69i57j69i60l2&sourceid=chrome&ie=UTF-8) does not belong in this code.  
Processing generates JAVA code in the background for you; most will never see this!

> **Processing Sketch Code**
>
> ```auto
> //global variables here
> 
> void setup() 
> {
> size(100, 100);
> //Code here
> }
> 
> void draw() 
> {
> background(128);
> // Code here
> }
> 
> ```

> **Java Code created by Processing**
>
> ```auto
> import java.util.HashMap; 
> import java.util.ArrayList; 
> import java.io.File; 
> import java.io.BufferedReader; 
> import java.io.PrintWriter; 
> import java.io.InputStream; 
> import java.io.OutputStream; 
> import java.io.IOException; 
> 
> public class sketch_210404b extends PApplet {
> 
> //global variables here
> 
> public void setup() 
> {
> //Code here
> }
> 
> public void draw() 
> {
> background(128);
> // Code here
> }
> public void settings() { size(100, 100); }
> static public void main(String[] passedArgs) {
> String[] appletArgs = new String[] { "sketch_210404b" };
> if (passedArgs != null) {
> PApplet.main(concat(appletArgs, passedArgs));
> } else {
> PApplet.main(appletArgs);
> }
> }
> }
> 
> ```

You can look in your `%temp%` folder for the JAVA files that Processing generates. Again, most will never see this when working with Processing.  
I have on occasion gone in there if a sketch crashes and I did not have saved code.

`:)`
