I get a tip of $8.0 when I want $8.4. What am I missing here?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Tip extends JFrame
implements ActionListener {
private JButton button;
public static void main(String[] args) {
Tip frame = new Tip();
frame.setSize(400, 300);
frame.createGUI();
frame.setVisible(true);
}
private void createGUI() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container window = getContentPane();
window.setLayout(new FlowLayout() );
button = new JButton("Compute Tip");
window.add(button);
button.addActionListener(this);
}
public void actionPerformed(ActionEvent event) {
int amount, percentage;
double tip;
String occupationString;
String amountString;
String percentageString;
occupationString = JOptionPane.showInputDialog("Person Occupation: ");
amountString = JOptionPane.showInputDialog("Amount of the Bill: ");
amount = Integer.parseInt(amountString);
percentageString = JOptionPane.showInputDialog("Percentage tip: ");
percentage = Integer.parseInt(percentageString);
tip = (amount * percentage) / 100;
JOptionPane.showMessageDialog(null, "Tip the " + occupationString + " " + "$" + tip);
}
}