Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pizzas购买的程序Java*已修复*_Java - Fatal编程技术网

Pizzas购买的程序Java*已修复*

Pizzas购买的程序Java*已修复*,java,Java,无法编译的入门级java程序。任何帮助都将是惊人的!我真的需要快速回顾一下我的基本代码。我得到整数、布尔和双精度的错误。我试着用多种方式重新排列它们,但我就是无法让它工作。还有我的奶酪皮计算加上它的总数。再次超级新手,但会真正享受帮助 import java.util.Scanner; public class programmingassignment1 { public static void main(String[] args) { Scanner keyboard =

无法编译的入门级java程序。任何帮助都将是惊人的!我真的需要快速回顾一下我的基本代码。我得到整数、布尔和双精度的错误。我试着用多种方式重新排列它们,但我就是无法让它工作。还有我的奶酪皮计算加上它的总数。再次超级新手,但会真正享受帮助

import java.util.Scanner;

public class programmingassignment1 {
   public static void main(String[] args) {

   Scanner keyboard = new Scanner( System.in );

      int pizzaLength;
      int pizzaWidth;
      int pizzaShape;
      double pizzaDiamiter;
      double pizzaToppingPrice = 0.025;
      int numberOfPizzaToppings;
      double pizzaSauceAndCheese = 0.036;
      double pizzaDoughPrice = 0.019;
      char doughType;
      String dough;
      int numberOfPizzas;
      double pizzasBeforeTax;
      int cheesyCrustInput;
      int deliveryWantedInput;
      int deliveryCharge;
      double doughVolume;
      double area;
      double crustCost;
      int basePrice;
      int costOfPizzaWithTax;


      //Shape of pizza
      System.out.println("What shape of pizza requested?");
      System.out.println("Enter (1) for Rectange or (2) Round?");
      pizzaShape = keyboard.nextLine().charAt(0);

      if(pizzaShape == 1){
               System.out.println("What Length?");
               pizzaLength = keyboard.nextInt();
               System.out.println("What Width?");
               pizzaWidth = keyboard.nextInt();
               area = pizzaLength * pizzaWidth;
               }
      else if(pizzaShape == 2){
               System.out.println("What is the Diamiter?");
               pizzaDiamiter = keyboard.nextInt();
               area = Math.PI * (pizzaDiamiter / 2);
               }

      //Volume
      System.out.print("What type of dough do you want? (1)Classic Hand-Tossed, (2)Thin and Crispy, (3)Texas Toast, or (4)Pan. (enter 1,2,3, or 4.");
      doughType = keyboard.nextLine().charAt(0);

      if (doughType == 1) {
          dough = "Classic Hand-Tossed";
          doughVolume = area * .25;
          } 
      else if (doughType == 2) {
          dough = "Thin and Crispy";
          doughVolume = area * .1;
          } 
      else if (doughType == 3) {
          dough = "Texas Toast";
          doughVolume = area * .9;
          }
      else if (doughType == 4) {
          dough = "Pan";
          doughVolume = area * .5;
          }  

      //Cheesey crust
      if(doughType == 2){
      }
      else{
          System.out.println("Would you like cheesy crust? (1) for yes (2) for no");
          cheesyCrustInput = keyboard.nextInt();
               if(cheesyCrustInput == 1){
               crustCost = area * .02;
               String Crust = "";
               }
               else{
               String Crust = "NO";
               }
      }

      //Toppings
      System.out.print("Enter the number of toppings:");
      numberOfPizzaToppings = keyboard.nextInt();
      if(numberOfPizzaToppings == 0){
         String toppings = "no";
         }
      else{
         int toppings = numberOfPizzaToppings;
         }

      //Base price
      basePrice = area (pizzaSauceAndCheese + (pizzaToppingPrice * numberOfPizzaToppings) + (pizzaDoughPrice * doughVolume));

      //how many pizzas
       System.out.print("Enter the number of pizzas being ordered:");
       numberOfPizzas = keyboard.nextInt();
       pizzasBeforeTax = basePrice * numberOfPizzas;

      //tax
      costOfPizzaWithTax = pizzasBeforeTax ( 1 + 0.07);

      //delivery fee
      System.out.print("Would you like delivery? (1) for yes, (2) for no.");
      deliveryWantedInput = keyboard.nextInt();
      if(deliveryWantedInput == 1){
         String deliveryOutput = numberOfPizzas + "deliverd";
         if(costOfPizzaWithTax < 10){
         deliveryCharge = 3;
         }
         if( 10 < costOfPizzaWithTax && costOfPizzaWithTax < 20 ){
         deliveryCharge = 2;
         }
         if(20 < costOfPizzaWithTax && costOfPizzaWithTax < 30){
         deliveryCharge = 1;
         }
         if(costOfPizzaWithTax > 30){
         deliveryCharge = 0;
         }
      }
      else{
      String deliveryOutput = "no delivery";
      }

      //display total
      total = costOfPizzaWithTax + deliveryCharge;
      System.out.println("Total Due: $" + df.format(total));
      if(pizzaShape = 1){
      System.out.print("User requested: Rectangular, " + pizzaWidth + "X" + pizzaLength + ", " + dough + toppings + "topping(s)" 
                      + Crust + "cheesy crust," + deliveryOutput + " - Program Output:");
      System.out.println("Details for - Rectangular Pizza (" + pizzaWidth + "\" X " + pizzaLength + "\"):");
      System.out.println( "Area:  " + area );
      System.out.println( "Volume:" + doughVolume);
      System.out.println( "Base price:   $" + basePrice);
      System.out.println( "With Cheesy:  $");
      System.out.println( "Multi Total:  $" + pizzasBeforeTax);
      System.out.println( "With Tax:     $" + costOfPizzaWithTax);
      System.out.println( "And Delivery: $" + total);

      }
      else{
      System.out.print("User requested: Circular, " + pizzaDiamiter + "\", " + dough + toppings + "topping(s)" 
                      + Crust + "cheesy crust," + deliveryOutput + " - Program Output:");
      System.out.println( "Area:  " + area );
      System.out.println( "Volume:" + doughVolume);
      System.out.println( "Base price:   $" + basePrice);
      System.out.println( "With Cheesy:  $");
      System.out.println( "Multi Total:  $" + pizzasBeforeTax);
      System.out.println( "With Tax:     $" + costOfPizzaWithTax);
      System.out.println( "And Delivery: $" + total);
      }                   
   }
}
import java.util.Scanner;
公共课程计划作业1{
公共静态void main(字符串[]args){
扫描仪键盘=新扫描仪(System.in);
整数披萨长度;
国际比萨饼宽度;
内部比萨饼形状;
双比萨饼;
双倍披萨最高价格=0.025;
比萨配料的国际编号;
双层比萨酱和奶酪=0.036;
双比萨饼价格=0.019;
炭豆型;
生面团;
国际比萨饼协会;
双层比萨饼;
int cheesecrustinput;
int deliveryWantedInput;
运费;
双道格拉斯体积;
双区;
双重成本;
国际基准价;
国际价格税;
//比萨饼的形状
System.out.println(“需要什么形状的比萨饼?”);
System.out.println(“输入(1)表示矩形或(2)表示圆形?”);
pizzaShape=keyboard.nextLine().charAt(0);
if(pizzaShape==1){
System.out.println(“什么长度?”);
pizzaLength=keyboard.nextInt();
System.out.println(“什么宽度?”);
pizzaWidth=keyboard.nextInt();
面积=比萨长度*比萨宽度;
}
else if(pizzaShape==2){
System.out.println(“数据表是什么?”);
pizzadamiter=keyboard.nextInt();
面积=数学PI*(Pizzadamiter/2);
}
//卷
System.out.print(“您想要哪种面团?(1)经典的手抛面团,(2)薄脆的面团,(3)德克萨斯土司,或(4)平底锅。(输入1、2、3或4)。”;
doughType=keyboard.nextLine().charAt(0);
如果(doughType==1){
面团=“经典手抛”;
doughVolume=面积*.25;
} 
else if(doughType==2){
面团=“薄而脆”;
doughVolume=面积*.1;
} 
else if(doughType==3){
面团=“德克萨斯土司”;
doughVolume=面积*.9;
}
else if(doughType==4){
面团=“潘”;
doughVolume=面积*.5;
}  
//干酪皮
如果(doughType==2){
}
否则{
System.out.println(“您想要奶酪皮吗?(1)表示是(2)表示否”);
cheesecrustinput=keyboard.nextInt();
如果(输入==1){
成本=面积*.02;
字符串外壳=”;
}
否则{
String=“否”;
}
}
//浇头
System.out.print(“输入浇头数:”);
numberOfPizzaToppings=键盘.nextInt();
如果(比萨配料的数量==0){
String-toppings=“否”;
}
否则{
int toppings=比萨浇头的数量;
}
//底价
基价=面积(比萨酱和奶酪+(比萨酱价格*比萨酱数量)+(比萨酱价格*面团体积));
//有多少比萨饼
System.out.print(“输入订购的比萨饼数量:”);
numberOfPizzas=keyboard.nextInt();
PizzasBefortax=基准价格*比萨数量;
//税
含税比萨的成本=比萨前(1+0.07);
//送货费
系统输出打印(“您想要送货吗?(1)表示是,(2)表示否”);
deliveryWantedInput=keyboard.nextInt();
如果(deliveryWantedInput==1){
字符串deliveryOutput=numberOfPizzas+“delivered”;
if(含税的比萨成本<10){
送货费=3;
}
if(10<含税的比萨成本和含税的比萨成本<20){
送货费=2;
}
if(20<含税的比萨成本和含税的比萨成本<30){
送货费=1;
}
如果(含税的价格成本>30){
送货费=0;
}
}
否则{
String deliveryOutput=“无交付”;
}
//显示总数
总计=含税的发票成本+运费;
System.out.println(“到期总额:$”+df.format(总额));
如果(pizzaShape=1){
系统输出打印(“用户请求:矩形,“+比萨宽度+”X“+比萨长度+”,“+面团+配料+”配料)
+结壳+“奶酪结壳,”+deliveryOutput+“-程序输出:”);
System.out.println(“矩形比萨饼的详细信息(“+pizzaWidth+”\“X”+pizzaWidth+“\”)”);
System.out.println(“面积:“+面积”);
System.out.println(“卷:+doughVolume”);
System.out.println(“基价:$”+基价);
System.out.println(“With Cheesy:$”;
System.out.println(“多重总计:$”+比萨饼前胸);
System.out.println(“带税:$”+带税的Pizza成本);
System.out.println(“和交付:$”+总计);
}
否则{
System.out.print(“用户请求:圆形,“+Pizzadamiter+”\“,“+面团+配料+”配料)
+结壳+“奶酪结壳,”+deliveryOutput+“-程序输出:”);
System.out.println(“面积:“+面积”);
System.out.println(“卷:+doughVolume”);
System.out.println(“基价:$”+基价);
System.out.println(“With Cheesy:$”;
System.out.println(“多重总计:$”+比萨饼前胸);
System.out.println(“带税:$”+带税的Pizza成本);
System.out.println(“和交付:$”+总计);
}                   
}
}

固定内容如下

导入java.util.Scanner

公共课程计划作业1{ 公共静态void main(字符串[]args){

扫描仪键盘
    Scanner keyboard = new Scanner(System.in);

    final double PIZZA_TOPPING_PRICE = 0.025;
  final double PIZZA_SAUCE_AND_CHEESE = 0.036;
    final double PIZZA_DOUGH_PRICE = 0.019;
  double numberOfPizzaToppings;
  double crustCost;
    double basePrice;
  double radiusOfPizza;
    double sizeOfPizzaCrust;
  double pizzasBeforeTax;
  double pizzaLength = 1;
    double pizzaWidth = 1;
    double pizzaShape = 1;
    double pizzaDiamiter = 0;
    double doughType = 1;
    double numberOfPizzas = 0;
    double cheesyCrustInput = 0;
    double deliveryWantedInput = 0;
    double deliveryCharge = 0;
    double doughVolume = 1;
    double area = 1;
    double costOfPizzaWithTax = 1;
    double total = 1;
    double toppings = 1;
  String dough = "";
  String crust = "";
    String deliveryOutput;
  String cheesyOutput = "";

    // Shape of pizza
    System.out.println("What shape of pizza requested?");
    System.out.println("Enter (1) for Rectangle or (2) Round:");
    pizzaShape = keyboard.nextDouble();

    if (pizzaShape == 1) {
        System.out.println("What Length?");
        pizzaLength = keyboard.nextDouble();
        System.out.println("What Width?");
        pizzaWidth = keyboard.nextDouble();
        area = pizzaLength * pizzaWidth;
    } else if (pizzaShape == 2) {
        System.out.println("What is the Diamiter?");
        pizzaDiamiter = keyboard.nextDouble();
        radiusOfPizza = pizzaDiamiter / 2;
        area = Math.PI * radiusOfPizza * radiusOfPizza;
    }

    // Volume
    System.out.print("What type of dough do you want? (1)Classic Hand Tossed,"
        + " (2)Thin and Crispy, (3)Texas Toast, or (4)Pan. \n(Enter 1,2,3, or 4.)");
    doughType = keyboard.nextDouble();

    if (doughType == 1) {
        dough = "Classic Hand Tossed";
        doughVolume = area * .25;
    } else if (doughType == 2) {
        dough = "Thin and Crispy";
        doughVolume = area * .1;
    } else if (doughType == 3) {
        dough = "Texas Toast";
        doughVolume = area * .9;
    } else if (doughType == 4) {
        dough = "Pan";
        doughVolume = area * .5;
    }

    // Toppings
    System.out.print("Enter the number of toppings:");
    numberOfPizzaToppings = keyboard.nextDouble();
    toppings = numberOfPizzaToppings;


    // Base price
    basePrice = area * (PIZZA_SAUCE_AND_CHEESE + PIZZA_TOPPING_PRICE * numberOfPizzaToppings)
            + PIZZA_DOUGH_PRICE * doughVolume;

    // Cheesey crust
    if (doughType == 2) {
        cheesyOutput = " no cheesy crust";
        crustCost = basePrice;
    } else {
        System.out.println("Would you like cheesy crust? (1) for yes (2) for no.");
        cheesyCrustInput = keyboard.nextDouble();
        if (cheesyCrustInput == 1 && pizzaShape == 2) {
            sizeOfPizzaCrust = 2 * Math.PI * (pizzaDiamiter / 2);
            crustCost = (sizeOfPizzaCrust * .02) + basePrice;
            crust = "";
            cheesyOutput = " cheesy crust";
        } else if (cheesyCrustInput == 1 && pizzaShape == 1) {
            sizeOfPizzaCrust = 2 * (pizzaLength + pizzaWidth);
            crustCost = (sizeOfPizzaCrust * .02) + basePrice;
            crust = "";
            cheesyOutput = " cheesy crust";
        } else {
            crust = " NO cheesy crust";
            crustCost = basePrice;
        }
    }

    // how many pizzas
    System.out.print("Enter the number of pizzas being ordered:");
    numberOfPizzas = keyboard.nextDouble();
    pizzasBeforeTax = crustCost * numberOfPizzas;

    // tax
    costOfPizzaWithTax = pizzasBeforeTax * (1 + 0.07);

    // delivery fee
    System.out.print("Would you like delivery? (1) for yes, (2) for no.");
    deliveryWantedInput = keyboard.nextDouble();
    if (deliveryWantedInput == 1) {
        deliveryOutput = (int) numberOfPizzas + " pizza delivered";
        if (costOfPizzaWithTax < 10) {
            deliveryCharge = 3;
        } else if (10 < costOfPizzaWithTax && costOfPizzaWithTax < 20) {
            deliveryCharge = 2;
        } else if (20 < costOfPizzaWithTax && costOfPizzaWithTax < 30) {
            deliveryCharge = 1;
        } else if (costOfPizzaWithTax > 30) {
            deliveryCharge = 0;
        }
    } else {
        deliveryOutput = "no delivery";
        deliveryCharge = 0;
    }

    // display total
    total = costOfPizzaWithTax + deliveryCharge;

    if (pizzaShape == 1) {
        System.out.print("User requested: Rectangular, " + (int) pizzaLength + "X" 
           + (int) pizzaWidth + ", " + dough
                + ", " + (int) toppings + " topping(s)," + crust + cheesyOutput + ", " 
           + deliveryOutput + " - Program Output:");
        System.out.println("\nDetails for - Rectangular Pizza (" + pizzaLength + "\" X " 
           + pizzaWidth + "\"):");
        System.out.printf("Area:    %.3f\n", area);
        System.out.printf("Volume:  %.3f\n", doughVolume);
        System.out.printf("Base price:   $%.2f", basePrice);
        System.out.printf("\nWith Cheesy:  $%.2f", crustCost);
        System.out.printf("\nMulti Total:  $%.2f", pizzasBeforeTax);
        System.out.printf("\nWith Tax:     $%.2f", costOfPizzaWithTax);
        System.out.printf("\nAnd Delivery: $%.2f", total);
    }

    else {
        System.out.print("User requested: Circular, " + (int) pizzaDiamiter + "\", " 
           + dough + ", " + (int) toppings + " topping(s)," + crust + cheesyOutput 
           + ", " + deliveryOutput + " - Program Output:");
        System.out.println("\nDetails for - Round Pizza (" + pizzaDiamiter + "\" diameter):");
        System.out.printf("Area:    %.3f\n", area);
        System.out.printf("Volume:  %.3f\n", doughVolume);
        System.out.printf("Base price:   $%.2f", basePrice);
        System.out.printf("\nWith Cheesy:  $%.2f", crustCost);
        System.out.printf("\nMulti Total:  $%.2f", pizzasBeforeTax);
        System.out.printf("\nWith Tax:     $%.2f", costOfPizzaWithTax);
        System.out.printf("\nAnd Delivery: $%.2f", total);
    }

}
if ( condition ) {
  String topping = "topping";
}

System.out.println(topping);
String topping = "default";
if ( condition ) {
  topping = "topping";
}
System.out.println(topping);
import java.util.Scanner;

public class pizzas {
   public static void main(String[] args) {

   Scanner keyboard = new Scanner( System.in );

      int pizzaLength = 0;
      int pizzaWidth = 0;
      int pizzaShape;
      double pizzaDiamiter = 0;
      double pizzaToppingPrice = 0.025;
      int numberOfPizzaToppings;
      double pizzaSauceAndCheese = 0.036;
      double pizzaDoughPrice = 0.019;
      char doughType;
      String dough = null;
      int numberOfPizzas;
      double pizzasBeforeTax;
      int cheesyCrustInput;
      int deliveryWantedInput;
      int deliveryCharge = 0;
      double doughVolume = 0;
      double area = 0;
      double crustCost;
      int basePrice;
      int costOfPizzaWithTax;


      //Shape of pizza
      System.out.println("What shape of pizza requested?");
      System.out.println("Enter (1) for Rectange or (2) Round?");
      pizzaShape = keyboard.nextLine().charAt(0);

      if(pizzaShape == 1){
               System.out.println("What Length?");
               pizzaLength = keyboard.nextInt();
               System.out.println("What Width?");
               pizzaWidth = keyboard.nextInt();
               area = pizzaLength * pizzaWidth;
               }
      else if(pizzaShape == 2){
               System.out.println("What is the Diamiter?");
               pizzaDiamiter = keyboard.nextInt();
               area = Math.PI * (pizzaDiamiter / 2);
               }

      //Volume
      System.out.print("What type of dough do you want? (1)Classic Hand-Tossed, (2)Thin and Crispy, (3)Texas Toast, or (4)Pan. (enter 1,2,3, or 4.");
      doughType = keyboard.nextLine().charAt(0);
      String Crust = "";
      String deliveryOutput="";
      if (doughType == 1) {
          dough = "Classic Hand-Tossed";
          doughVolume = area * .25;
          } 
      else if (doughType == 2) {
          dough = "Thin and Crispy";
          doughVolume = area * .1;
          } 
      else if (doughType == 3) {
          dough = "Texas Toast";
          doughVolume = area * .9;
          }
      else if (doughType == 4) {
          dough = "Pan";
          doughVolume = area * .5;
          }  

      //Cheesey crust
      if(doughType == 2){
      }
      else{
          System.out.println("Would you like cheesy crust? (1) for yes (2) for no");
          cheesyCrustInput = keyboard.nextInt();
               if(cheesyCrustInput == 1){
               crustCost = area * .02;
                Crust = "";
               }
               else{
                Crust = "NO";
               }
      }

      //Toppings
      System.out.print("Enter the number of toppings:");
      numberOfPizzaToppings = keyboard.nextInt();
      int toppings;
      if(numberOfPizzaToppings == 0){
          toppings = 0;
         }
      else{
           toppings = numberOfPizzaToppings;
         }

      //Base price
      basePrice = area (pizzaSauceAndCheese + (pizzaToppingPrice * numberOfPizzaToppings) + (pizzaDoughPrice * doughVolume));

      //how many pizzas
       System.out.print("Enter the number of pizzas being ordered:");
       numberOfPizzas = keyboard.nextInt();
       pizzasBeforeTax = basePrice * numberOfPizzas;

      //tax
      costOfPizzaWithTax = pizzasBeforeTax ( 1 + 0.07);

      //delivery fee
      System.out.print("Would you like delivery? (1) for yes, (2) for no.");
      deliveryWantedInput = keyboard.nextInt();
      if(deliveryWantedInput == 1){
          deliveryOutput = numberOfPizzas + "deliverd";
         if(costOfPizzaWithTax < 10){
         deliveryCharge = 3;
         }
         if( 10 < costOfPizzaWithTax && costOfPizzaWithTax < 20 ){
         deliveryCharge = 2;
         }
         if(20 < costOfPizzaWithTax && costOfPizzaWithTax < 30){
         deliveryCharge = 1;
         }
         if(costOfPizzaWithTax > 30){
         deliveryCharge = 0;
         }
      }
      else{
       deliveryOutput = "no delivery";
      }

      //display total
      int total = costOfPizzaWithTax + deliveryCharge;

    //System.out.println("Total Due: $" + df.format(total));

      if(pizzaShape == 1){
      System.out.print("User requested: Rectangular, " + pizzaWidth + "X"
      + pizzaLength + ", " + dough + toppings + "topping(s)" 
                      + Crust + "cheesy crust," + deliveryOutput + " - Program Output:");
      System.out.println("Details for - Rectangular Pizza (" + pizzaWidth + "\" X " + pizzaLength + "\"):");
      System.out.println( "Area:  " + area );
      System.out.println( "Volume:" + doughVolume);
      System.out.println( "Base price:   $" + basePrice);
      System.out.println( "With Cheesy:  $");
      System.out.println( "Multi Total:  $" + pizzasBeforeTax);
      System.out.println( "With Tax:     $" + costOfPizzaWithTax);
      System.out.println( "And Delivery: $" + total);

      }
      else{
      System.out.print("User requested: Circular, " + pizzaDiamiter + "\", " + dough + toppings + "topping(s)" 
                      + Crust + "cheesy crust," + deliveryOutput + " - Program Output:");
      System.out.println( "Area:  " + area );
      System.out.println( "Volume:" + doughVolume);
      System.out.println( "Base price:   $" + basePrice);
      System.out.println( "With Cheesy:  $");
      System.out.println( "Multi Total:  $" + pizzasBeforeTax);
      System.out.println( "With Tax:     $" + costOfPizzaWithTax);
      System.out.println( "And Delivery: $" + total);
      }                   
   }
private static int pizzasBeforeTax(double d) {
    // TODO Auto-generated method stub
    return 0;
}

private static int area(double d) {
    // TODO Auto-generated method stub
    return 0;
}