首頁 > php教程 > php手册 > 主體

PHP 5, PHP/Java Bridge & Apache on XP PRO + SP2 and

WBOY
發布: 2016-06-06 19:46:56
原創
1092 人瀏覽過

Example - SalesTax.java, salestax.php, salestax.htm C:\Program Files\Apache Group\Apache2\htdocs\test\SalesTax.java. import java.util.*;import java.text.*;public class SalesTax{ private double tax = 0.0; private double price = 0.0; private

Example - SalesTax.java, salestax.php, salestax.htm

C:\Program Files\Apache Group\Apache2\htdocs\test\SalesTax.java.

import java.util.*;
import java.text.*;

public class SalesTax
{

    private double tax = 0.0;
    private double price = 0.0;
    private double salesTax = 0.0;

    public SalesTax()
    {}

    public String SalesTax(double price, double salesTax)
    {
        tax = price * salesTax;

        NumberFormat nf = null;

        nf = NumberFormat.getCurrencyInstance();

        String priceOut = nf.format(price);
        String taxOut = nf.format(tax);

        nf = NumberFormat.getPercentInstance();
        String salesTaxOut = nf.format(salesTax);

        String str = "Sales Tax of " + salesTaxOut +
            " on " + priceOut + " equals " + taxOut + ".";

        return str;
    }
}
登入後複製

C:\Program Files\Apache Group\Apache2\htdocs\test\salestax.php

<?php if (isset($_POST["submit"]))
{
	java_require('http://localhost/test/SalesTax.jar');

	$salesTax = new Java("SalesTax");

	$price = (double) $_POST["price"];
	$tax = (double) $_POST["tax"];

	echo (String) $salesTax->SalesTax($price, $tax);
}

?>
登入後複製

C:\Program Files\Apache Group\Apache2\htdocs\test\salestax.htm.


<title></title>



登入後複製
Price: ($)

Tax Rate: (0.1 for 10%)

PHP 5, PHP/Java Bridge & Apache on XP PRO + SP2 and

PHP 5, PHP/Java Bridge & Apache on XP PRO + SP2 and

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!