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

Hello. I need help fixing this Java Code on Eclipse. Please fix parts indicated

ID: 3791811 • Letter: H

Question

Hello. I need help fixing this Java Code on Eclipse. Please fix parts indicated as "//Fix" or "//Fill-in". The code given is the first image. Thank you! Sample outputs are given below along with what the code is required to do.

import java til. Random import java til. Scanner public class GenCheeseShopv2 public static void intro (Stringt] names, double []prices int amounts Fill-in public static void getAmount (Scanner input, String[] names, int[] amounts) public static void itemizedList (String[] names, double Prices int[] amounts) Fill-i public static double calcSubTotal (double prices, int amounts return 0; pub. lic static int discount (double subTotal return 0; pub. lic static oid print Total (double subTotal int discount) Fill-in public static void mi args final int MAXCH EESEE DO NOT CHANGE ANYTHING BELOW String[] names new String CMAXCH EESE double[] prices new double EESE] int[] amounts new int [MAXCHEESEJ Scanner input new Scanner (Syste intro names, prices, amounts get Amo unt input, names, amounts double total calcSubTotal (prices, amounts if EESEE 0) System. out print Display the itemized list? (1 for yes) int itemized input-nex if item 1) itemized List (names, prices, amounts); System. out. println(); print Total(total, discount total));

Explanation / Answer

import java.util.Random;
import java.util.Scanner;

public class GenCheeseShopv2 {
  
   public static void intro(String[] names, double[] prices,int[] amounts){
       System.out.println("We sell "+names.length+" kinds of cheese");
       for(int i=0;i<names.length;i++){
           System.out.println(names[i]+": $"+prices[i]+" per pound");
       }
   }
   public static void getAmount(Scanner input, String[] names, int[] amounts){
       for(int i=0;i<names.length;i++){
           System.out.println("Enter the amount of "+names[i]+" :");
           amounts[i] = input.nextInt();
       }
   }
   public static void itemizedList(String[] names, double[] prices,int[] amounts){
       for(int i=0;i<names.length;i++){
           if(amounts[i]>0)
               System.out.println(amounts[i]+" lbs of "+names[i]+" @ "+prices[i]+" = $"+(amounts[i]*prices[i]));
       }
   }
   public static double calcSubTotal( double[] prices,int[] amounts){
       double subTotal=0;
       for(int i=0;i<prices.length;i++){
           subTotal = subTotal +(amounts[i]*prices[i]);
       }
       return subTotal;
   }
  
   public static int discount(double subTotal){
       if(subTotal >100)
           return 10;
       else if(subTotal > 50)
           return 25;
       else
           return 0;
   }
  
   public static void printTotal(double subTotal,int discount){
       System.out.println("Sub Total : $"+subTotal);
       System.out.println("-Discount : $"+discount);
       System.out.println("Total : $"+(subTotal-discount));
   }
  
   public static void main(String[] args){
       final int MAXCHEESES=4;
      
       String[] names = new String[MAXCHEESES];
       double[] prices = new double[MAXCHEESES];
       int[] amounts = new int[MAXCHEESES];
      
       Scanner input = new Scanner(System.in);
      
       intro(names, prices, amounts);
       getAmount(input, names, amounts);
       double total = calcSubTotal(prices, amounts);
       if(MAXCHEESES>0){
           System.out.println("Display the itemized list? (1 for yes)");
           int itemized = input.nextInt();
           if(itemized==1){
               itemizedList(names, prices, amounts);
           }
       }
       System.out.println();
       printTotal(total, discount(total));
   }
}