Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm having issues in creating a program using Android Studio.But i get a little coding errors. Any assistance would be appreciated.

What I have tried:

These are a few errors i'm having
Java
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

Java
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

Java
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

Java
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

Java
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
Posted
Updated 6-Nov-16 22:48pm

1 solution

In the first case you have a return statement in the middle of your method so the statement in the error message can never be reached.

In the second case you have a switch block that does nothing. You then have a break statement and a number of continue statements that prevent anything useful being done.

In the third case you have a non-statemnt (i2 + 1); etc.

I would suggest going back to The Java™ Tutorials[^] and spending some time learning Java.
 
Share this answer
 
Comments
CPallini 7-Nov-16 5:38am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900