Hello! I am Chris Bethel an I am proud to be a member of this forum for the first time today. I am creating this thread to ask for assistance with a program involving arrays. Whenever I use the System output command, a random string of characters will appear instead of the array. What's happening?
Here is the code for reference:
package ChipsandSalsa;
import java.util.Scanner;
public class ChipsAndSalsa
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int[] Salsas = new int[5];
String[] Sauces = {"Mild","Medium","Sweet","Hot","Zesty"};
System.out.print("Enter the amount of jars sold for each sauce:");
for(int i = 0;i < Salsas.length;i++)
{
Salsas[i] = input.nextInt();
if(Salsas[i] < 0)
System.out.print("Invalid total. Try again!");
}
int max = Salsas[0];
for(int i=0; i < Salsas.length; i++)
{
if (Salsas[i] > max)
max = Salsas[i];
}
System.out.print("Highest selling sauce:" + Sauces[i]);
int IndexOfMax = 0;
for(int i=0; i < Salsas.length; i++)
{
if (Salsas[i] > max)
max = Salsas[i];
IndexOfMax = i;
}
System.out.print("Lowest selling sauce:" + Sauces[i]);
int TotalSales = Salsas[1] + Salsas[2] + Salsas[3] + Salsas[4] + Salsas[5];
System.out.print(Salsas);
System.out.print("Total Sales: " + TotalSales);
}
}