通过扫描仪订购披萨
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)))