import javax.swing.*;
public class Tester
{
public static void main(String[]args)
{
String returnValue = "";
String prompt;
String title;
int msgTypeQ = JOptionPane.QUESTION_MESSAGE;
float oldAnnualSalary = 0.0f; // Current annual salary
// .01 - 1000000.00
float newAnnualSalary = 0.0f; // New annual salary
// .01 - 2000000.00
float percentIncrease = 0.0f; // Percent increase as whole
// percent
// ex 10.5, 1, .03, 100
// Prompt and get annual salary
prompt = "Enter your annual salary";
title = "Attention";
returnValue = JOptionPane.showInputDialog(null, prompt, title, msgTypeQ);
// Salary was entered - convert to float
if ( !returnValue.equals("") )
{
oldAnnualSalary = Float.parseFloat(returnValue);
}
// Prompt and get percentage increase
prompt = "Enter percent increase (0 - 100) ex 10.5 for 10.5% : ";
returnValue = JOptionPane.showInputDialog(null, prompt, title, msgTypeQ);
// Percentage increase was entered - convert to float
if ( !returnValue.equals("") )
{
percentIncrease = Float.parseFloat(returnValue);
}
// oldAnnualSalary is not from .01 to 1000000.00
if ( oldAnnualSalary < 0.01 || oldAnnualSalary > 1000000.00 )
{
System.out.println("Salary entered was not from 0.01 to 1000000.00.");
}
// precentIncrease is not 0.0 - 100.0
if ( percentIncrease < 0.01 || percentIncrease > 100.00 )
{
System.out.println("Percent increase is not .01 to 100.");
}
// oldAnnualSalary is from .01 to 1000000.00
// and percentIncrease is not 0
if ( oldAnnualSalary >= 0.01 && oldAnnualSalary <= 1000000.00
&& percentIncrease != 0.0)
{
// Compute new salary
newAnnualSalary = oldAnnualSalary *
(1 + percentIncrease / 100); // Convert whole
// percent to
// decimal
// and add one.
// Multiply by
// old salary
// Display salary change report
System.out.println("Your old salary is " + oldAnnualSalary);
System.out.println("Percent increase is " + percentIncrease);
System.out.println("Your new salary is " + newAnnualSalary);
}
// No change in salary
if ( newAnnualSalary == 0.00 )
{
// Display unchanged salary report
System.out.println("Your salary was unchanged");
}
}
}