Answer to Question #267285 in Java | JSP | JSF for Ikraam Kader

Question #267285

Write a Java application and use a two-dimensional array that will store the three ratings of five TV shows.

SERIES NAME RATING 1 RATING 2 RATING 3 Big Bang Theory 9 8 5 Scandal 7 5 5 Modern Family 8 8 8 Dexter 10 7 8 Grand Designs 3 1 5 (6)

Q.2.2 Calculate and print the average of the TV rating for each TV show.

Q.2.3 Determine if the series will be continued for another season. If the average rating of the series is greater than or equal to seven then the TV network will continue with a new season.

Q.2.4 Print out each series name with the average rating and if there will be a series continuation.


1
Expert's answer
2021-11-17T05:45:26-0500
public class Main {
      public static void main(String[] args) {
            int r[][] = { { 9, 8, 5 }, { 7, 5, 5 }, { 8, 8, 8 },{ 10, 7, 8 }, { 3, 1, 5 } };
            String names[] = { "Big Bang Theory", "Scandal", "Modern Family", "Dexter", "Grand Designs" };
            
            System.out.printf("%-24s %-16s %-20s\n", "TV SHOW", "RATING", "SERIES CONTINUATION");
            System.out.println("**************************************************************");
            for (int i = 0; i < names.length; i++) {
                  int total = 0;
                  for (int j = 0; j < r[i].length; j++) {
                        total += r[i][j];
                  }
                  int average = total / r[i].length;
                  String con = (average >= 7) ? "Yes" : "No";
                  System.out.printf("%-24s %-16d %-20s\n", names[i], average,  con);
            }
      }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS