集册 Java实例教程 通过扫描仪订购比萨饼

通过扫描仪订购比萨饼

欢马劈雪     最近更新时间:2020-01-02 10:19:05

445
通过扫描仪订购披萨


import java.text.DecimalFormat;

import java.util.Scanner;

/* 
*来 自
 时 代 J     a    v  a - nowjava.com
*/


public class order {


  public static void main(String[] args) {

        

        DecimalFormat df= new DecimalFormat ("0.00");

        double priceofburger = 1.69;

        double priceoffries = 1.09;

        double priceofsoda = 0.99;

        

        int numberofburgers;

        int numberoffries;

        int numberofsoda;

        

        double amounttendered;

        double change;

        double finaltotal;/** from 时   代     Java  公  众  号 - nowjava.com**/

        Scanner scan = new Scanner(System.in);

        

        System.out.println("Enter the number of burgers:");

        numberofburgers= scan.nextInt();

        System.out.println("Enter the number of fries:");

        numberoffries= scan.nextInt();

        System.out.println("Enter the number of soda:");

        numberofsoda= scan.nextInt();

       

        System.out.println("Total before tax:" + (df.format(priceofburger* numberofburgers + priceoffries*numberoffries + priceofsoda*numberofsoda)));

        

        double tax = (priceofburger* numberofburgers + priceoffries*numberoffries + priceofsoda*numberofsoda) * 0.065;

       

        System.out.println("Tax:" + (df.format( tax)));  

        

        System.out.println("Final total=" + (df.format(priceofburger* numberofburgers + priceoffries*numberoffries + priceofsoda*numberofsoda*tax)))
展开阅读全文