Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-06 19:46:56
Original
1092 people have browsed it

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;
    }
}
Copy after login

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);
}

?>
Copy after login

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


<title></title>



Copy after login
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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!