Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. code an array using an initializer list that contains the following categorie

ID: 3814987 • Letter: 1

Question

1. code an array using an initializer list that contains the following categories from the 2017 Oscars: Best Picture Best Animated Feature Film", "Best Directing" 2. Code a second array that holds the name of film. 3. Code a third array that holds the worldwide box office revenue for each film. 4. Code a for loop that will populate the arrays by prompting for the film and its worldwide box office revenue 5. Then, code another for loop that will display the content from these arrays as follows: Output Specifications: where the Xs represent the film and the category for which it is honored and the Zs the box office revenue

Explanation / Answer

import java.util.*;
import java.text.DecimalFormat;

class Films
{
   public static void main (String[] args)
   {
        //parallel arrays
       String[] categories = {"Best Picture","Best Animated Feature Film","Best Directing"};
       String[] name = new String[3];
       String[] revenue = new String[3];
       int i;
  
       Scanner scan = new Scanner(System.in);
      
       //input values
       for(i= 0;i<3;i++)
       {
            System.out.println("Enter the film for "+categories[i] +":");
            name[i] = scan.nextLine();
          
            System.out.println("Enter the worldwide box office revenue for "+ name[i] +":" );
            revenue[i] = scan.nextLine();
          
          
       }
      
       String pattern="###,###,###.##";
       DecimalFormat myFormatter = new DecimalFormat(pattern);
      
       System.out.println(" Oscar Winners 2017");
       System.out.println(" FILM CATEGORY WORLD WIDE BOX OFFICE REVENUE");
       for(i= 0;i<3;i++)
       {
            String output = myFormatter.format(Double.parseDouble(revenue[i]) *1000000);
            System.out.printf(" %s %s $ %s",categories[i],name[i],output);
          
       }
      
   }
}


output: