"Missing Return Statement" although the return statement IS there?

Hello :) I am currently studying computing science at staffordshire university, java is one of my modules (first year) and im about half way through (still at introduction stage though)... Within my code apparently I have not returned a statement... yet to my believe the return statement is there and in the correct space, i would appreciate it if you could have a look and tell me where I am going wrong please:
import java.util.*;
public class ReadWriteArrayApp3
+{+
+ public static void main(String [ ] args)+
+ {+
+ int[] nums = int double[6];+
+ double result;+
+ readArray(nums);+
+ printArray(nums);+
+ printReverse(nums);+
+ averageArray(nums);+
result = averageArray(nums);
+ System.out.println("The average of your numbers is " + result);+
+ } // end main+
public static void readArray(int [] a)
+ {+
+ Scanner kybd = new Scanner(System.in);+
+ System.out.println("Please enter 6 Integers");+
+ for(int i=0; i < a.length; i++)+
+ {+
+ a[i] = kybd.nextInt();+
+ }+
+ }+
+public static void printArray(int [ ] b)+
+ {+
+ for (int i = 0; i < b.length; i++)+
+ {+
+ System.out.println(b);+
+ }+
+ }+
+ public static void printReverse(int [ ] c)+
+ {+
+ for (int i = c.length-1; i >= 0; i--)+
+ {+
+ System.out.println(c[i]);+
+ }+
+ }+
+ public static double averageArray(int [ ] d)+
+ {+
+ double sum, tot, average;+
+ for (int i = 0; i < d.length; i++)+
+ {+
+ tot = tot + d[i];+
+ average = (tot)/d.length;+
+ if ((average)=(tot/d.length))+
+ {+
+ sum = average;+
+*  }
+ return sum;+
+ }+
+} // end application class+
Console states:
javac  ReadWriteArrayApp3.java
ReadWriteArrayApp3.java:49: missing return statement
* ^*
*1 error*
Above in the code I have shown I have made a part bold... this shows the area in which console has a problem with.
I would really appreciate any help in which I get
Thankyou
Victoria
Edited by: StaffsUniJavaGirl on Nov 12, 2009 9:48 AM

import java.util.*;
public class ReadWriteArrayApp3
     public static void main(String [ ] args)
          int[] nums = int double[6];
          double result;
          readArray(nums);
          printArray(nums);     
          printReverse(nums);
          averageArray(nums);
          result = averageArray(nums);
          System.out.println("The average of your numbers is " + result);
     }  //  end main
     public static void readArray(int [] a)
          Scanner kybd = new Scanner(System.in);
          System.out.println("Please enter 6 Integers");
          for(int i=0; i < a.length; i++)
          a[i] = kybd.nextInt();
     public static void printArray(int [ ] b)
          for (int i = 0; i < b.length; i++)
               System.out.println(b);
     public static void printReverse(int [ ] c)
          for (int i = c.length-1; i >= 0; i--)
               System.out.println(c[i]);
     public static double averageArray(int [ ] d)
          double sum, tot, average;
          for (int i = 0; i < d.length; i++)
               tot = tot + d[i];
               average = (tot)/d.length;
               if ((averagetot)=(tot/d.length))
                    sum = average;
     return sum;
} // end application class*line 49 is bold*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Method which is return's all the refinement state for Dimension.

    Hi All,
    Is there any java method which is return's all the refinement state for Dimension.
    Ex:
    Brand
    Reebok
    Scholl
    Sebago
    Ravel
    When i clicked All Brand from front end it will select all 4 Brands data.
    Any help will be great appreciation
    Thanks,
    Sunil N

    Not sure what you want to achieve here. If you want to select all the dimension values, then provided the dimension is Multi-select OR you can have N=Id-1+Id-2+Id-3 and it will return all of them. What I'm not sure on is why you would do this, you'll get back precisely the same results (provided every record is tagged with a brand) as if you did nothing, although I guess you might want to allow them to select all then deselect one or more afterwards ... Note you can also use N=<dimension-id>, where <dimension-id> is the id of the actual dimension, and that will return all records that have a value for that dimension, but that won't give you any descriptors (breadcrumbs) other than the dimension name/id.
    Michael

  • How would you change the state to the base state?

    How would you change the state to the base state? Its not
    letting me do something like:
    currentState='<Base State>';

    Sorry about the vagueness of that last reply :)
    What I have done now in my code is this:
    viewstack1.addChildAt(loginCanvas,0);
    toggle.selectedIndex = 0;
    However nothing happens at this line of code:
    toggle.selectedIndex = 0;
    but this works:
    toggle.selectedIndex = 1; or ...
    toggle.selectedIndex = 2;
    toggle.selectedIndex = 3;
    toggle.selectedIndex = 4;
    toggle.selectedIndex = 5;
    toggle.selectedIndex = 6;
    The strange thing is that if I have a button on the screen:
    <mx:Button x="10" y="3" label="Button"
    click="toggle.selectedIndex =0"/>
    and the user clicks it the toggle.selectedIndex = 0; works.
    I'm stumped, any ideas?

  • I have lost my photo albums on my iPad Although the photos are still there. How do I get the albums back?, I have lost my photo albums on my iPad Although the photos are still there. How do I get the albums back?

    I have lost my photo albums on my iPad Although the photos are still there. How do I get the albums back?, I have lost my photo albums on my iPad Although the photos are still there. How do I get the albums back?

    It's version iPhoto '11. I sent the photos to the trash from in the resident iPhoto application, but not to the iPhoto trash, but the OS's trash in the bottom right task bar (Finder Trash).
    Realizing what I had done, I dragged the picture folder back into the "Pictures" folder under my name in the Finder. I also dragged the iPhoto Library file back, but it said a new one had been created... I still attempted to replace the new with old iPhoto Library file.
    The pictures are back and i can see the album names under events. The problem is that the album covers, nor the pictures themselves show up as thumbnails like they did before... they only show when you individually click on the photo to bring it into full view. I only see a grey background where the thumbnail was.
    Any assistance you can provide would be greatly appreciated!
    Thanks,
    Evan

  • Suddenly my iphone 4 stopped connecting to the 3g network although the 3g symbol is there on the left of the screen

    suddenly my iphone 4 stopped connecting to the 3g network although the 3g symbol is there on the left of the screen did this happen with anyone ??

    Try turning on Airplane mode for 30 seconds (Settings>Airplane Mode>ON), then off.  See if you can connect to 3G now.

  • Trying to write an if statement around the return value of a CANCEL_OPTION

    I am writing a program that takes an input String using JOptionPane. The String can be made of only letters of the A-Z alphabet and the space character. I have written an error-checking loop that will pop another input box up along with an error message if any invalid character is detected. The input box has an 'ok' button and a 'cancel' button. As it is, if you hit cancel, the program crashes and you get a NullPointerException. All I want to do is place an if statement inside of the error-checking loop, immediatly after the code to pop up the second input box, that simply does System.exit() and exits the program correctly(rather than crashing) if 'cancel' is clicked.
    My attempt at such an if statement is visible in the following code(letter is a boolean variable defined earlier, and message is the input String that has already been read in):
                   letter = isValidMessage(message);
              while(!letter)
                   message = JOptionPane.showInputDialog(null, "Message must contain only A-Z, a-z, or space character...");
                            if(JOptionPane.CANCEL_OPTION > 0  //or ==0 or ==1 or ==2, nothing works//)
                                JOptionPane.showMessageDialog(null, "No valid message entered - program will terminate...");
                                System.exit(JOptionPane.CANCEL_OPTION);
                   letter = isValidMessage(message);
                    }The if statement doesn't work correctly. If you click 'cancel' when the input box comes up, the program does terminate as it is supposed to. The problem is that if I type something in the box and click 'ok', it also causes the program to terminate rather than continuing. I've tried changing the > to ==. I've tried changing 0 to 1 to 2 to -1(I really am not sure which int return value of CANCEL_OPTION corresponds to which event). I think once I got to do the exact opposite...that is to say, it would continue on with the program whether I clicked 'cancel' or 'ok'. Which is equally bad. I don't know what I'm doing wrong.
    It's probably something simple that I'm just overlooking.

    Well, here's what CANCEL_OPTION is, according to the JOptionPane class:
    /** Return value from class method if CANCEL is chosen. */
        public static final int         CANCEL_OPTION = 2;However, I believe you're going about this in the wrong way.
    With JOptionPane, whenever you show a dialog, it usually returns whatever OPTION the user chose.
    For instance,
        int choice = JOptionPane.showConfirmDialog(parentComponent, "hello");That will bring up a dialog centered on parentComponent, with a message of "hello".
    It will have the default options (YES_NO_OPTION).
    What it returns is the option the user chose.
    There are 4 possible things it can return:
    YES_OPTION, when user clicks "Yes"
    NO_OPTION, when user clicks "No"
    ERROR_OPTION, when an unforseen error occurs and the dialog closes
    CANCEL_OPTION, when the user clicks "Cancel" (if that OPTION type were being used), or if they close the dialog
    So this is how you would check for CANCEL_OPTION:
        int choice = JOptionPane.showConfirmDialog(parentComponent, "hello");
        if (choice == JOptionPane.CANCEL_OPTION) {
            // User cancelled
        else if (choice == JOptionPane.YES_OPTION) {
            // User chose yes
        // EtcSo you see, going about it like this:
    if(JOptionPane.CANCEL_OPTION > 0  //or ==0 or ==1 or ==2, nothing works//)Is really the wrong way, because you're not checking what the user DID, but just what the constant variable "CANCEL_OPTION" is.
    However, it seems as if you're in a unique situation where you don't want the OPTION chosen by the user, but an input String.
    This is all well and good, but I think this limits how you can interact with the user, as the "showInputDialog" methods return the String the user input- not the OPTION they chose, and you need to use both.
    What I've done in the past is created a simple JPanel with its own JTextField.
    I pass the JPanel in as the "message" parameter of a showConfirmDialog call, and get both the user input and their chosen OPTION based off a getText call to the JTextField and the OPTION constant returned by showConfirmDialog.
    Basically,
    JPanel promptPanel = new JPanel(new BorderLayout());
    JTextField promptField = new JTextField();
    promptPanel.add(promptField, BorderLayout.CENTER);
    int choice = JOptionPane.showConfirmDialog(parentComponent, promptPanel, "Input", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (choice == JOptionPane.OK_OPTION) {
       // User chose OK, see if invalid characters were entered
       String input = promptField.getText();
    else if (choice == JOptionPane.CANCEL_OPTION) {
       // User cancelled
    }Hope that helps.
    (note that I'm unsure if showConfirmDialog can accept OK_CANCEL_OPTION as its OPTION parameter, as it says only YES_NO_OPTION and YES_NO_CANCEL_OPTION can be used, but I seem to remember using it in the past. if OK_CANCEL_OPTION doesn't want to work, then use one of the other two and adjust your if statements accordingly)
    Cheers!
    Edited by: LukeFoss on Oct 9, 2007 10:39 PM

  • Decode Statement Inside the Case statement

    Can we use Decode Statement inside a CASE Statement as show below --
    It is giving an error -- Is the a better way to write with out any error
    create or replace
    function test (a varchar2) RETURN VARCHAR2
    is
    m varchar2(20);
    begin
    m :=
    CASE
    WHEN a IN (
    '1009' -- (soon obsolete)
    ,'1010'
    ,'1019'
    ,'1051'
    ,'XGP'
    ,'XSC')
    THEN (SELECT DECODE(v_lef_cd,'NAM','71','GLB','99','01') into m FROM DUAL)
    -- ) THEN '01' -- UNITED STATES OF AMERICA
    WHEN a IN (
    '1069' -- South Africa
    ,'SAO' -- South Africa
    ,'SA' -- South Africa
    ) THEN '26' -- South Africa
    ELSE NULL
    END;
    return m;
    end;

    Hi,
    You can only use DECODE in SQL statements.
    Your SELECT DECODE (...) INTO statement would work anywhere a PL/SQL statement is allowed; but PL/SQL statements are not allowed within CASE expressions.
    Remember, the expression that comes after THEN in a CASE expression must be a single value.
    I would write a function like this using IF ... ELSIF statements. It's a little more typing than CASE, but a lot easier to code, test and maintain.
    If you want to use CASE, here's one way:
    ...     m := CASE
              WHEN  a  IN ('1069', 'SAO', 'SA')
                   THEN  '26'     -- South Africa
              WHEN  a  NOT IN ('1009', '1019', '1051', 'XGP', 'XSC')
              OR    a  IS NULL
                   THEN  NULL
              WHEN  v_lef_cd = 'NAM'
                   THEN  '71'
              WHEN  v_lef_cd = 'GLB'
                   THEN  '99'
                   ELSE  '01'     -- USA
              END;This assumes that you have a variable v_lef_cd defined.
    If you want, you can nest CASE expressions, like this:
    ...     m := CASE
              WHEN  a  IN ('1069', 'SAO', 'SA')
                   THEN  '26'     -- South Africa
              WHEN  a  IN ('1009', '1019', '1051', 'XGP', 'XSC')
                   THEN  CASE  v_lef_cd
                          WHEN  'NAM'
                             THEN  '71'
                          WHEN  'GLB'
                             THEN  '99'
                             ELSE  '01'     -- USA
                         END
              END;Always format your code, so you can see where the CASE expressions and each of the WHEN clauses begin and end.
    When posting formatted text on this site, type these 6 characters:
    (all small letters, inside curly brackets) before and after sections of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • My lov returns AND displays the return value

    Hi,
    For 1 of the columns I'm representing in APEX, I choose 'Display as text, based on a lov'. I'm using:
    select aan.id||', '||r.naam||', '||a.woonplaats d, aan.id r
    from wmo_aanvragen aan
    , wmo_dossiers d
    , wmo_relaties r
    , wmo_adressen a
    where d.avg_1_id = aan.id
    and d.rel_nummer = r.nummer
    and a.rel_nummer = r.nummer
    and a.id = (select min(e.id) from wmo_adressen e where e.REL_NUMMER = r.nummer
    and e.EIND_DATUM is null)
    and d.id = (select min(f.id) from wmo_dossiers f where f.AVG_1_ID = aan.id)
    But somehow it returns AND displays the 'aan.id' value instead of displaying the display value. Does anyone know howcome?? In TOAD it works fine. Starting a new page also doesn't make any sense
    Niels

    Nope, doesn't work either.
    I've an identical statement which does work...
    select z.id||', '||zst.omschrijving||', '||r.naam||', '||a.woonplaats d, z.id r
    from wmo_zorgverleners z
    , wmo_zorgverlener_soorten zst
    , wmo_relaties r
    , wmo_adressen a
    where z.zst_id = zst.id
    and z.rel_nummer = r.nummer
    and a.rel_nummer = r.nummer
    and a.id = (select min(e.id)
    from wmo_adressen e
    where e.REL_NUMMER = r.nummer
    and e.EIND_DATUM is null)
    Here,iIt does display the contcatenated text..

  • Case sensitive statement in the select-statement

    Hi All,
    i have a table in the abap-dictionary filled with names...when i try to select them with the select-statement with condition:
    table-name_column like 'some_name'
    I have encountered some problems...the inquiry is case-sensitive. What i want to do is to read the value from the abap-dictionary table uppercase or lowercase and compare it with the needed value also translated in uppercase or lowercase.
    The only idea i have is to select all values of the dictionary table into an internal table and to translate the values there in uppercase or lowercase and then to loop trough it. But this approach would cost a lot of performance.
    Do someone has an other proposal?

    check...
    Select statement
    It would be difficult , because it is based on how data is stored in the data base , now consider the scenario of the system i am using , we can material description as 'test' or 'TEST' , 'Test' .
    If in your system there are only stored in either caps or small the you can perform the select twice .
    But i myself dont find it to be such a good solution , but you can give it a try
    There is one more solution specific to material description ,and that is in the table MAKT there is a field MAKTG , which stored the description in uppercase , so for this you can first convert the description to uppercase and then perform select on this field

  • Just tried to install update to iTunes and keep getting error statements. The errors statements read: "iTunes was not installed correctly. Please reinstall iTunes. Error 7 (Windows error 1114) and Runtime error - Program: C\Program files (x86)\iTunes\iTun

    I just tried to install the iTunes update 11.4.1 and keep getting error messages.  I have never had this issue before over many years of using iTunes and getting updates to the software.  I have removed the iTunes from my computer and reinstalled it but keep getting the errors.  Here are the error statements: "Runtime error: Program: C:\Program Files(x86)\iTunes\iTunes.exe; R6034; An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team.  iTunes was not installed correctly. Please reinstall iTunes. Error 7 (Windows error 1114)

    Follow the instructions of tt2 in https://discussions.apple.com/thread/5822086 and note to run as admin

  • Deleted Bank statement - reset the Bank statement.

    Dear Friends,
    The user claims Bank statements were deleted.
    How to find out who deleted them.
    How to reset them?
    Please suggest.
    Regards
    Sridhar Reddy

    Dear Friends,
    Thanks for the time and effort.
    As suggested, I used the T.code FBL3N for the Main Bank account, outgoing and incoming accounts. The FI data was intact.
    It seems that only Bank statements from FF67 were deleted.
    We have promised the user that we will upload the manual bank statement  for one year.
    But there are more than 10 banks and data has to be uploaded.
    Is there any simple process or program which bank data can be uploaded with short span of time.
    Please suggest.
    Regards
    Sridhar

  • Disable random generation of  .adf-ctrl-state and the view state

    Hi,
    I'm trying to test a few transaction on an ADF application that would need to be run using a simulator.
    The problem is it is pretty hard to do this using a programmed simulator since everytime the adf-ctrl-state and the viewstate in the browser change, which requires capturing them. To complicate matters further there exists the PPR navigation (at least that's what I think it is) which present a unique _afrLoop id, that also seems to behave differently with different user-agents. 
    My question is, can I do anything with those fiedls that would allow me to have one id to run my transactions ? I understand that some of those ids, like the viewstate act like a session nonce....but are there do I have any options ?
    Thanks,

    You will need to configure your test suite to capture and replay those values. There is also the javax.faces.ViewState variable.
    Here are some good pointers on how to do this in JMeter
    http://one-size-doesnt-fit-all.blogspot.com.au/2010/04/configuring-apache-jmeter-specifically.html
    A more generalized article
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/adfloadstresstesting-354067.pdf

  • I am new to ipad and iphoto.  I edited a photo and then selected undo, to return it to the original.  Now there is a spinning disk on the screen and the program is frozen. What can I do now?  I can still access the same photo through the camera roll.

    I am new to ipad and iphoto.  I edited a photo and saved it.  Then used "undo" to change it back.  The thumbnail shows the edited version and the larger window shows the original version.  There is a whirling disk over the orginal version as if the program is stuck saving the reversion back to original.  None of the other features will work.  Turning it off doesn't help.  leaving it on indefinetely so it will "complete saving" doesn't work.  I don't have some of the keys and choices outlined with other posts about stuck iphoto on Macs.  Any help would be appreciated.

    Quit the app completely and reboot the iPad. Go to the home screen first by tapping the home button. Double tap the home button and the recents tray will appear with all of your recent apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Tap the home button or anywhere above the task bar.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • DCM BitLocker protection assigned configuration baseline return ERROR in the compliance state

    Hello,
    Here is the situation: I Installed MBAM 2.5 and done the integration with SCCM 20012 R2. Modified the GPO for the targeted clients.
    Encryption started, DCM policies ran and Reports on SCCM server (after a long period), it returned compliances of my tests computers. I have removed and reinstalled SCCM integration. NOW, the SCCM clients are returning Configuration Baselines error
    when the evaluate, (NOT Non-Compliant). It was running fine before.
    here is a sample of my DcmWmiProvider.log:
    ScriptProvider::ReadDiscoveryInformation - ScriptType: 1 ScriptProvider 2015-01-26 11:39:44 2832 (0x0B10)
    ScriptProvider::CreateInstanceEnumAsync - Script Execution Returned :1, Error Message:(null) ScriptProvider 2015-01-26 11:39:44 2832 (0x0B10)
    Failed in discovering instance.
    Incorrect function. (Error: 80070001; Source: Windows) ScriptProvider 2015-01-26 11:39:44 2832 (0x0B10)
    Failed to do HandleExecQueryAsync().
    Incorrect function. (Error: 80070001; Source: Windows) ScriptProvider 2015-01-26 11:39:44 2832 (0x0B10)
    Failed to process CScriptProvider::GExecQueryAsync.
    Incorrect function. (Error: 80070001; Source: Windows) ScriptProvider 2015-01-26 11:39:44 2832 (0x0B10)
    ScriptProvider::ReadDiscoveryInformation - reading discovery script definition ScriptProvider 2015-01-26 11:39:44 2832 (0x0B10)
    ScriptProvider::ReadDiscoveryInformation - ScriptType: 1 ScriptProvider 2015-01-26 11:39:44 2832 (0x0B10)
    You can see that the script is generating an error with an incorrect function. This is weird! That script was working correctly before. I don't even know where this script is located on the SCCM server.
    Anyone can help me with this problem?
    Big Air

    Hi!
    I think I found the root cause of this problem. I'm not 100% sure, but the
    Configuration baseline ID that the client receive is reuse in the policy after uninstalling and reinstalling the MBAM Integration. The client can't find it on the configuration point, since it acquired a new AssignmentID when fetching the policies
    and reevaluating the Configuration Base line.
    Here how I fixed this:
    I have exported using the Export function on the two Configuration Items named
    BitLocker Operating System Drive Protection, BitLocker Fixed Data Drives Protection,
    then created a new Configuration Baseline and imported the two Configurations Items. Deployed to the targeted collection. It work on first try. I also disabled the faulty one. You can also delete it, since it's useless. Now everything is all aligned
    and working.
    Hope someone can confirm this hypothesis or have a more elegant solution?
    Thanks!
    Big Air

  • Select Statement inside the insert statement

    I need to insert the values into nav_pending by selecting the values from nav table
    when i write this code its giving missing expression error
    Can i know what is the problem??
    can i use select inside insert in oracle????
    INSERT INTO NAV_PENDING (ACCOUNT_NUM,PERIOD_DTE)
    VALUES
    SELECT ACCOUNT_NUM,PERIOD_DTE
    FROM NAV where ACCOUNT_NUM=1;
    Thanks in advance

    Leave the values keyword
    INSERT INTO NAV_PENDING (ACCOUNT_NUM,PERIOD_DTE)
    SELECT ACCOUNT_NUM,PERIOD_DTE
    FROM NAV where ACCOUNT_NUM=1;

Maybe you are looking for