Hi there! Im new to Java and I'm also new to these forums. And hopefully i can get some advice to point me in the right direction.
My assignment was to make a program that calculates and writes a persons taxes, based on their income.
If the income were less then (or the same) as 8900. 0 would be payed in taxes.
If the income were more than 8900 but less than 198700. 100 would be payed in taxes.
If the income were more than (or the same) as 198700. 100 + 20% of the income above 198700 would be payed in taxes.
And also, before the program shuts down it should ask me if i want to calculate some more.
So i have it almost done. It's just something that is missing, and i just can't figure it out. Maybe u guys can help me out a bit. Here's the code i've written so far:
import javax.swing.*; public class Test { public static void main (String[] arg) { int knappNr; do{ String tax = JOptionPane.showInputDialog ("Write your income"); double pay = Double.parseDouble (pay); if (pay <=8900) pay = 0; else if (pay >=198700) pay = pay - 198700; pay = pay * 0.20 + 100; else pay = 100; JOptionPane.showMessageDialog (null, "Your tax to pay is " + pay+" dollar"); knappNr = JOptionPane.showConfirmDialog (null, "Do you want to make another calculate?", "Question", JOptionPane.YES_NO_OPTION); } while (knappNr == 0); } }
Thank you in advance.