Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Need Assistance in coding error in java program running on Android

Denpeter0229Denpeter0229 Kota Kinabalu Sabah MalaysiaMember Posts: 1

I'm having issues in creating a program using Android Studio.I'm trying to create a program that calculate CGPA and GPA ,tut i get a little coding errors. Any assistance would be appreciated.

    public void getEditTextGPA() {
    String str = ((EditText) findViewById(R.id.GPAEditText)).getText().toString();
      if (str.trim().equalsIgnoreCase(".")) {
      showAlertMessage("Error", ". is not a valid number");
      this.errorMessageDisplayed = true;
      }
      while (true) {
      if (this.userInputGPA > 4.00D) {
      showAlertMessage("ERROR: CGPA Input", "You cannot have CGPA of over   4.00.");
      this.errorMessageDisplayed = true;
      }
      return;
      if (str.trim().matches("")) {
      this.userInputGPA = -1.0F;
      continue;
      }
      this.userInputGPA = Float.parseFloat(str);
      }

Error at this.userInputGPA=-1.0F; as unreachable statement

public void getGPAValueForGrade(String paramString, int paramInt) {
      String[] arrayOfString = {"A", "A-", "B+", "B", "B-", "C+", "C", "C-",   "D+", "D", "E", "Grade"};
      int i = 0;
      if (i >= 12)
      return;
      String str = arrayOfString[i];
      if (paramString.trim().equalsIgnoreCase(str))
      switch (i) {
        default:
        case 0:
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
        case 10:
        case 11:
      }
      while (true) {
      i++;
      break;
      this.GPAValueArray[paramInt] = 4.0F;
      continue;
      this.GPAValueArray[paramInt] = 3.67F;
      continue;
      this.GPAValueArray[paramInt] = 3.33F;
      continue;
      this.GPAValueArray[paramInt] = 3.0F;
      continue;
      this.GPAValueArray[paramInt] = 2.67F;
      continue;
      this.GPAValueArray[paramInt] = 2.33F;
      continue;
      this.GPAValueArray[paramInt] = 2.0F;
      continue;
      this.GPAValueArray[paramInt] = 1.67F;
      continue;
      this.GPAValueArray[paramInt] = 1.33F;
      continue;
      this.GPAValueArray[paramInt] = 1.0F;
      continue;
      this.GPAValueArray[paramInt] = 0.0F;
      continue;
      }
      }

Error at the 1st continue; as unreachable statement

 public void getTotalGPAValueFromSpinnerFloat() {
      getGPAValueForGrade(this.gpaSpinnerOne.getSelectedItem().toString(), 0);
      int i = 0 + 1;
      getGPAValueForGrade(this.gpaSpinnerTwo.getSelectedItem().toString(), i);
      int j = i + 1;
      getGPAValueForGrade(this.gpaSpinnerThree.getSelectedItem().toString(), j);
      int k = j + 1;
      getGPAValueForGrade(this.gpaSpinnerFour.getSelectedItem().toString(), k);
      int m = k + 1;
      getGPAValueForGrade(this.gpaSpinnerFive.getSelectedItem().toString(), m);
      int n = m + 1;
      getGPAValueForGrade(this.gpaSpinnerSix.getSelectedItem().toString(), n);
      int i1 = n + 1;
      getGPAValueForGrade(this.gpaSpinnerSeven.getSelectedItem().toString(),i1);
      int i2 = i1 + 1;
      getGPAValueForGrade(this.gpaSpinnerEight.getSelectedItem().toString(), i2);
      (i2 + 1);
      }

Error at the last part (i2 + 1); as not a statement

public void setTextResults() {
    TextView localTextView1 = (TextView) findViewById(R.id.GPATextView);
    TextView localTextView2 = (TextView) findViewById(R.id.CGPATextView);
    float f1 = 0.0F;
    float f2 = 0.0F;
    int i = 0;
    float f3;
    if (i >= 8) {
    f3 = f1 / f2;
    if (f2 != 0.0F)
    break label153;
    localTextView1.setText("GPA: 0.0");
    }
    float f4;
    float f5;
    while (true) {
    if (this.userInputGPA == -1.0F)
    break label258;
    f4 = f1 + this.userInputGPA * this.userInputUnits;
    f5 = f2 + this.userInputUnits;
    if (f5 != 0.0F)
    break label203;
    localTextView2.setText("CGPA: 0.0");
    return;
    if (this.GPAValueArray[i] != -1.0F) {
    f1 += this.GPAValueArray[i] * this.UnitValueArray[i];
    f2 += this.UnitValueArray[i];
    }

Errors at break label153,break label258 & break label203 as undefinable label

i++;
  break;
  label153:
  StringBuilder localStringBuilder1 = new StringBuilder("GPA: ");
  Object[] arrayOfObject1 = new Object[1];
  arrayOfObject1[0] = Float.valueOf(f3);
  localTextView1.setText(String.format("%.2f", arrayOfObject1));

Error in StringBuilder localStringBuilder1 = new StringBuilder("GPA: ") as not a statement

 label203:
Float f6 = f4 / f5;
StringBuilder localStringBuilder3 = new StringBuilder("CGPA: ");
Object[] arrayOfObject3 = new Object[1];
arrayOfObject3[0] = Float.valueOf(f6);
localTextView2.setText(String.format("%.2f", arrayOfObject3));
return;

Error in Float f6 = f4 / f5 as not a statement

Tagged:
Sign In or Register to comment.