Tip, Tax, and Total Problem: Create a JavaFX application that lets the user ente
ID: 3888014 • Letter: T
Question
Tip, Tax, and Total Problem:
Create a JavaFX application that lets the user enter the food charge for a meal at a restaurant. When a button is clicked, the application should calculate and display the amount of an 18 percent tip, 7 percent sales tax, and the total of all three amounts.
I need an html file with this, I don't know how to go about doing that. This is what I have for the program and it works just fine, I just don't know how to make the html file or incorporate it into my java file. Can someone help me?
------------------------------------------------------------------------------------------------------
package WordNode;
import java.awt.Button;
import java.util.Scanner;
public class TipTaxTotal {
public static void main(String [] args)
{
double charge;
double tax = 0.07;
double tipRate = 0.18;
double totalWithTax;
double taxAmount;
double tipAmount;
double grandTotal;
Scanner keyboard = new Scanner(System.in);
//ask for charge from the user
System.out.println("What is the charge for your meal?");
charge = keyboard.nextDouble();
//calculate the charge and the tip
taxAmount = charge * tax;
totalWithTax = charge + taxAmount;
tipAmount = totalWithTax * tipRate;
grandTotal = totalWithTax + tipAmount;
//Display it back to the user
System.out.println("meal: $" + charge);
System.out.println("tax: $" + taxAmount);
System.out.println("meal + tax: $" + totalWithTax);
System.out.println("total cost(tip included): $" + grandTotal);
}
}
Please someone explain the html file...like exactly what I need to put because I am thoroughly confused.
Explanation / Answer
Below is the HTML code needed for the program
<form id="someIdYouMustGive" action="your method details">
<div class="col-md-2 form-group">
<label class="control-label">Food Charge:</label> <input
type="text" class="form-control"
placeholder="Enter The Charge" autocomplete="off"
name="foodCharge" id="foodCharge">
</div>
<div class="col-md-2 form-group">
<label class="control-label">Tip:</label> <input
type="text" class="form-control">
</div>
<div class="col-md-2 form-group">
<label class="control-label">Sales Tax:</label> <input
type="text" class="form-control">
</div>
<div class="col-md-2 form-group">
<label class="control-label">Total Amount:</label> <input
type="text" class="form-control">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-success"
id="submit">
<i class="fa fa-save"></i> Save
</button>
</div>
</form>
Explanation:
Starting I have given the form tag and in that form tag I have given the method details in action attribute and the form tag is ended in the last.In between <form> start tag and </form> end tag, I have given the labels and input field for all the three fields. I have given like which you askeed as food charge,tip,sales tax and total of all the three after entering the values like food charge you can get the calculation of all those which you asked and the calculation part written by you.This is for web page design for the sheet which you asked in HTML code.
Now how to connect to java:
You can incorporate in java by setting path like :
In this way the screen and incorporating in java.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.