Take multiple inputs from single edit text and add those values?












0












$begingroup$


I am creating a CGPA calculator and i need to take multiple inputs from single edit text. I needed up to add a whole quality point table for six subjects. This thing is itching me as multiple if conditions are very confusing. As the table points are based on credit hours.



b is showing credit hours
w is showing the marks obtained and their according quality grade points.



if (b == 2) {



                    String M1 = etM1.getText ().toString ();
w = Integer.parseInt (M1);

if (w == 16) {
w = Float.parseFloat (String.valueOf (2));
} else if (w == 17) {
w = Float.parseFloat (String.valueOf (2.5));
} else if (w == 18) {
w = Float.parseFloat (String.valueOf (3));
} else if (w == 19) {
w = Float.parseFloat (String.valueOf (3.5));
} else if (w == 20) {
w = Float.parseFloat (String.valueOf (4));
} else if (w == 21) {
w = Float.parseFloat (String.valueOf (4.33));
} else if (w == 22) {
w = Float.parseFloat (String.valueOf (4.67));
} else if (w == 23) {
w = Float.parseFloat (String.valueOf (5));
} else if (w == 24) {
w = Float.parseFloat (String.valueOf (5.33));
} else if (w == 25) {
w = Float.parseFloat (String.valueOf (5.67));
} else if (w == 26) {
w = Float.parseFloat (String.valueOf (6));
} else if (w == 27) {
w = Float.parseFloat (String.valueOf (6.33));
} else if (w == 28) {
w = Float.parseFloat (String.valueOf (6.67));
} else if (w == 29) {
w = Float.parseFloat (String.valueOf (7));
} else if (w == 30) {
w = Float.parseFloat (String.valueOf (7.33));
} else if (w == 31) {
w = Float.parseFloat (String.valueOf (7.67));
} else if (w == 32 || w <= 40) {
w = Float.parseFloat (String.valueOf (8));
}

} else if (b == 3) {
String M1 = etM1.getText ().toString ();
w = Integer.parseInt (M1);

if (w == 24) {
w = Float.parseFloat (String.valueOf (3));
} else if (w == 25) {
w = Float.parseFloat (String.valueOf (3.5));
} else if (w == 26) {
w = Float.parseFloat (String.valueOf (4));
} else if (w == 27) {
w = Float.parseFloat (String.valueOf (4.5));
} else if (w == 28) {
w = Float.parseFloat (String.valueOf (5));
} else if (w == 29) {
w = Float.parseFloat (String.valueOf (5.5));
} else if (w == 30) {
w = Float.parseFloat (String.valueOf (6));
} else if (w == 31) {
w = Float.parseFloat (String.valueOf (6.33));
} else if (w == 32) {
w = Float.parseFloat (String.valueOf (6.67));
} else if (w == 33) {
w = Float.parseFloat (String.valueOf (7));
} else if (w == 34) {
w = Float.parseFloat (String.valueOf (7.33));
} else if (w == 35) {
w = Float.parseFloat (String.valueOf (7.67));
} else if (w == 36) {
w = Float.parseFloat (String.valueOf (8));
} else if (w == 37) {
w = Float.parseFloat (String.valueOf (8.33));
} else if (w == 38) {
w = Float.parseFloat (String.valueOf (8.67));
} else if (w == 39) {
w = Float.parseFloat (String.valueOf (9));
} else if (w == 40) {
w = Float.parseFloat (String.valueOf (9.33));
} else if (w == 41) {
w = Float.parseFloat (String.valueOf (9.67));
} else if (w == 42) {
w = Float.parseFloat (String.valueOf (10));
} else if (w == 43) {
w = Float.parseFloat (String.valueOf (10.33));
} else if (w == 44) {
w = Float.parseFloat (String.valueOf (10.67));
} else if (w == 45) {
w = Float.parseFloat (String.valueOf (11));
} else if (w == 46) {
w = Float.parseFloat (String.valueOf (11.33));
} else if (w == 47) {
w = Float.parseFloat (String.valueOf (11.67));
} else if (w == 48 || w <= 60) {
w = Float.parseFloat (String.valueOf (12));
}
}`









share|improve this question







New contributor




Asad Ur Rehman Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$

















    0












    $begingroup$


    I am creating a CGPA calculator and i need to take multiple inputs from single edit text. I needed up to add a whole quality point table for six subjects. This thing is itching me as multiple if conditions are very confusing. As the table points are based on credit hours.



    b is showing credit hours
    w is showing the marks obtained and their according quality grade points.



    if (b == 2) {



                        String M1 = etM1.getText ().toString ();
    w = Integer.parseInt (M1);

    if (w == 16) {
    w = Float.parseFloat (String.valueOf (2));
    } else if (w == 17) {
    w = Float.parseFloat (String.valueOf (2.5));
    } else if (w == 18) {
    w = Float.parseFloat (String.valueOf (3));
    } else if (w == 19) {
    w = Float.parseFloat (String.valueOf (3.5));
    } else if (w == 20) {
    w = Float.parseFloat (String.valueOf (4));
    } else if (w == 21) {
    w = Float.parseFloat (String.valueOf (4.33));
    } else if (w == 22) {
    w = Float.parseFloat (String.valueOf (4.67));
    } else if (w == 23) {
    w = Float.parseFloat (String.valueOf (5));
    } else if (w == 24) {
    w = Float.parseFloat (String.valueOf (5.33));
    } else if (w == 25) {
    w = Float.parseFloat (String.valueOf (5.67));
    } else if (w == 26) {
    w = Float.parseFloat (String.valueOf (6));
    } else if (w == 27) {
    w = Float.parseFloat (String.valueOf (6.33));
    } else if (w == 28) {
    w = Float.parseFloat (String.valueOf (6.67));
    } else if (w == 29) {
    w = Float.parseFloat (String.valueOf (7));
    } else if (w == 30) {
    w = Float.parseFloat (String.valueOf (7.33));
    } else if (w == 31) {
    w = Float.parseFloat (String.valueOf (7.67));
    } else if (w == 32 || w <= 40) {
    w = Float.parseFloat (String.valueOf (8));
    }

    } else if (b == 3) {
    String M1 = etM1.getText ().toString ();
    w = Integer.parseInt (M1);

    if (w == 24) {
    w = Float.parseFloat (String.valueOf (3));
    } else if (w == 25) {
    w = Float.parseFloat (String.valueOf (3.5));
    } else if (w == 26) {
    w = Float.parseFloat (String.valueOf (4));
    } else if (w == 27) {
    w = Float.parseFloat (String.valueOf (4.5));
    } else if (w == 28) {
    w = Float.parseFloat (String.valueOf (5));
    } else if (w == 29) {
    w = Float.parseFloat (String.valueOf (5.5));
    } else if (w == 30) {
    w = Float.parseFloat (String.valueOf (6));
    } else if (w == 31) {
    w = Float.parseFloat (String.valueOf (6.33));
    } else if (w == 32) {
    w = Float.parseFloat (String.valueOf (6.67));
    } else if (w == 33) {
    w = Float.parseFloat (String.valueOf (7));
    } else if (w == 34) {
    w = Float.parseFloat (String.valueOf (7.33));
    } else if (w == 35) {
    w = Float.parseFloat (String.valueOf (7.67));
    } else if (w == 36) {
    w = Float.parseFloat (String.valueOf (8));
    } else if (w == 37) {
    w = Float.parseFloat (String.valueOf (8.33));
    } else if (w == 38) {
    w = Float.parseFloat (String.valueOf (8.67));
    } else if (w == 39) {
    w = Float.parseFloat (String.valueOf (9));
    } else if (w == 40) {
    w = Float.parseFloat (String.valueOf (9.33));
    } else if (w == 41) {
    w = Float.parseFloat (String.valueOf (9.67));
    } else if (w == 42) {
    w = Float.parseFloat (String.valueOf (10));
    } else if (w == 43) {
    w = Float.parseFloat (String.valueOf (10.33));
    } else if (w == 44) {
    w = Float.parseFloat (String.valueOf (10.67));
    } else if (w == 45) {
    w = Float.parseFloat (String.valueOf (11));
    } else if (w == 46) {
    w = Float.parseFloat (String.valueOf (11.33));
    } else if (w == 47) {
    w = Float.parseFloat (String.valueOf (11.67));
    } else if (w == 48 || w <= 60) {
    w = Float.parseFloat (String.valueOf (12));
    }
    }`









    share|improve this question







    New contributor




    Asad Ur Rehman Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$















      0












      0








      0


      0



      $begingroup$


      I am creating a CGPA calculator and i need to take multiple inputs from single edit text. I needed up to add a whole quality point table for six subjects. This thing is itching me as multiple if conditions are very confusing. As the table points are based on credit hours.



      b is showing credit hours
      w is showing the marks obtained and their according quality grade points.



      if (b == 2) {



                          String M1 = etM1.getText ().toString ();
      w = Integer.parseInt (M1);

      if (w == 16) {
      w = Float.parseFloat (String.valueOf (2));
      } else if (w == 17) {
      w = Float.parseFloat (String.valueOf (2.5));
      } else if (w == 18) {
      w = Float.parseFloat (String.valueOf (3));
      } else if (w == 19) {
      w = Float.parseFloat (String.valueOf (3.5));
      } else if (w == 20) {
      w = Float.parseFloat (String.valueOf (4));
      } else if (w == 21) {
      w = Float.parseFloat (String.valueOf (4.33));
      } else if (w == 22) {
      w = Float.parseFloat (String.valueOf (4.67));
      } else if (w == 23) {
      w = Float.parseFloat (String.valueOf (5));
      } else if (w == 24) {
      w = Float.parseFloat (String.valueOf (5.33));
      } else if (w == 25) {
      w = Float.parseFloat (String.valueOf (5.67));
      } else if (w == 26) {
      w = Float.parseFloat (String.valueOf (6));
      } else if (w == 27) {
      w = Float.parseFloat (String.valueOf (6.33));
      } else if (w == 28) {
      w = Float.parseFloat (String.valueOf (6.67));
      } else if (w == 29) {
      w = Float.parseFloat (String.valueOf (7));
      } else if (w == 30) {
      w = Float.parseFloat (String.valueOf (7.33));
      } else if (w == 31) {
      w = Float.parseFloat (String.valueOf (7.67));
      } else if (w == 32 || w <= 40) {
      w = Float.parseFloat (String.valueOf (8));
      }

      } else if (b == 3) {
      String M1 = etM1.getText ().toString ();
      w = Integer.parseInt (M1);

      if (w == 24) {
      w = Float.parseFloat (String.valueOf (3));
      } else if (w == 25) {
      w = Float.parseFloat (String.valueOf (3.5));
      } else if (w == 26) {
      w = Float.parseFloat (String.valueOf (4));
      } else if (w == 27) {
      w = Float.parseFloat (String.valueOf (4.5));
      } else if (w == 28) {
      w = Float.parseFloat (String.valueOf (5));
      } else if (w == 29) {
      w = Float.parseFloat (String.valueOf (5.5));
      } else if (w == 30) {
      w = Float.parseFloat (String.valueOf (6));
      } else if (w == 31) {
      w = Float.parseFloat (String.valueOf (6.33));
      } else if (w == 32) {
      w = Float.parseFloat (String.valueOf (6.67));
      } else if (w == 33) {
      w = Float.parseFloat (String.valueOf (7));
      } else if (w == 34) {
      w = Float.parseFloat (String.valueOf (7.33));
      } else if (w == 35) {
      w = Float.parseFloat (String.valueOf (7.67));
      } else if (w == 36) {
      w = Float.parseFloat (String.valueOf (8));
      } else if (w == 37) {
      w = Float.parseFloat (String.valueOf (8.33));
      } else if (w == 38) {
      w = Float.parseFloat (String.valueOf (8.67));
      } else if (w == 39) {
      w = Float.parseFloat (String.valueOf (9));
      } else if (w == 40) {
      w = Float.parseFloat (String.valueOf (9.33));
      } else if (w == 41) {
      w = Float.parseFloat (String.valueOf (9.67));
      } else if (w == 42) {
      w = Float.parseFloat (String.valueOf (10));
      } else if (w == 43) {
      w = Float.parseFloat (String.valueOf (10.33));
      } else if (w == 44) {
      w = Float.parseFloat (String.valueOf (10.67));
      } else if (w == 45) {
      w = Float.parseFloat (String.valueOf (11));
      } else if (w == 46) {
      w = Float.parseFloat (String.valueOf (11.33));
      } else if (w == 47) {
      w = Float.parseFloat (String.valueOf (11.67));
      } else if (w == 48 || w <= 60) {
      w = Float.parseFloat (String.valueOf (12));
      }
      }`









      share|improve this question







      New contributor




      Asad Ur Rehman Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      I am creating a CGPA calculator and i need to take multiple inputs from single edit text. I needed up to add a whole quality point table for six subjects. This thing is itching me as multiple if conditions are very confusing. As the table points are based on credit hours.



      b is showing credit hours
      w is showing the marks obtained and their according quality grade points.



      if (b == 2) {



                          String M1 = etM1.getText ().toString ();
      w = Integer.parseInt (M1);

      if (w == 16) {
      w = Float.parseFloat (String.valueOf (2));
      } else if (w == 17) {
      w = Float.parseFloat (String.valueOf (2.5));
      } else if (w == 18) {
      w = Float.parseFloat (String.valueOf (3));
      } else if (w == 19) {
      w = Float.parseFloat (String.valueOf (3.5));
      } else if (w == 20) {
      w = Float.parseFloat (String.valueOf (4));
      } else if (w == 21) {
      w = Float.parseFloat (String.valueOf (4.33));
      } else if (w == 22) {
      w = Float.parseFloat (String.valueOf (4.67));
      } else if (w == 23) {
      w = Float.parseFloat (String.valueOf (5));
      } else if (w == 24) {
      w = Float.parseFloat (String.valueOf (5.33));
      } else if (w == 25) {
      w = Float.parseFloat (String.valueOf (5.67));
      } else if (w == 26) {
      w = Float.parseFloat (String.valueOf (6));
      } else if (w == 27) {
      w = Float.parseFloat (String.valueOf (6.33));
      } else if (w == 28) {
      w = Float.parseFloat (String.valueOf (6.67));
      } else if (w == 29) {
      w = Float.parseFloat (String.valueOf (7));
      } else if (w == 30) {
      w = Float.parseFloat (String.valueOf (7.33));
      } else if (w == 31) {
      w = Float.parseFloat (String.valueOf (7.67));
      } else if (w == 32 || w <= 40) {
      w = Float.parseFloat (String.valueOf (8));
      }

      } else if (b == 3) {
      String M1 = etM1.getText ().toString ();
      w = Integer.parseInt (M1);

      if (w == 24) {
      w = Float.parseFloat (String.valueOf (3));
      } else if (w == 25) {
      w = Float.parseFloat (String.valueOf (3.5));
      } else if (w == 26) {
      w = Float.parseFloat (String.valueOf (4));
      } else if (w == 27) {
      w = Float.parseFloat (String.valueOf (4.5));
      } else if (w == 28) {
      w = Float.parseFloat (String.valueOf (5));
      } else if (w == 29) {
      w = Float.parseFloat (String.valueOf (5.5));
      } else if (w == 30) {
      w = Float.parseFloat (String.valueOf (6));
      } else if (w == 31) {
      w = Float.parseFloat (String.valueOf (6.33));
      } else if (w == 32) {
      w = Float.parseFloat (String.valueOf (6.67));
      } else if (w == 33) {
      w = Float.parseFloat (String.valueOf (7));
      } else if (w == 34) {
      w = Float.parseFloat (String.valueOf (7.33));
      } else if (w == 35) {
      w = Float.parseFloat (String.valueOf (7.67));
      } else if (w == 36) {
      w = Float.parseFloat (String.valueOf (8));
      } else if (w == 37) {
      w = Float.parseFloat (String.valueOf (8.33));
      } else if (w == 38) {
      w = Float.parseFloat (String.valueOf (8.67));
      } else if (w == 39) {
      w = Float.parseFloat (String.valueOf (9));
      } else if (w == 40) {
      w = Float.parseFloat (String.valueOf (9.33));
      } else if (w == 41) {
      w = Float.parseFloat (String.valueOf (9.67));
      } else if (w == 42) {
      w = Float.parseFloat (String.valueOf (10));
      } else if (w == 43) {
      w = Float.parseFloat (String.valueOf (10.33));
      } else if (w == 44) {
      w = Float.parseFloat (String.valueOf (10.67));
      } else if (w == 45) {
      w = Float.parseFloat (String.valueOf (11));
      } else if (w == 46) {
      w = Float.parseFloat (String.valueOf (11.33));
      } else if (w == 47) {
      w = Float.parseFloat (String.valueOf (11.67));
      } else if (w == 48 || w <= 60) {
      w = Float.parseFloat (String.valueOf (12));
      }
      }`






      android






      share|improve this question







      New contributor




      Asad Ur Rehman Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Asad Ur Rehman Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Asad Ur Rehman Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 25 mins ago









      Asad Ur Rehman KhanAsad Ur Rehman Khan

      11




      11




      New contributor




      Asad Ur Rehman Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Asad Ur Rehman Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Asad Ur Rehman Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Asad Ur Rehman Khan is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214294%2ftake-multiple-inputs-from-single-edit-text-and-add-those-values%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Asad Ur Rehman Khan is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Asad Ur Rehman Khan is a new contributor. Be nice, and check out our Code of Conduct.













          Asad Ur Rehman Khan is a new contributor. Be nice, and check out our Code of Conduct.












          Asad Ur Rehman Khan is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214294%2ftake-multiple-inputs-from-single-edit-text-and-add-those-values%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Сан-Квентин

          Алькесар

          Josef Freinademetz