I'm working on an assignment. Parallel arrays are required... I need help with a couple of things, well, at least three things.
- The first issue when I run the program all the way through. How do I add spaces in the print statement? It comes out like this "MondaySoda1.0"
- Another problem is the "1.0" I clearly have "1.25" for price [0] but why is it printing out "1.0"?
- Lastly, if I type in Tuesday where it asks "Which day of the week do you want...." It stills prints out the information for Monday. How do I code it where if you type in Tuesday, it does not print anything at all.
I'll appreciate any help at this point!
import java.util.Scanner;
public class Cafeteria
{
public static void main (String [] args)
{
String [] days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday ", "Saturday ", "Sunday "};
String [] drinks = {"Soda", "Sweet Tea", "Lemonade", "Frozen Lemonade", "Coffee-Hot", "Coffee-Iced", "Latte"};
double [] price; = {1.25, 1.50, 1.75, 2.00, 2.25, 2.50, 3.75};
for ( int i = 0; i < days.length; i++)
{
}
Scanner scan = new Scanner(System.in);
System.out.println("What is the price of a Soda? ");
price [0] = scan.nextDouble();
System.out.println("What is the price of a Sweet Tea? ");
price [1] = scan.nextDouble();
System.out.println("What is the price of a Lemonade? ");
price [2] = scan.nextDouble();
System.out.println("What is the price of a Frozen Lemonade? ");
price [3] = scan.nextDouble();
System.out.println("What is the price of a Coffee-Hot? ");
price [4] = scan.nextDouble();
System.out.println("What is the price of a Coffee-Iced? ");
price [5] = scan.nextDouble();
System.out.println("What is the price of a Latte? ");
price [6] = scan.nextDouble();
System.out.println();
scan.nextLine();
System.out.println("Which day of the week do you want the discounted drink price for?");
String day = scan.nextLine();
System.out.println();
System.out.println("Weekday Drink Original-Price Discount-Price");
System.out.println("----------------------------------------------------------");
System.out.println(days[0] + drinks[0] + price[0]); //Print out the list of the desire array when you enter a day in
System.out.println("The highest price drink is latte at $3.75");
}
}