I have tried to create a subclass called premiumProduce that will add a 5% fee to the totalvalue, this is what I have but is not compiling. Please tell me what I'm doing wrong.
1. import java.util.*;
2. import java.text.NumberFormat;
3.
4. public class Produce {
5.
6. //initialize and load array with values
7.
8. private static int[] produceNumber = new int[] {2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024};
9.
10. private static String[] produceName = new String[] {"carrots","potatoe", "bananas", "tomatoe", "lettuce", "apples", "oranges", "grapes", "cherrie", "celery"};
11.
12. private static int[] produceStock = new int[] {20, 50, 12, 15, 10, 30, 40, 6, 75, 8};
13.
14. private static double[] producePrice = new double[] {.50,2.75,.60,1.00,1.50,2.50,3.00,1.89,2.50,1.48};
15.
16.
17. public static void DisplayOutput()
18.
19. { //Displays inventory and totals
20.
21. System.out.println("Item Number\tProduce Name\tStock\tPrice\tTotal Price\n");
22.
23. NumberFormat numForm = NumberFormat.getCurrencyInstance();//Displays double values as currency
24.
25. double totalValue = 0;
26.
27. for (int i=0; i<10; i++){
28.
29. // String price = numform.format(producePrice[i]);
30.
31. System.out.println(produceNumber[i]+"\t\t"+ produceName[i]+"\t\t"+produceStock[i]+"\t"+numForm.format(producePrice[i])+
32.
33. "\t"+(numForm.format(produceStock[i]*producePrice[i])));
34.
35. totalValue=totalValue+(produceStock[i]*producePrice[i]);
36. }
37. System.out.println("\n\nTotal Stock Value: "+numForm.format(totalValue));
38. }
39.}
40.
41. // Inventory Part 3 July 20, 2008
42.
43.
44.
45. class premiumProduce extends Produce
46. {
47.
48.
49. private double restockFee;
50.
51. public premiumProduce(String name, String number, String Stock, Double price)
52. {
53.
54. super(name, number, stock);
55. setRestockFee( fee);
56.
57. }
58.
59. public void setRestockFee( totalValue+0.05 price)
60.
61. {
62.
63. restockFee = fee < 0.0 ? 0.0 : price);
64.
65. }
66.
67. public double getRestockFee()
68.
69.{
70. return restockFee;
71.
72. }
73.
74. public double totalValue()
75.
76. {
77. return getRestockFee();
78.
79. }
80.
81. public String toString()
82.
83. {
84. return String.format("Premium Produce: %s\n%s: $%,.2f",
85.
86. super.toString(), "Restock Fee", getRestockFee() );
87.
88.}
89.
90. }
91.}
92. }