+ 2

How to finish this im confused

Tom and Bob are playing a board game, in which both players start with the same number of points. Tom won the first game and got 1 point, while Bob lost the game, and therefore lost 1 point. You are given a program that is intended to take the initial score and increase Tom's score by 1 and decrease Bob's score by 1. But something is wrong: the program outputs the scores without the change. Task Fix the program to result in the expected outputs. Sample Input 5 Sample Output Round 1 results: 6 4 Explanation Both players had 5 points at the start of the game. After the first game, Tom gained 1 point (6, the first outputted number), and Bob lost 1 point (4, the second outputted number).

4th Oct 2021, 1:25 PM
Jonathan Ivan
Jonathan Ivan - avatar
11 Antworten
+ 3
You need only one input. Both have the same initScore. import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //taking initial score int scoreTom = scanner.nextInt(); int scoreBob = scoreTom ; System.out.println("Round 1 results:"); //fix ++scoreTom; --scoreBob ; System.out.println(scoreTom); System.out.println(scoreBob); } }
4th Oct 2021, 2:08 PM
Coding Cat
Coding Cat - avatar
+ 2
import 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 = scanner.nextInt(); int scoreBob = scanner.nextInt(); System.out.println("Round 1 results:"); //fix ++ scoreTom ; -- scoreBob ; System.out.println(scoreTom); System.out.println(scoreBob); } }
4th Oct 2021, 1:55 PM
Jonathan Ivan
Jonathan Ivan - avatar
+ 1
Your input format was invalid. Here you go: https://code.sololearn.com/c68vbzTXUunH/?ref=app
4th Oct 2021, 2:10 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 1
Jonathan Ivan, Thanks to Coding Cat too))
4th Oct 2021, 2:20 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
0
Please post your attempt(code) before we could help you.
4th Oct 2021, 1:39 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
4th Oct 2021, 1:56 PM
Jonathan Ivan
Jonathan Ivan - avatar
4th Oct 2021, 2:17 PM
Jonathan Ivan
Jonathan Ivan - avatar
0
https://code.sololearn.com/cVrY5Ctz06Rl/?ref=app They must run the code in a good program. For now, start with the numbre 1 or 2.
6th Oct 2021, 6:08 AM
Velceo
Velceo - avatar
0
You need only one input. Both have the same initScore. import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //taking initial score int scoreTom = scanner.nextInt(); int scoreBob = scoreTom ; System.out.println("Round 1 results:"); //fix ++scoreTom; --scoreBob ; System.out.println(scoreTom); System.out.println(scoreBob); } }
6th Oct 2021, 10:06 AM
yohana erick
yohana erick - avatar
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //taking initial score int scoreTom = scanner.nextInt(); int scoreBob = scoreTom ; System.out.println("Round 1 results:"); //fix ++scoreTom; --scoreBob ; System.out.println(scoreTom); System.out.println(scoreBob); } }
21st Sep 2022, 10:23 AM
Jesse Wasike
Jesse Wasike - avatar