Question: Integer numScores is read from input, representing the number of integers to be read next. Then, the remaining integers are read and stored into array

Integer numScores is read from input, representing the number of integers to be read next. Then, the remaining integers are read and stored into array scoresList. For each element in scoresList that is greater than
6
0
,
assign the element with
6
0
.
Ex: If the input is:
3
3
9
9
1
1
0
0
then the output is:
Raw scores:
3
9
9
1
1
0
0
Adjusted scores:
3
9
6
0
6
0
import java.util.Scanner;
public class ArrayUpdate
{
public static void main
(
String
[
]
args
)
{
Scanner scnr
=
new Scanner
(
System
.
in
)
;
int
[
]
scoresList;
int numScores;
int i;
numScores
=
scnr
.
nextInt
(
)
;
scoresList
=
new int
[
numScores
]
;
for
(
i
=
0
; i
<
scoresList.length;
+
+
i
)
{
scoresList
[
i
]
=
scnr
.
nextInt
(
)
;
}
System.out.print
(
"
Raw scores:
"
)
;
for
(
i
=
0
; i
<
scoresList.length;
+
+
i
)
{
System.out.print
(
scoresList
[
i
]
+
"
"
)
;
}
System.out.println
(
)
; System.out.print
(
"
Adjusted scores:
"
)
;
for
(
i
=
0
; i
<
scoresList.length;
+
+
i
)
{
System.out.print
(
scoresList
[
i
]
+
"
"
)
;
}
System.out.println
(
)
;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!