Web Analytics Made Easy -
StatCounter if statement help - CodingForum


No announcement yet.

if statement help

  • Filter
  • Time
  • Show
Clear All
new posts

  • if statement help

    Hey, could I get a little help with this program I'm writing?

    if (Multiplication){
    System.out.println(num1 "*" num2 "=" mult);

    if (Division){
    System.out.println(num1 "/" num2 "=" divid);

    if (Addition){
    System.out.println(num1 "+" num2 "=" add);

    if (Subtraction){
    System.out.println(num1 "-" num2 "=" sub);

    ^^^ That's the part of my Java code which displays the output. On all the lines which it says "System.out.println" JCreator tells me I have an error and a ')' is expected. Where am I missing an ')'???? I can't seem to figure this out. No, this is not my homework. I'm just messing around with a code for fun.

  • #2
    You need to concatenate your literals with your variables with the '+' sign.
    System.out.println(num1 + "*" + num2 + "=" + mult);

    Good luck;
    Why using tables for eating is stupid!