I am working on an assignment with arrays. I have to use parallel arrays, however, I am having difficulties with the desired output I want the code to produce. The trouble is at the end of the code where it asks to enter in the day. I tried doing String [i] days.nextLine
, String days next.Line
, but it does not work.
I will provide a picture to clarify what I am trying to do. Warning: the picture is blurry. I'm doing good so far, it's the last three parts that present a challenge. I will add the discount portion later on. Thanks.
System.out.println("Weekday Drink Original-Price Discount-Price");
System.out.println("------------------------------------------------------");
System.out.println(day + drink + price + "IDK" );
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.00, 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();
System.out.println("Which day of the week do you want the discounted drink price for?");
System.out.println("Weekday Drink Original-Price Discount-Price");
System.out.println("-------------------------------------------------");
}
}