I am supposed to let up to 16 guests order wine from a menu like this:
The program has to be modular. To place an order, the guest must be shown a list of product types and then variations based on that type. Once the orders are processed I have to show a final report with: total amount made by the winery, most ordered wine product type, and the wine product/variation combo ordered the most times.
I am not sure how to make a method that will search the counter array for the most ordered product type, and then another method that will search the counter array for the most ordered product/variation combo. That is what I need help with.
import javax.swing.JOptionPane;
public class Wine_Taste{
public static void main(String[] args){
String[]wines = {"Riesling", "Chardonnay", "Sauvignon Blanc", "Merlot"};
String[][]wineTypes=
{{"Dry- $4.50", "Off Dry-$4.00", "Sweet- $5.00",},
{"Apple- $6.00", "Lemon-$5.50","Vanilla- $6.00"},
{"Lime-$4.50", "Lemongrass- $6.50","Coconut- $7.00"},
{"Plum- $5.00", "Black Cherry- $7.50","Chocolate- $6.00"}};
}
double[][]prices= {{4.50, 4.00, 5.00},
{6.00, 5.50, 6.00},
{4.50, 6.50, 7.00},
{5.00, 7.50, 6.00}};
int[][]counter ={{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0}};
counter = go(wines,wineTypes,counter,prices);
public static int[][] go(String[] wines, String[][] wineTypes, int[][] counter, double[][] prices){
go2(counter);
double totalCost = 0;
String user;
int x =0;
while (x<=16){
for(int i = 0;i<wines.length;i++){
JOptionPane.showMessageDialog(null,wines[i]);
}
user = JOptionPane.showInputDialog("choose wine 0-3");
int i = Integer.parseInt(user);
for(int j=0;j<wineTypes[i].length;j++){
JOptionPane.showMessageDialog(wineTypes[i][j]);
}
user = JOptionPane.showInputDialog("choose option 0-3");
int j = Integer.parseInt(user);
totalCost += prices[i][j];
counter[i][j]++;
user = JOptionPane.showInputDialog("Order more? y/n");
if (user.equals("y")){
x++;
else{
JOptionPane.showMessageDialog(totalCost);
}
}
}
return counter;
}
}
}