Jump to content

Project 2


Ste

Recommended Posts

Ok Nvm fiurd it out, heres the completed code

 

 

 

/*

Steven Borchard

Project 2

*/

import javax.swing.JOptionPane;

import java.text.*;

public class TrivialApplication {

 

public static void main(String args[]) {

NumberFormat formatter=

NumberFormat.getNumberInstance();

formatter.setMaximumFractionDigits(2);

formatter.setMinimumFractionDigits(2);

//Asks for User Input

String hours= JOptionPane.showInputDialog

(" Pay System\nPlease Enter Number of Hours Worked");

String dependent= JOptionPane.showInputDialog

("Please Enter Number of Dependents");

//Parsing Input

double ho= Double.parseDouble(hours);

int de= Integer.parseInt(dependent);

//Variables Created

double grosspay= 16.78*ho;

int union= 10;

int health= 35;

double overpay= (ho - 40)*(16.78*1.5)+(40*16.78);

//Equations

double social= grosspay * .06;

double fedtax= grosspay * .14;

double statetax= grosspay * .05;

double takehome= grosspay - social - fedtax - statetax - union;

double social1= overpay * .06;

double fedtax1= overpay * .14;

double statetax1= overpay * .05;

double takehome2= overpay - social1 - fedtax1 - statetax1 - union;

//outputs result

if(de>=3)

if(ho>40)

JOptionPane.showMessageDialog(null," Gross Pay $"

+ formatter.format(overpay) +"\nSocial Secruity $"

+ formatter.format(social1) +"\nFederal Income "+ formatter.format(fedtax1)

+"\nState Income $" + formatter.format(statetax1)

+"\nUnion Dues $" + formatter.format(union)

+ "\nHealth Insurance $" + formatter.format(health) +"\n\nNet Take Home "

+ formatter.format(takehome2-35) +"$");

 

 

else if(de>=3)

JOptionPane.showMessageDialog(null," Gross Pay $"

+ formatter.format(grosspay) +"\nSocial Secruity $"

+ formatter.format(social) +"\nFederal Income "+ formatter.format(fedtax)

+"\nState Income $" + formatter.format(statetax)

+"\nUnion Dues $" + formatter.format(union)

+ "\nHealth Insurance $" + formatter.format(health) +"\n\nNet Take Home "

+ formatter.format(takehome-35) +"$");

 

else if(ho>40)

JOptionPane.showMessageDialog(null," Gross Pay $"

+ formatter.format(overpay) +"\nSocial Secruity $"

+ formatter.format(social1) +"\nFederal Income "+ formatter.format(fedtax1)

+"\nState Income $" + formatter.format(statetax1)

+"\nUnion Dues $" + formatter.format(union)

+ "\nHealth Insurance $" +"\n\nNet Take Home "

+ formatter.format(takehome2) +"$");

 

else

JOptionPane.showMessageDialog(null,(" Gross Pay $"

+ formatter.format(grosspay) +"\nSocial Secruity $"

+ formatter.format(social) +"\nFederal Income $"+ formatter.format(fedtax)

+"\nState Income $" + formatter.format(statetax)

+"\nUnion Dues$ " + formatter.format(union)

+ "$\n\nNet Take Home "

+ formatter.format(takehome) +"$"));

 

}

}

Edited by Ste

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...