java - Basic calculations "Multiple markers on this line syntax error, delete this token" -


hello beginning learn java , having trouble basic calculations. simple program asks user input 2 values , when runs want show "20 + 5 = 25". repeatedly receiving "syntax error, delete token" message on portion of line "+" num2 "=" num1. wrong?

package ner.cs1451;  import java.util.scanner;  public class project01a { /*this program asks user input 2 values  *then computes following: sum, difference, product, quotient, remainder, , average.*/      public static void main(string[] args) {           scanner in = new scanner(system.in);           system.out.print("enter first number: ");         int num1 = in.nextint();         system.out.print("enter second number: ");         int num2 = in.nextint();         int avg = (num1 + num2)/2;           system.out.println(num1 "+" num2 "=" num1 + num2);         system.out.println(num1 "-" num2 "=" num1 - num2);         system.out.println(num1 "*" num2 "=" num1 * num2);         system.out.println(num1 "/" num2 "=" num1 / num2);         system.out.println(num1 "%" num2 "=" num1 % num2);         system.out.println("the average of 2 numbers is: "+avg); 

concatenate strings this:

system.out.println(num1 + "+" + num2 + "=" + (num1 + num2));


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -