0
I need help please
java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //taking initial score int initScore = scanner.nextInt(); int scoreTom = initScore; int scoreBob = initScore; System.out.println("Round 1 results:"); //fix System.out.println(scoreTom++); System.out.println(scoreBob--); } }
2 Answers
+ 1
If you want to increment/decrement the value and then output the new value, you need to either do the increment/decrement prior to the output line or use;
System.out.println(++scoreTom);
System.out.println(--scoreBob);
+ 1
missing 'import' before 'java.util.Scanner;' ^^
anyway, what's the task requirements / your goal?
actually your code only input one value, and assign it to scoreTom and scoreBob... then you print them and only after printing you increase one by 1 and decrease other by 1...
pre-increment and post-increment (or decrement) are not the same:
v++ use v then assign v+1 to v
++v assign v+1 to v then use v