Answer:
The program in Java is as follows:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String [] salsa = {"Mild","Medium","Sweet","Hot","Zesty"};
int [] number = new int[5];
for(int i = 0;i<5;i++){
System.out.print(salsa[i]+" number: ");
number[i] = input.nextInt();
}
for(int i = 0;i<5;i++){
System.out.println(salsa[i]+" : "+number[i]);
}
int smallest = number[0]; int highest = number[0];
int count = 0;
for(int i = 0;i<5;i++){
if(smallest > number[i]){
smallest = number[i];
count = i;
}
}
System.out.println("Smallest");
System.out.println(salsa[count]+" : "+smallest);
for(int i = 0;i<5;i++){
if(highest < number[i]){
highest = number[i];
count = i;
}
}
System.out.println("Highest");
System.out.println(salsa[count]+" : "+highest);
}
}
Explanation:
This initializes the salsa names
String [] salsa = {"Mild","Medium","Sweet","Hot","Zesty"};
This declares the array for the amount of salsa
int [] number = new int[5];
This iterates through the 5 salsas and get input for the amount of each
<em> for(int i = 0;i<5;i++){</em>
<em> System.out.print(salsa[i]+" number: ");</em>
<em> number[i] = input.nextInt();</em>
<em> }</em>
This prints each salsa and the amount sold
<em> for(int i = 0;i<5;i++){</em>
<em> System.out.println(salsa[i]+" : "+number[i]);</em>
<em> }</em>
This initializes smallest and largest to the first array element
int smallest = number[0]; int highest = number[0];
This initializes the index of the highest or lowest to 0
int count = 0;
The following iteration gets the smallest of the array elements
<em> for(int i = 0;i<5;i++){</em>
<em> if(smallest > number[i]){</em>
<em> smallest = number[i];</em>
This gets the index of the smallest
<em> count = i;</em>
<em> }</em>
<em> }</em>
This prints the smallest
<em> System.out.println("Smallest");</em>
<em> System.out.println(salsa[count]+" : "+smallest);</em>
The following iteration gets the largest of the array elements
<em>for(int i = 0;i<5;i++){</em>
<em> if(highest < number[i]){</em>
<em> highest = number[i];</em>
This gets the index of the highest
<em> count = i;</em>
<em> }</em>
<em> }</em>
This prints the highest
System.out.println("Highest");
System.out.println(salsa[count]+" : "+highest);