Any way to better structure many if else statements in Java -


here code have tax program.is there better way structure if else statements , there better way write program. apologize before hand not having comments.

    package joptionpane;      import javax.swing.joptionpane;      public class main {      public static void main(string[] args)     {         double paycheck = double.parsedouble(joptionpane.showinputdialog("how paycheck?"));         string[] options = new string[] {"yes", "no"};         int response = joptionpane.showoptiondialog(null, "are married?", "title",             joptionpane.default_option, joptionpane.plain_message,             null, options, options[0]);         double deductions = integer.parseint(joptionpane.showinputdialog("how many deductions did claim?"));         string[] payoften = new string[] {"weekly", "biweekly"};         int variability = joptionpane.showoptiondialog(null, "how paid?", "title",             joptionpane.default_option, joptionpane.plain_message,             null, payoften, payoften[0]);         double ss = 0;          if (response == 0)         {             if (variability == 0)             {                  if(paycheck <= 490)                  {                      ss = (paycheck - (deductions*73.08)) * .1;                  }                   else if (paycheck <= 1515)                  {                      ss = (paycheck - (deductions*73.08)) * .15 + 33.4;                  }                  else                  {                      system.out.println("i lazy compute");                  }             }             else              {                 if(paycheck <= 981)                 {                     ss = (paycheck - (deductions * 146.15)) * .1;                 }                 else if (paycheck <= 3031)                 {                     ss = (paycheck - (deductions * 146.15)) * .15 + 66.9;                 }                 else                  {                     system.out.println("i lazy compute");                 }             }         }         else         {             if (variability == 0)             {                 if(paycheck <= 209)                 {                     ss = (paycheck - (deductions * 73.08)) * .1;                 }                 else if (paycheck <= 721)                 {                     ss = (paycheck -(deductions * 73.08)) * .15 + 16.8;                 }                 else                 {                     system.out.println("i lazy compute.");                 }             }             else             {                 if(paycheck <= 417)                 {                     ss = (paycheck - (deductions * 146.15)) * .1;                 }                 else if (paycheck <= 1442)                 {                     ss = (paycheck - (deductions * 146.15)) * .15 + 33.4;                 }                 else                  {                     system.out.println("i lzy compute.");                 }             }         }         system.out.println("you owe " + ss + " social security");      }  } 

in real system these amounts , rates , thresholds in database table, , processing payment matter of applying simple arithmetic formula involving values taken applicable row(s). have think restructuring whole thing along lines.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -