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

I need help with my java lab, here are some of the outputs imtrying to achieve..

ID: 3617025 • Letter: I

Question

I need help with my java lab, here are some of the outputs imtrying to achieve...
....................................................................
We sell 0 kinds of Cheese
Sub Total: $0.0
-Discount: $0.0
Total    : $0.0
....................................................................
We sell 10 kinds of Cheese
Dalaran Sharp: $1.25 per pound
Stormwind Brie: $10.0 per pound
Alterac Swiss: $40.0 per pound
Cheese Type D: $9.15 per pound
Cheese Type E: $2.5 per pound
Cheese Type F: $8.74 per pound
Cheese Type G: $9.88 per pound
Cheese Type H: $2.91 per pound
Cheese Type I: $6.66 per pound
Cheese Type J: $0.36 per pound
Enter the amount of Dalaran Sharp : 1
Enter the amount of Stormwind Brie : 1
Enter the amount of Alterac Swiss : 1
Enter the amount of Cheese Type D : 1
Enter the amount of Cheese Type E : 1
Enter the amount of Cheese Type F : 1
Enter the amount of Cheese Type G : 1
Enter the amount of Cheese Type H : 1
Enter the amount of Cheese Type I : 1
Enter the amount of Cheese Type J : 1
Display the itemized list? (1 for yes) 1
1 lbs of Dalaran Sharp @ 1.25 = $1.25
1 lbs of Stormwind Brie @ 10.0 = $10.0
1 lbs of Alterac Swiss @ 40.0 = $40.0
1 lbs of Cheese Type D @ 9.15 = $9.15
1 lbs of Cheese Type E @ 2.5 = $2.5
1 lbs of Cheese Type F @ 8.74 = $8.74
1 lbs of Cheese Type G @ 9.88 = $9.88
1 lbs of Cheese Type H @ 2.91 = $2.91
1 lbs of Cheese Type I @ 6.66 = $6.66
1 lbs of Cheese Type J @ 0.36 = $0.36
Sub Total: $91.44999999999999
-Discount: $10.0
Total    : $81.44999999999999
................................................................................
We sell 10 kinds of Cheese
Dalaran Sharp: $1.25 per pound
Stormwind Brie: $10.0 per pound
Alterac Swiss: $40.0 per pound
Cheese Type D: $9.15 per pound
Cheese Type E: $2.5 per pound
Cheese Type F: $8.74 per pound
Cheese Type G: $9.88 per pound
Cheese Type H: $2.91 per pound
Cheese Type I: $6.66 per pound
Cheese Type J: $0.36 per pound
Enter the amount of Dalaran Sharp : 1
Enter the amount of Stormwind Brie : 0
Enter the amount of Alterac Swiss : 2
Enter the amount of Cheese Type D : 0
Enter the amount of Cheese Type E : 3
Enter the amount of Cheese Type F : 0
Enter the amount of Cheese Type G : 4
Enter the amount of Cheese Type H : 0
Enter the amount of Cheese Type I : 5
Enter the amount of Cheese Type J : 0
Display the itemized list? (1 for yes) 1
1 lbs of Dalaran Sharp @ 1.25 = $1.25
2 lbs of Alterac Swiss @ 40.0 = $80.0
3 lbs of Cheese Type E @ 2.5 = $7.5
4 lbs of Cheese Type G @ 9.88 = $39.52
5 lbs of Cheese Type I @ 6.66 = $33.3
Sub Total: $161.57
-Discount: $25.0
Total    : $136.57
.............................................................................

** and here is my actual lab that i need to work with and fix somemore.


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

public class GenCheeseShopv2 {

    public static void intro(String[] names,double[]prices, int[] amounts) {
        // Fill-in
    }

    public static void getAmount(Scanner input,String[] names, int[] amounts) {
        // Fill-in
    }

    public static void itemizedList(String[] names,double[]prices, int[] amounts) {
        // Fill-in
    }

    public static double calcSubTotal(double[]prices, int[] amounts) {
        // Fix
        return 0;
    }

    public static int discount(double subTotal){
        // Fix
        return 0;
    }

    public static void printTotal(double subTotal,int discount) {
        // Fill-in

    }

    public static void main(String[] args) {

        final int MAXCHEESE = 4;

        // DO NOT CHANGE ANYTHINGBELOW
        String[] names = newString[MAXCHEESE];
        double[] prices = newdouble[MAXCHEESE];
        int[] amounts = newint[MAXCHEESE];

        Scanner input = newScanner(System.in);

        intro(names, prices,amounts);

        getAmount(input, names,amounts);

        double total =calcSubTotal(prices, amounts);
       
        if (MAXCHEESE > 0) {
           System.out.print("Display the itemized list? (1 for yes) ");
            intitemized = input.nextInt();

            if(itemized == 1) {
               itemizedList(names, prices, amounts);
            }
        }

        System.out.println();

       printTotal(total,discount(total));
    }
}

Explanation / Answer

publicstatic double calcSubTotal(double[] prices,int[] amounts){

double subTotal = 0;

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

{

subTotal = subTotal + (prices[i]*amounts[i]);

}

return subTotal;

}

publicstatic intdiscount(doublesubTotal){

// Fix

return 0;

}

publicstatic voidprintTotal(double subTotal,int discount){

System.out.println("Sub Total: $" +subTotal);

System.out.println("-Discount: $" +discount);

double total = subTotal - discount;

System.out.println("Total : $" +total);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote