salestax.java

来自「Java 入门书的源码」· Java 代码 · 共 27 行

JAVA
27
字号
//Copyright (c) 1998, Arthur Gittleman
//This example is provided WITHOUT ANY WARRANTY either expressed or implied.

//Debugging Exercise 3.8 -- Has Errors

               public class SalesTax {
                   public static void main(String [] args) {
                       double taxA = .05, taxB= .04;
                       double priceA =
                            Io.readInt("Enter a purchase price in County A, -1 to quit");
                       double totalA = 0.0, totalB = 0.0;
                       while (priceA >= 0) {
                            totalA += priceA;
                            priceA = 
                               Io.readInt("Enter a purchase price in County A, -1 to quit");
                       }
                       while (priceB >= 0) {
                            totalB += priceB;
                            priceB = 
                               Io.readInt("Enter a purchase price in County B, -1 to quit");   
                       }
                       double tax = priceA*taxA + priceB*taxB;
                       System.out.print("The total sales tax is");
                       Io.println$(tax);
                   }
               }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?