我的java程序无法编译。代码和错误包括在内

我的java程序无法编译。代码和错误包括在内,java,arrays,Java,Arrays,我收到的错误来自 public class Sundae { private String flavor; private int numberOfScoops; private double costForScoops;

我收到的错误来自

      public class Sundae
                               {

  private String flavor;
                                       private int numberOfScoops;
                                    private double costForScoops;
                                    private String [] stdToppingList=new String [4];
                                    private String freeSyrupChoice;
                                    private String [] deluxeToppingList= new String [9];
                                    private int counterD= 0;
                                    private double costOfDeluxeToppings;
                                    private double costOfSundae;
                                    private final double SALES_TAX= .08625;
                                    private double tax;
                                    private final double COST_PER_DELUXE_TOPPING =.75;
                                    private int counterFree=0;
                                    public Sundae()
                                    {
                                            flavor= " vanilla ";
                                            numberOfScoops=2;
                                            costForScoops=2.79;
                                            stdToppingList[0]=" whipped cream ";
                                            stdToppingList[1]=" hot fudge syrup ";
                                            stdToppingList[2]=" multi colored sprinkles ";
                                            stdToppingList[3]=" cherry ";
                                    }
                            public String getFlavor()
                            {
                                    return flavor;
                            }
                            public int getNumberOfScoops()
                            {
                                    return numberOfScoops;
                            }
                            public double getCostForScoops()
                            {
                                    return costForScoops;
                            }
                            public String [] getStdTopping()
                            {
                                    return stdToppingList;
                            }
                            public String getFreeSyrupChoice()
                            {
                                    return freeSyrupChoice;
                            }
                            public String [] getDeluxeTopping()
                            {
                                    return deluxeToppingList;
                            }
                            public int getCounterD()
                            {
                                    return counterD;
                            }
                            public double getCostDeluxeToppings()
                            {
                                    return costOfDeluxeToppings;
                            }
                            public double getCostOFSundae()
                            {
                                    return costOfSundae;
                            }
                            public void setFlavor( String selection )
                            {
                                    flavor=selection;
                            }
                            public void setNumberOfScoops(int number)
                            {
                                    numberOfScoops= number;
                            }
                            public void setCostForScoops()
                            {
                            costForScoops= numberOfScoops + .79;
                            }
                            public void setStdTopping( String toppings )
                            {
                                    stdToppingList[counterFree] = toppings;
                                    counterFree++;
                            }
                            public void setFreeSyrupChoice( String syrup )
                            {
                                    freeSyrupChoice= syrup;
                            }
                            public void setDeluxTopping (String xtraToppings)
                            {
                                    deluxeToppingList[counterD] = xtraToppings;
                                    counterD++;
                            }
                            public void setDefault()
                            {
                            flavor= " vanilla ";
                            numberOfScoops= 2;
                            costForScoops=2.79;
                            stdToppingList[0] = " whipped cream ";
                            stdToppingList[1] = " hot fudge syrup ";
                            stdToppingList[2] = " multi colored sprinkles ";
                            stdToppingList[3] = " cherry" ;
                            }
                            public void Print()
                            {
                            System.out.println(flavor + " "+ numberOfScoops+ " " + costForScoops +
                            " " +stdToppingList);
                            costOfDeluxeToppings = COST_PER_DELUXE_TOPPING*counterD;
                            costOfSundae = costOfDeluxeToppings + costForScoops;
                            tax=SALES_TAX*costOfSundae;
                            System.out.printf("Subtotal :$%.2f, tax:$%.2f, grand total: $%.2f " ,
                                    costOfSundae, tax, (costOfSundae+tax));
                            }
                            }
sundadriver.java
java:69:错误:“)”应为
((newSundae.getFreeSyrupChoice().equalsIgnoreCas)
(草莓)
^
java:70:错误:“)”应为
{
^
java:72:错误:“else”没有“if”
其他的
^
java:81:错误:“;”应为
对于(int i-0;i
||(newSundae.getNumberOfScoops()=4)
应该是
|(newSundae.getNumberOfScoops()=4)

      public class Sundae
                               {

  private String flavor;
                                       private int numberOfScoops;
                                    private double costForScoops;
                                    private String [] stdToppingList=new String [4];
                                    private String freeSyrupChoice;
                                    private String [] deluxeToppingList= new String [9];
                                    private int counterD= 0;
                                    private double costOfDeluxeToppings;
                                    private double costOfSundae;
                                    private final double SALES_TAX= .08625;
                                    private double tax;
                                    private final double COST_PER_DELUXE_TOPPING =.75;
                                    private int counterFree=0;
                                    public Sundae()
                                    {
                                            flavor= " vanilla ";
                                            numberOfScoops=2;
                                            costForScoops=2.79;
                                            stdToppingList[0]=" whipped cream ";
                                            stdToppingList[1]=" hot fudge syrup ";
                                            stdToppingList[2]=" multi colored sprinkles ";
                                            stdToppingList[3]=" cherry ";
                                    }
                            public String getFlavor()
                            {
                                    return flavor;
                            }
                            public int getNumberOfScoops()
                            {
                                    return numberOfScoops;
                            }
                            public double getCostForScoops()
                            {
                                    return costForScoops;
                            }
                            public String [] getStdTopping()
                            {
                                    return stdToppingList;
                            }
                            public String getFreeSyrupChoice()
                            {
                                    return freeSyrupChoice;
                            }
                            public String [] getDeluxeTopping()
                            {
                                    return deluxeToppingList;
                            }
                            public int getCounterD()
                            {
                                    return counterD;
                            }
                            public double getCostDeluxeToppings()
                            {
                                    return costOfDeluxeToppings;
                            }
                            public double getCostOFSundae()
                            {
                                    return costOfSundae;
                            }
                            public void setFlavor( String selection )
                            {
                                    flavor=selection;
                            }
                            public void setNumberOfScoops(int number)
                            {
                                    numberOfScoops= number;
                            }
                            public void setCostForScoops()
                            {
                            costForScoops= numberOfScoops + .79;
                            }
                            public void setStdTopping( String toppings )
                            {
                                    stdToppingList[counterFree] = toppings;
                                    counterFree++;
                            }
                            public void setFreeSyrupChoice( String syrup )
                            {
                                    freeSyrupChoice= syrup;
                            }
                            public void setDeluxTopping (String xtraToppings)
                            {
                                    deluxeToppingList[counterD] = xtraToppings;
                                    counterD++;
                            }
                            public void setDefault()
                            {
                            flavor= " vanilla ";
                            numberOfScoops= 2;
                            costForScoops=2.79;
                            stdToppingList[0] = " whipped cream ";
                            stdToppingList[1] = " hot fudge syrup ";
                            stdToppingList[2] = " multi colored sprinkles ";
                            stdToppingList[3] = " cherry" ;
                            }
                            public void Print()
                            {
                            System.out.println(flavor + " "+ numberOfScoops+ " " + costForScoops +
                            " " +stdToppingList);
                            costOfDeluxeToppings = COST_PER_DELUXE_TOPPING*counterD;
                            costOfSundae = costOfDeluxeToppings + costForScoops;
                            tax=SALES_TAX*costOfSundae;
                            System.out.printf("Subtotal :$%.2f, tax:$%.2f, grand total: $%.2f " ,
                                    costOfSundae, tax, (costOfSundae+tax));
                            }
                            }
应该更像

      public class Sundae
                               {

  private String flavor;
                                       private int numberOfScoops;
                                    private double costForScoops;
                                    private String [] stdToppingList=new String [4];
                                    private String freeSyrupChoice;
                                    private String [] deluxeToppingList= new String [9];
                                    private int counterD= 0;
                                    private double costOfDeluxeToppings;
                                    private double costOfSundae;
                                    private final double SALES_TAX= .08625;
                                    private double tax;
                                    private final double COST_PER_DELUXE_TOPPING =.75;
                                    private int counterFree=0;
                                    public Sundae()
                                    {
                                            flavor= " vanilla ";
                                            numberOfScoops=2;
                                            costForScoops=2.79;
                                            stdToppingList[0]=" whipped cream ";
                                            stdToppingList[1]=" hot fudge syrup ";
                                            stdToppingList[2]=" multi colored sprinkles ";
                                            stdToppingList[3]=" cherry ";
                                    }
                            public String getFlavor()
                            {
                                    return flavor;
                            }
                            public int getNumberOfScoops()
                            {
                                    return numberOfScoops;
                            }
                            public double getCostForScoops()
                            {
                                    return costForScoops;
                            }
                            public String [] getStdTopping()
                            {
                                    return stdToppingList;
                            }
                            public String getFreeSyrupChoice()
                            {
                                    return freeSyrupChoice;
                            }
                            public String [] getDeluxeTopping()
                            {
                                    return deluxeToppingList;
                            }
                            public int getCounterD()
                            {
                                    return counterD;
                            }
                            public double getCostDeluxeToppings()
                            {
                                    return costOfDeluxeToppings;
                            }
                            public double getCostOFSundae()
                            {
                                    return costOfSundae;
                            }
                            public void setFlavor( String selection )
                            {
                                    flavor=selection;
                            }
                            public void setNumberOfScoops(int number)
                            {
                                    numberOfScoops= number;
                            }
                            public void setCostForScoops()
                            {
                            costForScoops= numberOfScoops + .79;
                            }
                            public void setStdTopping( String toppings )
                            {
                                    stdToppingList[counterFree] = toppings;
                                    counterFree++;
                            }
                            public void setFreeSyrupChoice( String syrup )
                            {
                                    freeSyrupChoice= syrup;
                            }
                            public void setDeluxTopping (String xtraToppings)
                            {
                                    deluxeToppingList[counterD] = xtraToppings;
                                    counterD++;
                            }
                            public void setDefault()
                            {
                            flavor= " vanilla ";
                            numberOfScoops= 2;
                            costForScoops=2.79;
                            stdToppingList[0] = " whipped cream ";
                            stdToppingList[1] = " hot fudge syrup ";
                            stdToppingList[2] = " multi colored sprinkles ";
                            stdToppingList[3] = " cherry" ;
                            }
                            public void Print()
                            {
                            System.out.println(flavor + " "+ numberOfScoops+ " " + costForScoops +
                            " " +stdToppingList);
                            costOfDeluxeToppings = COST_PER_DELUXE_TOPPING*counterD;
                            costOfSundae = costOfDeluxeToppings + costForScoops;
                            tax=SALES_TAX*costOfSundae;
                            System.out.printf("Subtotal :$%.2f, tax:$%.2f, grand total: $%.2f " ,
                                    costOfSundae, tax, (costOfSundae+tax));
                            }
                            }
    if ((newSundae.getFreeSyrupChoice().equalsIgnoreCase("hot fudge"))
                    || ((newSundae.getFreeSyrupChoice().equalsIgnoreCase("chocolate"))
                    || ((newSundae.getFreeSyrupChoice().equalsIgnoreCase("caramel"))
                    || ((newSundae.getFreeSyrupChoice().equalsIgnoreCase("strawberry"))) {
(inti-0;i
没有意义,应该是(inti=0;i

      public class Sundae
                               {

  private String flavor;
                                       private int numberOfScoops;
                                    private double costForScoops;
                                    private String [] stdToppingList=new String [4];
                                    private String freeSyrupChoice;
                                    private String [] deluxeToppingList= new String [9];
                                    private int counterD= 0;
                                    private double costOfDeluxeToppings;
                                    private double costOfSundae;
                                    private final double SALES_TAX= .08625;
                                    private double tax;
                                    private final double COST_PER_DELUXE_TOPPING =.75;
                                    private int counterFree=0;
                                    public Sundae()
                                    {
                                            flavor= " vanilla ";
                                            numberOfScoops=2;
                                            costForScoops=2.79;
                                            stdToppingList[0]=" whipped cream ";
                                            stdToppingList[1]=" hot fudge syrup ";
                                            stdToppingList[2]=" multi colored sprinkles ";
                                            stdToppingList[3]=" cherry ";
                                    }
                            public String getFlavor()
                            {
                                    return flavor;
                            }
                            public int getNumberOfScoops()
                            {
                                    return numberOfScoops;
                            }
                            public double getCostForScoops()
                            {
                                    return costForScoops;
                            }
                            public String [] getStdTopping()
                            {
                                    return stdToppingList;
                            }
                            public String getFreeSyrupChoice()
                            {
                                    return freeSyrupChoice;
                            }
                            public String [] getDeluxeTopping()
                            {
                                    return deluxeToppingList;
                            }
                            public int getCounterD()
                            {
                                    return counterD;
                            }
                            public double getCostDeluxeToppings()
                            {
                                    return costOfDeluxeToppings;
                            }
                            public double getCostOFSundae()
                            {
                                    return costOfSundae;
                            }
                            public void setFlavor( String selection )
                            {
                                    flavor=selection;
                            }
                            public void setNumberOfScoops(int number)
                            {
                                    numberOfScoops= number;
                            }
                            public void setCostForScoops()
                            {
                            costForScoops= numberOfScoops + .79;
                            }
                            public void setStdTopping( String toppings )
                            {
                                    stdToppingList[counterFree] = toppings;
                                    counterFree++;
                            }
                            public void setFreeSyrupChoice( String syrup )
                            {
                                    freeSyrupChoice= syrup;
                            }
                            public void setDeluxTopping (String xtraToppings)
                            {
                                    deluxeToppingList[counterD] = xtraToppings;
                                    counterD++;
                            }
                            public void setDefault()
                            {
                            flavor= " vanilla ";
                            numberOfScoops= 2;
                            costForScoops=2.79;
                            stdToppingList[0] = " whipped cream ";
                            stdToppingList[1] = " hot fudge syrup ";
                            stdToppingList[2] = " multi colored sprinkles ";
                            stdToppingList[3] = " cherry" ;
                            }
                            public void Print()
                            {
                            System.out.println(flavor + " "+ numberOfScoops+ " " + costForScoops +
                            " " +stdToppingList);
                            costOfDeluxeToppings = COST_PER_DELUXE_TOPPING*counterD;
                            costOfSundae = costOfDeluxeToppings + costForScoops;
                            tax=SALES_TAX*costOfSundae;
                            System.out.printf("Subtotal :$%.2f, tax:$%.2f, grand total: $%.2f " ,
                                    costOfSundae, tax, (costOfSundae+tax));
                            }
                            }
这个

      public class Sundae
                               {

  private String flavor;
                                       private int numberOfScoops;
                                    private double costForScoops;
                                    private String [] stdToppingList=new String [4];
                                    private String freeSyrupChoice;
                                    private String [] deluxeToppingList= new String [9];
                                    private int counterD= 0;
                                    private double costOfDeluxeToppings;
                                    private double costOfSundae;
                                    private final double SALES_TAX= .08625;
                                    private double tax;
                                    private final double COST_PER_DELUXE_TOPPING =.75;
                                    private int counterFree=0;
                                    public Sundae()
                                    {
                                            flavor= " vanilla ";
                                            numberOfScoops=2;
                                            costForScoops=2.79;
                                            stdToppingList[0]=" whipped cream ";
                                            stdToppingList[1]=" hot fudge syrup ";
                                            stdToppingList[2]=" multi colored sprinkles ";
                                            stdToppingList[3]=" cherry ";
                                    }
                            public String getFlavor()
                            {
                                    return flavor;
                            }
                            public int getNumberOfScoops()
                            {
                                    return numberOfScoops;
                            }
                            public double getCostForScoops()
                            {
                                    return costForScoops;
                            }
                            public String [] getStdTopping()
                            {
                                    return stdToppingList;
                            }
                            public String getFreeSyrupChoice()
                            {
                                    return freeSyrupChoice;
                            }
                            public String [] getDeluxeTopping()
                            {
                                    return deluxeToppingList;
                            }
                            public int getCounterD()
                            {
                                    return counterD;
                            }
                            public double getCostDeluxeToppings()
                            {
                                    return costOfDeluxeToppings;
                            }
                            public double getCostOFSundae()
                            {
                                    return costOfSundae;
                            }
                            public void setFlavor( String selection )
                            {
                                    flavor=selection;
                            }
                            public void setNumberOfScoops(int number)
                            {
                                    numberOfScoops= number;
                            }
                            public void setCostForScoops()
                            {
                            costForScoops= numberOfScoops + .79;
                            }
                            public void setStdTopping( String toppings )
                            {
                                    stdToppingList[counterFree] = toppings;
                                    counterFree++;
                            }
                            public void setFreeSyrupChoice( String syrup )
                            {
                                    freeSyrupChoice= syrup;
                            }
                            public void setDeluxTopping (String xtraToppings)
                            {
                                    deluxeToppingList[counterD] = xtraToppings;
                                    counterD++;
                            }
                            public void setDefault()
                            {
                            flavor= " vanilla ";
                            numberOfScoops= 2;
                            costForScoops=2.79;
                            stdToppingList[0] = " whipped cream ";
                            stdToppingList[1] = " hot fudge syrup ";
                            stdToppingList[2] = " multi colored sprinkles ";
                            stdToppingList[3] = " cherry" ;
                            }
                            public void Print()
                            {
                            System.out.println(flavor + " "+ numberOfScoops+ " " + costForScoops +
                            " " +stdToppingList);
                            costOfDeluxeToppings = COST_PER_DELUXE_TOPPING*counterD;
                            costOfSundae = costOfDeluxeToppings + costForScoops;
                            tax=SALES_TAX*costOfSundae;
                            System.out.printf("Subtotal :$%.2f, tax:$%.2f, grand total: $%.2f " ,
                                    costOfSundae, tax, (costOfSundae+tax));
                            }
                            }
    if ((newSundae.getFreeSyrupChoice().equalsIgnoreCase("hot fudge"))
                    || (newSundae.getFreeSyrupChoice().equalsIgnoreCase("chocolate"))
                    || (newSundae.getFreeSyrupChoice().equalsIgnoreCase("caramel"))
                    || (newSundae.getFreeSyrupChoice().equalsIgnoreCase("strawberry"))) {
    }
有一个前导的
没有尾随的`)

      public class Sundae
                               {

  private String flavor;
                                       private int numberOfScoops;
                                    private double costForScoops;
                                    private String [] stdToppingList=new String [4];
                                    private String freeSyrupChoice;
                                    private String [] deluxeToppingList= new String [9];
                                    private int counterD= 0;
                                    private double costOfDeluxeToppings;
                                    private double costOfSundae;
                                    private final double SALES_TAX= .08625;
                                    private double tax;
                                    private final double COST_PER_DELUXE_TOPPING =.75;
                                    private int counterFree=0;
                                    public Sundae()
                                    {
                                            flavor= " vanilla ";
                                            numberOfScoops=2;
                                            costForScoops=2.79;
                                            stdToppingList[0]=" whipped cream ";
                                            stdToppingList[1]=" hot fudge syrup ";
                                            stdToppingList[2]=" multi colored sprinkles ";
                                            stdToppingList[3]=" cherry ";
                                    }
                            public String getFlavor()
                            {
                                    return flavor;
                            }
                            public int getNumberOfScoops()
                            {
                                    return numberOfScoops;
                            }
                            public double getCostForScoops()
                            {
                                    return costForScoops;
                            }
                            public String [] getStdTopping()
                            {
                                    return stdToppingList;
                            }
                            public String getFreeSyrupChoice()
                            {
                                    return freeSyrupChoice;
                            }
                            public String [] getDeluxeTopping()
                            {
                                    return deluxeToppingList;
                            }
                            public int getCounterD()
                            {
                                    return counterD;
                            }
                            public double getCostDeluxeToppings()
                            {
                                    return costOfDeluxeToppings;
                            }
                            public double getCostOFSundae()
                            {
                                    return costOfSundae;
                            }
                            public void setFlavor( String selection )
                            {
                                    flavor=selection;
                            }
                            public void setNumberOfScoops(int number)
                            {
                                    numberOfScoops= number;
                            }
                            public void setCostForScoops()
                            {
                            costForScoops= numberOfScoops + .79;
                            }
                            public void setStdTopping( String toppings )
                            {
                                    stdToppingList[counterFree] = toppings;
                                    counterFree++;
                            }
                            public void setFreeSyrupChoice( String syrup )
                            {
                                    freeSyrupChoice= syrup;
                            }
                            public void setDeluxTopping (String xtraToppings)
                            {
                                    deluxeToppingList[counterD] = xtraToppings;
                                    counterD++;
                            }
                            public void setDefault()
                            {
                            flavor= " vanilla ";
                            numberOfScoops= 2;
                            costForScoops=2.79;
                            stdToppingList[0] = " whipped cream ";
                            stdToppingList[1] = " hot fudge syrup ";
                            stdToppingList[2] = " multi colored sprinkles ";
                            stdToppingList[3] = " cherry" ;
                            }
                            public void Print()
                            {
                            System.out.println(flavor + " "+ numberOfScoops+ " " + costForScoops +
                            " " +stdToppingList);
                            costOfDeluxeToppings = COST_PER_DELUXE_TOPPING*counterD;
                            costOfSundae = costOfDeluxeToppings + costForScoops;
                            tax=SALES_TAX*costOfSundae;
                            System.out.printf("Subtotal :$%.2f, tax:$%.2f, grand total: $%.2f " ,
                                    costOfSundae, tax, (costOfSundae+tax));
                            }
                            }
main
方法中的最后一个
else
没有相应的
if

      public class Sundae
                               {

  private String flavor;
                                       private int numberOfScoops;
                                    private double costForScoops;
                                    private String [] stdToppingList=new String [4];
                                    private String freeSyrupChoice;
                                    private String [] deluxeToppingList= new String [9];
                                    private int counterD= 0;
                                    private double costOfDeluxeToppings;
                                    private double costOfSundae;
                                    private final double SALES_TAX= .08625;
                                    private double tax;
                                    private final double COST_PER_DELUXE_TOPPING =.75;
                                    private int counterFree=0;
                                    public Sundae()
                                    {
                                            flavor= " vanilla ";
                                            numberOfScoops=2;
                                            costForScoops=2.79;
                                            stdToppingList[0]=" whipped cream ";
                                            stdToppingList[1]=" hot fudge syrup ";
                                            stdToppingList[2]=" multi colored sprinkles ";
                                            stdToppingList[3]=" cherry ";
                                    }
                            public String getFlavor()
                            {
                                    return flavor;
                            }
                            public int getNumberOfScoops()
                            {
                                    return numberOfScoops;
                            }
                            public double getCostForScoops()
                            {
                                    return costForScoops;
                            }
                            public String [] getStdTopping()
                            {
                                    return stdToppingList;
                            }
                            public String getFreeSyrupChoice()
                            {
                                    return freeSyrupChoice;
                            }
                            public String [] getDeluxeTopping()
                            {
                                    return deluxeToppingList;
                            }
                            public int getCounterD()
                            {
                                    return counterD;
                            }
                            public double getCostDeluxeToppings()
                            {
                                    return costOfDeluxeToppings;
                            }
                            public double getCostOFSundae()
                            {
                                    return costOfSundae;
                            }
                            public void setFlavor( String selection )
                            {
                                    flavor=selection;
                            }
                            public void setNumberOfScoops(int number)
                            {
                                    numberOfScoops= number;
                            }
                            public void setCostForScoops()
                            {
                            costForScoops= numberOfScoops + .79;
                            }
                            public void setStdTopping( String toppings )
                            {
                                    stdToppingList[counterFree] = toppings;
                                    counterFree++;
                            }
                            public void setFreeSyrupChoice( String syrup )
                            {
                                    freeSyrupChoice= syrup;
                            }
                            public void setDeluxTopping (String xtraToppings)
                            {
                                    deluxeToppingList[counterD] = xtraToppings;
                                    counterD++;
                            }
                            public void setDefault()
                            {
                            flavor= " vanilla ";
                            numberOfScoops= 2;
                            costForScoops=2.79;
                            stdToppingList[0] = " whipped cream ";
                            stdToppingList[1] = " hot fudge syrup ";
                            stdToppingList[2] = " multi colored sprinkles ";
                            stdToppingList[3] = " cherry" ;
                            }
                            public void Print()
                            {
                            System.out.println(flavor + " "+ numberOfScoops+ " " + costForScoops +
                            " " +stdToppingList);
                            costOfDeluxeToppings = COST_PER_DELUXE_TOPPING*counterD;
                            costOfSundae = costOfDeluxeToppings + costForScoops;
                            tax=SALES_TAX*costOfSundae;
                            System.out.printf("Subtotal :$%.2f, tax:$%.2f, grand total: $%.2f " ,
                                    costOfSundae, tax, (costOfSundae+tax));
                            }
                            }
        if ((deluxe.equalsIgnoreCase("M&Ms"))
                        || (deluxe.equalsIgnoreCase("crushed oreos"))
                        || (deluxe.equalsIgnoreCase("reeses peices"))
                        || (deluxe.equalsIgnoreCase("bwonie crunches"))
                        || (deluxe.equalsIgnoreCase("mint chocolate chip"))
                        || (deluxe.equalsIgnoreCase("marshmallows"))
                        || (deluxe.equalsIgnoreCase("peanuts"))
                        || (deluxe.equalsIgnoreCase("walnuts"))
                        || (deluxe.equalsIgnoreCase("peanuts and walnuts"))) {
            (newSundae.setDeluxTopping(deluxe);
                                              ^---- ??

我强烈建议您采用更合适的缩进策略和/或使用支持自动代码格式化的IDE,这将帮助您跟踪所有括号…甚至使用
开关
语句…

将for循环更改为:

      public class Sundae
                               {

  private String flavor;
                                       private int numberOfScoops;
                                    private double costForScoops;
                                    private String [] stdToppingList=new String [4];
                                    private String freeSyrupChoice;
                                    private String [] deluxeToppingList= new String [9];
                                    private int counterD= 0;
                                    private double costOfDeluxeToppings;
                                    private double costOfSundae;
                                    private final double SALES_TAX= .08625;
                                    private double tax;
                                    private final double COST_PER_DELUXE_TOPPING =.75;
                                    private int counterFree=0;
                                    public Sundae()
                                    {
                                            flavor= " vanilla ";
                                            numberOfScoops=2;
                                            costForScoops=2.79;
                                            stdToppingList[0]=" whipped cream ";
                                            stdToppingList[1]=" hot fudge syrup ";
                                            stdToppingList[2]=" multi colored sprinkles ";
                                            stdToppingList[3]=" cherry ";
                                    }
                            public String getFlavor()
                            {
                                    return flavor;
                            }
                            public int getNumberOfScoops()
                            {
                                    return numberOfScoops;
                            }
                            public double getCostForScoops()
                            {
                                    return costForScoops;
                            }
                            public String [] getStdTopping()
                            {
                                    return stdToppingList;
                            }
                            public String getFreeSyrupChoice()
                            {
                                    return freeSyrupChoice;
                            }
                            public String [] getDeluxeTopping()
                            {
                                    return deluxeToppingList;
                            }
                            public int getCounterD()
                            {
                                    return counterD;
                            }
                            public double getCostDeluxeToppings()
                            {
                                    return costOfDeluxeToppings;
                            }
                            public double getCostOFSundae()
                            {
                                    return costOfSundae;
                            }
                            public void setFlavor( String selection )
                            {
                                    flavor=selection;
                            }
                            public void setNumberOfScoops(int number)
                            {
                                    numberOfScoops= number;
                            }
                            public void setCostForScoops()
                            {
                            costForScoops= numberOfScoops + .79;
                            }
                            public void setStdTopping( String toppings )
                            {
                                    stdToppingList[counterFree] = toppings;
                                    counterFree++;
                            }
                            public void setFreeSyrupChoice( String syrup )
                            {
                                    freeSyrupChoice= syrup;
                            }
                            public void setDeluxTopping (String xtraToppings)
                            {
                                    deluxeToppingList[counterD] = xtraToppings;
                                    counterD++;
                            }
                            public void setDefault()
                            {
                            flavor= " vanilla ";
                            numberOfScoops= 2;
                            costForScoops=2.79;
                            stdToppingList[0] = " whipped cream ";
                            stdToppingList[1] = " hot fudge syrup ";
                            stdToppingList[2] = " multi colored sprinkles ";
                            stdToppingList[3] = " cherry" ;
                            }
                            public void Print()
                            {
                            System.out.println(flavor + " "+ numberOfScoops+ " " + costForScoops +
                            " " +stdToppingList);
                            costOfDeluxeToppings = COST_PER_DELUXE_TOPPING*counterD;
                            costOfSundae = costOfDeluxeToppings + costForScoops;
                            tax=SALES_TAX*costOfSundae;
                            System.out.printf("Subtotal :$%.2f, tax:$%.2f, grand total: $%.2f " ,
                                    costOfSundae, tax, (costOfSundae+tax));
                            }
                            }
//??
else {
    newSundae.setDefault();
    newSundae.Print();
}
for(inti-0;i
使用它!
导入java.util.Scanner;
公共级圣代驾驶员
{
公共静态void main(字符串[]args)
{
圣代新圣代=新圣代();
扫描仪输入=新扫描仪(System.in);
System.out.println(“您喜欢哪种圣代口味?”);
setFlavor(input.nextLine());
if((newSundae.getFlavor().equalsIgnoreCase(“香草”))||
(newSundae.getFlavor().equalsIgnoreCase(“花生酱”))||
(newSundae.getFlavor().equalsIgnoreCase(“巧克力”))||
(newSundae.getFlavor().equalsIgnoreCase(“椰子”))||
(newSundae.getFlavor().equalsIgnoreCase(“饼干面团”))||
(newSundae.getFlavor().equalsIgnoreCase(“咖啡”))||
(newSundae.getFlavor().equalsIgnoreCase(“草莓”))||
(newSundae.getFlavor().equalsIgnoreCase(“黄油山核桃”))
{
}
其他的
{
newSundae.setDefault();
newSundae.Print();
}
System.out.println(“多少勺?”);
setNumberOfScoops(input.nextInt());
if((newSundae.getNumberOfScoops()==1)||
(newSundae.getNumberOfScoops()==2)||
(newSundae.getNumberOfScoops()==3)||
(newSundae.getNumberOfScoops()==4)||
(newSundae.getNumberOfScoops()==5)||
(newSundae.getNumberOfScoops()==6))
{
}
其他的
{
newSundae.setDefault();
newSundae.Print();
}
System.out.println(“您想要多少免费浇头”);
int num=input.nextInt();
input.nextLine();

对于(int i=0;iWell,您只需读取错误消息。
)例如,expected
意味着应该有一个
…在for循环
的初始化位置,您想做什么(int i-0
。你必须初始化一个变量。阅读错误消息,在If语句中你不能使用它,因为它返回void。所以仔细阅读错误消息并尝试解决它们。你有很多语法错误,尝试使用IDE来解决这些错误。错误非常简单。你使用IDE来解决吗编写代码?