Question

In: Computer Science

Write a Java program that lets the user keep track of their homemade salsa sales. Use...

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).

Solutions

Expert Solution

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 );
}
}


Related Solutions

Write a c++ program for the Sales Department to keep track of the monthly sales of...
Write a c++ program for the Sales Department to keep track of the monthly sales of its salespersons. The program shall perform the following tasks: Create a base class “Employees” with a protected variable “phone_no” Create a derived class “Sales” from the base class “Employees” with two public variables “emp_no” and “emp_name” Create a second level of derived class “Salesperson” from the derived class “Sales” with two public variables “location” and “monthly_sales” Create a function “employee_details” under the class “Salesperson”...
Write a Java program that lets the user play a game where they must guess a...
Write a Java program that lets the user play a game where they must guess a number between zero and one hundred (0-100). The program should generate a random number between 0 and 100 and then the user will try to guess the number. The program should help the user guess the number (see details below). The program must allow the user five attempts to guess the number. Further Instruction: (a) Declare a variable diff and assign to it the...
Write a JAVA program that prompts the user to enter a single name. Use a for...
Write a JAVA program that prompts the user to enter a single name. Use a for loop to determine if the name entered by the user contains at least 1 uppercase and 3 lowercase letters. If the name meets this policy, output that the name has been accepted. Otherwise, output that the name is invalid.
How to write a C++ program that lets the user enter a string and checks if...
How to write a C++ program that lets the user enter a string and checks if it is an accepted polynomial. Accepted polynomials need to have one term per degree, no parentheses, spaces ignored.
Use Java (Geometry: point in a rectangle?) Write a program that prompts the user to enter...
Use Java (Geometry: point in a rectangle?) Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (0, 0) with width 10 and height 5.  For example, (2, 2) is inside the rectangle and (6, 4) is outside the rectangle. (Hint: A point is in the rectangle if its horizontal distance to (0, 0) is less than or equal to10 / 2 and its vertical...
ASSIGNMENT: Write a program to keep track of the total number of bugs collected in a...
ASSIGNMENT: Write a program to keep track of the total number of bugs collected in a 7 day period. Ask the user for the number of bugs collected on each day, and using an accumulator, keep a running total of the number of bugs collected. Display the total number of bugs collected, the count of the number of days, and the average number of bugs collected every day. Create a constant for the number of days the bugs are being...
Fraction calculator: Write a program that lets the user perform arithmetic operations on fractions.
Fraction calculator: Write a program that lets the user perform arithmetic operations on fractions. Fractions are of the form a / b, in which a and b are integers and b != 0.Your program must:be menu driven, allowing the user to select the operation (+, -, *, or /) and input the numerator and denominator of each fraction.The input must be validated for correct operation (+, -, *, or /) and b != 0. If any of these cases are...
Write an assembly program that lets the user to input only the word MASM and displays...
Write an assembly program that lets the user to input only the word MASM and displays invalid input for any other user inputs.
C++ Write a program that lets the user enter a two letters which are f and...
C++ Write a program that lets the user enter a two letters which are f and s with a length of 5. And outputs how many times it was occurred and lists the 2 most repeating pattern with 5lengths of f and s. The output display should always start at three-f(s) .Include an option where user can retry the program. Example: Input: sssfsfsfssssfffsfsssssfffsffffsfsfssffffsfsfsfssssfffffsffffffffffffssssssssfffsffffsssfsfsfsfssssfffsssfsfsffffffssssssffffsssfsfsfsss Output: The most repeating 5lengths of pattern is: fffsf and occurred 6times. Output2: The second most repeating...
Write a C++ program that lets the user enter the total rainfall for each of 12...
Write a C++ program that lets the user enter the total rainfall for each of 12 months (starting with January) into an array of doubles. The program should calculate and display (in this order): the total rainfall for the year,     the average monthly rainfall,     and the months with the highest and lowest amounts. Months should be expressed as English names for months in the Gregorian calendar, i.e.: January, February, March, April, May, June, July, August, September, October, November,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT