In: Computer Science
Write a Java program that lets the user keep track of their homemade salsa sales. Use 5-element arrays to track the following. The salsa names mild, medium, sweet, hot, and zesty. The number of each type sold. The price of each type of salsa. Show gross amount of money made (before tax). Calculate how much the user owes in sales tax (6% of the amount made). Then display the net profit (after subtracting the tax).
Raw_code:
import java.util.Scanner;
public class Salsa{
public static void main(String[] args){
Scanner snr = new Scanner(System.in);
String[] names = {"mild", "medium", "sweet", "hot", "zesty"};
double[] price = new double[5];
int[] sold = new int[5];
double gross_ammount = 0;
double profit = 0;
double net_ammount = 0;
for (int iter = 0; iter < 5; iter++){
System.out.print("Enter the cost of " + names[iter] + " salsa:
");
price[iter] = snr.nextDouble();
System.out.print("Enter number of " + names[iter] + " salsa sold:
");
sold[iter] = snr.nextInt();
}
System.out.println();
for(int iter = 0; iter <5; iter++){
System.out.println(names[iter] + " salsa: " + sold[iter] +" sold. "
+
"Each costs :" + price[iter] + " Total = " + sold[iter] *
price[iter]);
}
for (int iter = 0; iter<5; iter++){
gross_ammount += price[iter] * sold[iter];
}
System.out.println("Gross amount of Money made = " +
gross_ammount);
profit = ( gross_ammount * 6)/100;
net_ammount = gross_ammount - profit;
System.out.println("Net amount of Money made = " + net_ammount
);
}
}