Question: Integer numElements is read from input and integer array userRating is declared with size numElements. Assign the last element in userRating with 4 0 .

Integer numElements is read from input and integer array userRating is declared with size numElements. Assign the last element in userRating with 40.
Ex: If the input is 5, then the output is:
Updated ratings: 000040 import java.util.Scanner;
public class RatingList {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
int numElements;
int[] userRating;
int i;
numElements = scnr.nextInt();
userRating = new int[numElements];
/* Your code goes here */
System.out.print("Updated ratings: ");
for (i =0; i < userRating.length; ++i){
System.out.print(userRating[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!