How to solve 6.2 java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to solve 6.2 java

2nd Aug 2022, 11:35 AM
Mommy
Mommy - avatar
4 Answers
+ 4
By modifying the given code. Read the previous lesson again and pay attention to post- and pre-increment/ decrement. If you need help with your code, please show your code.
2nd Aug 2022, 12:11 PM
Lisa
Lisa - avatar
+ 4
ONLY modify the code where it says "fix". DO NOT MODIFY THE OTHER CODE. The initial score is whatever the user enters, not 5!
2nd Aug 2022, 2:09 PM
Lisa
Lisa - 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 initScore =5; scanner.nextInt(); int scoreTom = initScore; int scoreBob = initScore; System.out.println("Round 1 results:"); //fix System.out.println(++scoreTom); System.out.println(--scoreBob); } }
2nd Aug 2022, 1:47 PM
Mommy
Mommy - avatar
0
Thank you ☺️☺️
2nd Aug 2022, 5:01 PM
Mommy
Mommy - avatar