/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication19;
import java.util.Scanner;
/**
*
* @author joshu
*/
public class JavaApplication19 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// also please don't block me this is my second time using this site
System.out.println("// SALES_TAX////////////////////////////////////");
Scanner input = new Scanner(System.in);
String emailAddress;
double itemPrice, itemAmount, SALES_TAX;
System.out.println("How many item will you like to buy?");
itemAmount = input.nextDouble();
System.out.println("What is the price of the item?");
itemPrice = input.nextDouble();
System.out.println("Enter sales tax rate: ");
SALES_TAX = input.nextDouble();
final Double SalesTaxRate = SALES_TAX * itemPrice;
double totalprice = SalesTaxRate + (itemPrice * itemAmount);
emailAddress = input.nextLine();
System.out.println("Please enter emailAddress");
emailAddress = input.nextLine();
System.out.printf("Your total price is: $ %1.2f" + " a copy of this invoice"
+ " will be emailed to: %s\n",
totalprice,emailAddress.toUpperCase());
System.out.println("///////////////////////////////////////////");
}
}
-2
A
回答
2
這條線是有問題對於初學者:
final Double SalesTaxRate = SALES_TAX * itemPrice;
double totalprice = SalesTaxRate + (itemPrice * itemAmount);
你只是增加稅率上的單個項目,總金額不。
0
我會改變邏輯您的總的計算,像這樣:
//gets the percentage of the item, and then adds the item price
final Double SalesTaxRate = itemPrice + (itemPrice * (SALES_TAX/100));
//simply multiply the new price by the amount required
double totalprice = SalesTaxRate * itemAmount;
相關問題
- 1. PHP銷售稅計算
- 2. Quickbooks桌面api獲得銷售稅稅率和相應的銷售稅代碼
- 3. 計算銷售稅和總計
- 4. jQuery銷售稅
- 5. 有條件的程序 - 計算銷售稅的設計功能?
- 6. 計算總銷售額增值稅
- 7. 銷售稅和小費計算器
- 8. 銷售稅申請未計算營業稅
- 9. 計算我的收入計劃中的一部分稅收與稅率和稅率在java
- 10. 退出銷售稅
- 11. DHL稅率計算
- 12. ASP.net/Classic ASP:通過Zip計算銷售稅率?
- 13. 在收銀員計劃中計算銷售稅
- 14. 計算總成本並將購物車添加銷售稅
- 15. 增加銷售稅將jQuery計算插件
- 16. PayPal IPN自動銷售稅?
- 17. 從QBO獲得銷售稅
- 18. Ruby類獲得銷售稅
- 19. 自動銷售稅表
- 20. 4D自動銷售稅
- 21. javascript 101:銷售稅計算器不響應數據輸入
- 22. 計算有不同的產品稅匯率PHP SQL稅
- 23. 使用QBFC添加銷售稅項目
- 24. QB將銷售稅增加到項目
- 25. Openbravo銷售點:稅後一定數額
- 26. 哪個表持有銷售訂單稅?
- 27. 試圖計算Magento中的單個項目的銷售稅,而不顯示包括稅的價格
- 28. 如何使用此腳本計算銷售稅?
- 29. PHP只計算州居民銷售稅只
- 30. 計算稅額
所以你調試到代碼?它的行爲方式與您期望的不同? –
即時通訊初學者,所以我仍然在學習,所以我不知道這是我的代碼或我的百分比編寫方式的問題,因爲我試圖讓百分之百的稅率加倍價格 –
我看到的一件事 - 重新將SalesTaxRate添加到價格*金額;所以稅款只收取一次。 – theGleep