I'm trying to write a program that asks the user two numbers - the 1st number is the income, the 2nd is the tax class (either 1 or 2).
If the tax class is 1, the program will divide the income by 10, if the tax class is 2, it will divide by 15. So if a user puts in "8000" as his income and "2" as his tax class, there will be a plain message saying "You're paying 4000 in taxes" (taxes=8000/15).
I have no idea how to even start on this. I'm able to write a simple program that asks a user to type in his name, then shows a "Hello <NAME>!" message... but not this. Can someone please help me, give me a push in the right direction? It would be so much appreciated.
this is what I've got so far - I can't even get the if/else thing to work. I've only done this for a couple of weeks >.<
If the tax class is 1, the program will divide the income by 10, if the tax class is 2, it will divide by 15. So if a user puts in "8000" as his income and "2" as his tax class, there will be a plain message saying "You're paying 4000 in taxes" (taxes=8000/15).
I have no idea how to even start on this. I'm able to write a simple program that asks a user to type in his name, then shows a "Hello <NAME>!" message... but not this. Can someone please help me, give me a push in the right direction? It would be so much appreciated.
this is what I've got so far - I can't even get the if/else thing to work. I've only done this for a couple of weeks >.<
Code:
public class eks_sett02_oppg4a { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int k=1; int j=2; String s=javax.swing.JOptionPane.showInputDialog("Tast inn din inntekt"); System.out.println(s); String t=javax.swing.JOptionPane.showInputDialog("Tast inn din skatteklasse"); System.out.println(t); if (t==k){ System.out.println("bleh"); } else if (t==j){ System.out.println("bah"); } } }
Comment