I'm trying to write a program that will output the total number of large,medium,and small pizza along with the average cost of an order. I'm stuck on this error , "Else without if" on line 48 else ...medium. What is wrong with it? Are my brackets not matching up?
import java.util.Scanner;
public class PizzaOrder
{
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
double cost,total, average;
String name,response,size,type;
int count,l,m,s;
System.out.println("Do you wish to order a pizza?");
response = input.next();
while (!( response.equals("no")))
{
if ( response.equals("yes"))
{
System.out.print("Enter your last name in all lower case and then press the ENTER key.");
name = input.next();
System.out.print("Enter the size of pizza desired in all lower case and then press the ENTER key. ");
size = input.next();
System.out.print("Enter the type of pizza desired in all lower case and then press the ENTER key.");
type = input.next();
if (size.equals("small")|| size.equals("medium")||size.equals("large"))
count=0;cost=0;
{
if (size.equals("small"))
s=0;
{
if (type.equals("pepperoni"))
cost = 8.50;
else if (type.equals("cheese"))
cost = 7.00;
else if (type.equals("supreme"))
cost = 11.00;
else
cost = 10.00;
s++;
}
else if (size.equals("medium"))
m=0;
{
if (type.equals("pepperoni"))
cost = 9.50;
else if (type.equals("cheese"))
cost = 8.00;
else if (type.equals("supreme"))
cost = 14.00;
else
cost = 12.25;
m++;
}
else ( size.equals("large"))
l=0;
{
if (type.equals("pepperoni"))
cost = 10.50;
else if (type.equals("cheese"))
cost = 9.00;
else if (type.equals("supreme"))
cost = 16.00;
else
cost = 14.50;
l++;
}
}
count++;
total = cost;
average = total/count;
System.out.println("Last Name: " +name);
System.out.println("Number of large pizzas ordered: " +(l));
System.out.println("Number of medium pizzas ordered: " +(m));
System.out.println("Number of small pizzas ordered: " +(s));
System.out.println("Number of pizzas ordered: " +(count));
System.out.println("Average cost of an order: " +(average));
}
}
else
System.out.println("Word entered is invalid.");
}
System.out.print("Do you wish to order a pizza?");
response = input.next();
}
}