PayCheck - double hours, rate, pay; int again; do {...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // PayCheck.java // // Demonstrates the use of the JOptionPane class. //******************************************************************** import javax.swing.JOptionPane; class PayCheck { //----------------------------------------------------------------- // Finds and displays the gross pay for an hourly worker // Uses multiple dialog boxes for user interaction. //----------------------------------------------------------------- public static void main (String[] args) { String hoursStr, rateStr, result;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: double hours, rate, pay; int again; do { hoursStr = JOptionPane.showInputDialog ("Enter hours worked: "); hours = Double.parseDouble(hoursStr); rateStr = JOptionPane.showInputDialog ("Enter hourly rate: "); rate = Double.parseDouble(rateStr); if (hours > 40) pay = 40 * rate + (hours-40) * rate * 1.5; else pay = hours * rate; result = "Gross pay is " + pay; JOptionPane.showMessageDialog (null, result); again = JOptionPane.showConfirmDialog (null, "Do Another?"); } while (again == JOptionPane.YES_OPTION); } }...
View Full Document

Ask a homework question - tutors are online