Write a program in a class SandwichCounter that computes the cost of sandwiches sold at a food stand. Three kinds of sandwiches —cheese steak, chicken, and salad— are cost, respectively, $8.5, $7.5, and $7.0 per sandwich. Create an array of strings that holds the names of these sandwiches. Create another array that holds the cost of each corresponding sandwich. Your program should read the name of a sandwich and the quantity desired by a customer. Locate the sandwich in the name array and use that index to find the cost per purchase in the cost array. Compute and print the total cost of the sale.
import java.util.Scanner;
public class SandwichCounter {
public static void main(String[] args) {
String names[] = { "cheese steak",
"chicken", "salad" };
double prices[] = { 8.5, 7.5, 7
};
//reading name and quantity
System.out.println("Enter the name
of the sandwich cheese (steak, chicken,salad)");
Scanner sc = new
Scanner(System.in);
String n = sc.nextLine();
System.out.println("Enter
quantity");
int q = sc.nextInt();
double total = 0;
//iterating through loop to fing
the cost for entered sandwich
for (int i = 0; i <
names.length; i++) {
if
(n.equalsIgnoreCase(names[i])) {
// finding total cost
total = q * prices[i];
break;
}
}
System.out.println("Total Cost :$"
+ total);
}
}
Write a program in a class SandwichCounter that computes the cost of sandwiches sold at a...
In Java with comments. Write a program that computes the cost of flowers sold at a flower stand. Five kinds of flowers—petunia, pansy, rose, violet, and carnation— are stocked and cost, respectively, 50¢, 75¢, $1.50, 50¢, and 80¢ per flower. Create an array of strings that holds the names of these flowers. Create another array that holds the cost of each corresponding flower. Your program should read the name of a flower and the quantity desired by a customer. Locate...
Write a program that meets the following requirements: Sandwich Class Create a class called Sandwich which has the following instance variables. No other instance variables should be used: - ingredients (an array of up to 10 ingredients, such as ham, capicola, American cheese, lettuce, tomato) -condiments (an array of up to 5 condiments, such as mayonnaise, oil, vinegar and mustard) Create a two argument constructor Write the getters and setters for the instance variables Override the toString method using the...
In Java.
Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...
Write you code in a class named HighScores, in file named HighScores.java. Write a program that records high-score data for a fictitious game. The program will ask the user to enter five names, and five scores. It will store the data in memory, and print it back out sorted by score. The output from your program should look approximately like this: Enter the name for score #1: Suzy Enter the score for score #1: 600 Enter the name for score...
THIS MUST BE DONE ON VISUAL STUDIO Write a C# program that computes a the cost of donuts at your local Rich Horton’s store. The cost, of course, depends on the number of donuts you purchase. The following table gives the break down: Donuts Purchased Cost per Donut ($) = 15 0.75 A customer can save on the HST (13%) if they buy 12 or more donuts so only charge HST (use a constant) on the purchase if the customer...
Write a program named "VegetablePricer" which prompts the user for a vegetable from the pricing table shown below. The program will then display the cost per pound for that vegetable, again using the table provided. Your program must use a switch statement to process the input value and display the desired output. Be sure to provide a default case in your switch statement which handles unrecognized input. Use named constants for all constant strings (e.g. prompts and vegetable names) and...
Program 2 <100 points>: Chips and Salsa (chipsSalsa.cpp) Write a program that lets a maker of chips and salsa keep track of sales for five different types of salsa: mild, medium, sweet, hot, and zesty. The program should use two parallel 5-element arrays: an array of strings that holds the five salsa names and an array of integers that holds the number of jars sold during the past month for each salsa type. The salsa names should be stored using...
This is subject of C++ Your program should read the file answers.dat. This file contains the name of the student who took the quiz, and his answers for each question. The answers file has the following format: The student name is always the first line. A student name may or may not have last names. For example, both Elvis Presley and Cher took this class. A quiz always has 11 questions. There is one answer per line. Each answer is...
Order up:: Write a program that will be used to keep track of orders placed at a donut shop. There are two types of items that can be ordered: coffee or donuts. Your program will have a class for each order type, and an abstract superclass. Coffee orders are constructed with the following information: quantity (int) - how many coffees are being ordered size (String) - the size of the coffees (all coffees in the order have the same size)...
Create a simple Java class for a Month object with the following requirements: This program will have a header block comment with your name, the course and section, as well as a brief description of what the class does. All methods will have comments concerning their purpose, their inputs, and their outputs One integer property: monthNumber (protected to only allow values 1-12). This is a numeric representation of the month (e.g. 1 represents January, 2 represents February,...