Question

Hello, I'm having a hard time with the below array problem. I declare and initialized the...

Hello,

I'm having a hard time with the below array problem.

I declare and initialized the array, but when I create the command line argument I get syntax error. I can't get pass there.

This is what I have so far:

int [][] movieRatings;

movieRatings = new int [args.length][args.length];

for (int i = 0; i < args.length; i++)

movieRatings[i] = Integer.parseInt(args[i]); //getting a error here :(

movieRatings[2] = new int [4];

Rotten Tomatoes (20 points). Write a program RURottenTomatoes.java that creates a 2 dimensional integer array of movie ratings from the command line arguments and displays the index of the movie that has the highest sum of ratings. Ratings range from 1 to 5 (inclusive). The rows of the 2D array correspond to movie reviewers and the columns of the 2D array correspond to movies. The reviewer at index 2 gave movie at index 0 a rating of 4. Take a look at the following example for an explanation on the command line arguments sequence.

Homework Answers

Answer #1

int [][] movieRatings;

       movieRatings = new int [args.length][args.length];

       for (int i = 0; i < args.length; i++) {

       // here we are assigning the value movieRatings which is an 2D array so when you refer
           // movieRatings[i] means it will expect 1D array but your assigning an single integer
          
       //movieRatings[i] = Integer.parseInt(args[i]);
           movieRatings[i] = new int[Integer.parseInt(args[i])];

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions