Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

// I am trying to call a method called getGoodProvinceCode fromwithin another me

ID: 3615055 • Letter: #

Question

// I am trying to call a method called getGoodProvinceCode fromwithin another method called getPST. When l compile the program itsays pstmethod can not be applied to () . What does this mean andhow can l solve this problem. The other thing is can l return twothings from one method like what l did in getPST

import javax.swing.*;

public class pstmethod
{
    public static void main (String [] args )
    {
        String callProvince =getGoodProvinceCode();

        String callPST =getPST();

       System.out.println(callProvince);


    }

    public static String getGoodProvinceCode()
    // open method getGoodProvinceCode
    {





         booleaninputOk=false;

         String province =JOptionPane.showInputDialog("Enter your provincial code e.gMB");


               while ( !inputOk )
               {   // open while loop

                     province =province.toUpperCase().trim() ;
                     if (province.equals("BC") || province.equals("AB")
                       ||province.equals("SK") || province.equals("MB")
                       ||province.equals("ON") || province.equals("QC")
                       ||province.equals("PE") || province.equals("NB")
                       ||province.equals("NS") || province.equals("NL") )
                       {
                          inputOk=true;
                       }



                     else
                     {
                       inputOk=false;

                         province = JOptionPane.showInputDialog("Enter your provincial codee.g MB");
                     }
                   }// close while loop
                  System.out.println(province);

                   return province;
               }   // close methodgetGoodProvinceCode

    public static double getPST(String province)
    // opens method get PST
    {
        String input =getGoodProvinceCode();


        final double HST_RATE=0.13;
        final double AB_PST_RATE=0;
        final doubleSK_PST_RATE=0.05;
        final double MB_PST_RATE =0.07 ;
        final doubleON_PST_RATE=0.08;
        final doubleQC_PST_RATE=0.075;
        final doublePE_PST_RATE=0.10;

        double PST;
        double HST;



        if(input.equalsIgnoreCase("AB"))    // if user inputsAB the PST is AB_PST_RATE
        {
        PST=AB_PST_RATE;
        }
        else if(input.equalsIgnoreCase("SK"))
        {
        PST=SK_PST_RATE;
        }
        else if(input.equalsIgnoreCase("MB"))
        {
        PST=MB_PST_RATE;
        }
        else if(input.equalsIgnoreCase("ON"))
        {
        PST=ON_PST_RATE;
        }
        else    if (input.equalsIgnoreCase("QC"))
        {
        PST=QC_PST_RATE;
        }
        else if(input.equalsIgnoreCase("PE"))
        {
        PST=PE_PST_RATE;
        }

      return PST ;
      return HST;
    }
}

Explanation / Answer

/* The changes are highlighted in red color. You cannot return two statements...as the second return statementbecomes unreachable after the first return statement isexecuted. */ import javax.swing.*; public class PSTmethod {     public static void main (String [] args )     {         String callProvince =getGoodProvinceCode();         double callPST = getPST(callProvince); /* this methodreturns double instead of string and also takes an parameterof type string */        System.out.println(callProvince);     }     public static String getGoodProvinceCode()     // open method getGoodProvinceCode     {          booleaninputOk=false;          String province = JOptionPane.showInputDialog("Enter your provincial codee.g MB");                while ( !inputOk )                {   // open while loop                      province = province.toUpperCase().trim() ;                      if ( province.equals("BC") || province.equals("AB")                        || province.equals("SK") || province.equals("MB")                        || province.equals("ON") || province.equals("QC")                        || province.equals("PE") || province.equals("NB")                        || province.equals("NS") || province.equals("NL") )                        {                            inputOk=true;                        }                      else                      {                          inputOk=false;                           province = JOptionPane.showInputDialog("Enter your provincial codee.g MB");                      }                    }// close while loop                    System.out.println(province);                    return province;                }   // close method getGoodProvinceCode     public static double getPST(String province)     // opens method get PST     {         String input =getGoodProvinceCode();         final double HST_RATE=0.13;         final doubleAB_PST_RATE= 0;         final doubleSK_PST_RATE=0.05;         final double MB_PST_RATE= 0.07 ;         final doubleON_PST_RATE=0.08;         final doubleQC_PST_RATE=0.075;         final doublePE_PST_RATE=0.10;         double PST =0.0;         double HST = 0.0;          if(input.equalsIgnoreCase("AB"))    // if user inputsAB the PST is AB_PST_RATE         {          PST=AB_PST_RATE;         }         else if(input.equalsIgnoreCase("SK"))         {         PST=SK_PST_RATE;         }         else if(input.equalsIgnoreCase("MB"))         {         PST=MB_PST_RATE;         }         else if(input.equalsIgnoreCase("ON"))         {         PST=ON_PST_RATE;         }        else     if (input.equalsIgnoreCase("QC"))         {         PST=QC_PST_RATE;         }         else if(input.equalsIgnoreCase("PE"))         {         PST=PE_PST_RATE;         }       return PST ;       //returnHST; //either one of the two return statements should becommented     } }