Hello I need help for this assignment: The assignment we will actually create a
ID: 3774256 • Letter: H
Question
Hello I need help for this assignment:
The assignment we will actually create a Windows Presentation Foundation (WPF) form.
The form should contain a text field to enter the amount of the meal. A list of checkboxes with Tip choices 10%, 15%, 20% and other. There should be a textbox for other.
The user will click a button to calculate the tip, and the total. In the code we will make a tax amount of .09 a constant. After the button is clicked the form will display the amount, the tip, the tax and the total.
Create a Class called "Bill." that has fields for Tip Percent and Amount and which has methods to calculate the Tip, Tax, and total.
To turn in:
Upload the code for the WPF Form and the bill class. Alternatively, upload all to GitHub and provide a link to the repository.
Explanation / Answer
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapp;
import javax.swing.JOptionPane;
/**
This program demonstrates using dialogs with
JOptionPane.
*/
public class Bill
{
public static void main(String[] args)
{
inputString; //For reader's input
int total; // The user's total bill.
int taxAmount; //10% of the user's total bill
int totalMeal; //Bill after tax has been added
int tip; // 10,15,20 and ur wish percent of the totalMeal
int overall; // The total including tax and tip
// Get the user's total bill.
inputString =
JOptionPane.showInputDialog("What is " +
"the total bill? ");
//Convert the input to an int.
total = Integer.parseInt(inputString);
// Calculate the tax amount.
taxAmount = 10/100 * total;
// Calculate the total meal after tax has been added.
totalMeal = taxAmount + total
//Calculate the tip
tip = 15/100 * totalMeal
// Calculate the entire bill.
overall = totalMeal + tip;
System.out.println("The taxed amount is" + taxAmount);
System.out.println("The tip amount is" + tipAmount);
System.out.println("The total bill is" + overall)
System.exit(0);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.