Spot the error!!!! float not saved in array

I have the following class file which compiles fine and runs, but for some reason the salary is never stored into the file when saved, i am outputting store to the terminal window and everything comes up apart from salary which always says 0.0 can anybody see any errors has it is driving me mad lol!
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import bank.BankUI;
import bank.*;
public class CreateSequentialFile extends JFrame {
   private ObjectOutputStream output;
   private BankUI userInterface;
   private JButton enterButton, openButton;
   private Store store;
   private Employee record;
   // set up GUI
   public CreateSequentialFile()
      super( "Creating a Sequential File of Objects" ); // appears in top of gui
      // create instance of reusable user interface
      userInterface = new BankUI( 9 );  // four textfields
      getContentPane().add( userInterface, BorderLayout.CENTER );
      openButton = userInterface.getDoTask1Button();
      openButton.setText( "Save to file" );
      openButton.addActionListener(
         // anonymous inner class to handle openButton event
         new ActionListener() {
            // call openFile when button pressed
            public void actionPerformed( ActionEvent event )
               openFile();
         } // end anonymous inner class
      ); // end call to addActionListener
      // configure button doTask2 for use in this program
      enterButton = userInterface.getDoTask2Button();
      enterButton.setText( "Save to file..." );
      enterButton.setEnabled( false );  // disable button
      // register listener to call addRecord when button pressed
      enterButton.addActionListener(
         // anonymous inner class to handle enterButton event
         new ActionListener() {
            // call addRecord when button pressed
            public void actionPerformed( ActionEvent event )
               addRecord();
         } // end anonymous inner class
      ); // end call to addActionListener
      // register window listener to handle window closing event
      addWindowListener(
         // anonymous inner class to handle windowClosing event
         new WindowAdapter() {
            // add current record in GUI to file, then close file
            public void windowClosing( WindowEvent event )
                         if ( output != null )
                            addRecord();
                              closeFile();
         } // end anonymous inner class
      ); // end call to addWindowListener
      setSize( 600, 500 );
      setVisible( true );
     store = new Store(100);
   } // end CreateSequentialFile constructor
   // allow user to specify file name
   private void openFile()
      // display file dialog, so user can choose file to open
      JFileChooser fileChooser = new JFileChooser();
      fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
      int result = fileChooser.showSaveDialog( this );
      // if user clicked Cancel button on dialog, return
      if ( result == JFileChooser.CANCEL_OPTION )
         return;
      File fileName = fileChooser.getSelectedFile(); // get selected file
      // display error if invalid
      if ( fileName == null || fileName.getName().equals( "" ) )
         JOptionPane.showMessageDialog( this, "Invalid File Name",
            "Invalid File Name", JOptionPane.ERROR_MESSAGE );
      else {
         // open file
         try {
            output = new ObjectOutputStream(
               new FileOutputStream( fileName ) );
            openButton.setEnabled( false );
            enterButton.setEnabled( true );
         // process exceptions from opening file
         catch ( IOException ioException ) {
            JOptionPane.showMessageDialog( this, "Error Opening File",
               "Error", JOptionPane.ERROR_MESSAGE );
      } // end else
   } // end method openFile
   // close file and terminate application
   private void closeFile()
      // close file
      try {
                                             int storeSize = store.getCount();
                                        for (int i = 0; i<storeSize;i++)
                                        output.writeObject(store.elementAt(i));
         output.close();
         System.exit( 0 );
      // process exceptions from closing file
      catch( IOException ioException ) {
         JOptionPane.showMessageDialog( this, "Error closing file",
            "Error", JOptionPane.ERROR_MESSAGE );
         System.exit( 1 );
   } // end method closeFile
   // add record to file
   public void addRecord()
      int employeeNumber = 0;
      String fieldValues[] = userInterface.getFieldValues();
      // if account field value is not empty
      if ( ! fieldValues[ BankUI.IDNUMBER ].equals( "" ) ) {
         // output values to file
         try {
            employeeNumber = Integer.parseInt(
               fieldValues[ BankUI.IDNUMBER ] );
                    String dob = fieldValues[ BankUI.DOB ];
                    String[] dateofBirth = dob.split ("-");
                    String sDate = fieldValues[ BankUI.START ];
                    String[] startDate = sDate.split ("-");
                    String sex = fieldValues[ BankUI.GENDER ];
                    char gender = (sex.charAt(0));
if ( employeeNumber >= 0 ) {
                record  = new Employee(
                fieldValues[ BankUI.NAME ],
                    gender,
                new Date(     Integer.parseInt(dateofBirth[0]),
                          Integer.parseInt(dateofBirth[1]),
                          Integer.parseInt(dateofBirth[2])),
                    fieldValues[ BankUI.ADDRESS ],
                    fieldValues[ BankUI.NATINTNO ],
                    fieldValues[ BankUI.PHONE ],
                    fieldValues[ BankUI.IDNUMBER ],
          new Date(     Integer.parseInt(startDate[0]),
                          Integer.parseInt(startDate[1]),
                          Integer.parseInt(startDate[2])),
          Float.parseFloat( fieldValues[ BankUI.SALARY ] ));
                    if (!store.isFull())
                         store.add(record);
                    else
                    JOptionPane.showMessageDialog( this, "The Store is full you cannot add\n"+
                     "anymore employees. \nPlease Save Current File and Create a New File." );
                         System.out.println("Store full");
                    store.displayAll();
                    System.out.println("Count is " + store.getCount());
                              // output record and flush buffer
                    //should be written to fuile in the close file method.
                                             output.flush();
            else
                JOptionPane.showMessageDialog( this,
                   "Account number must be greater than 0",
                   "Bad account number", JOptionPane.ERROR_MESSAGE );
            // clear textfields
            userInterface.clearFields();
         } // end try
         // process invalid account number or balance format
         catch ( NumberFormatException formatException ) {
            JOptionPane.showMessageDialog( this,
               "Bad ID number, Date or Salary", "Invalid Number Format",
               JOptionPane.ERROR_MESSAGE );
         // process exceptions from file output
         catch ( ArrayIndexOutOfBoundsException ArrayException ) {
             JOptionPane.showMessageDialog( this, "Error with Start Date or Date of Birth",
                "IO Exception", JOptionPane.ERROR_MESSAGE );
                  // process exceptions from file output
         catch ( IOException ioException ) {
             JOptionPane.showMessageDialog( this, "Error writing to file",
                "IO Exception", JOptionPane.ERROR_MESSAGE );
            closeFile();
      } // end if
   } // end method addRecord
   public static void main( String args[] )
      new CreateSequentialFile();
} // end class CreateSequentialFile

I don't see any salary-related code in what you posted. Is there salary information in that Employee class or something? If so you should look there to see if it's working correctly. Or better still, test the Employee class properly before allowing other classes to use it.

Similar Messages

  • Pages is not saving document correctly.  After saving the changes either do not appear or you can not open the file. The error is "not a valid format"  I am in Pages '09 4.1 (923).  I also use Parallels.  Anyone having similar issues?

    Pages is not saving document correctly.  After saving the changes either do not appear or you can not open the file. The error is "not a valid format"  I am in Pages '09 4.1 (923).  I also use Parallels.  Anyone having similar issues?

    I'm not sure that Lion AutoSave feature apply to network servers.
    I'm just sure that the Versions feature doesn't.
    Yvan KOENIG (VALLAURIS, France) samedi 21 janvier 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My Box account  is : http://www.box.com/s/00qnssoyeq2xvc22ra4k
    My iDisk is : http://public.me.com/koenigyvan

  • The workbook was not saved

    Hi,
    This problem occurs after a BI upgrade. When I try to change a workbook and save it, I get the error "The workbook was not saved". There are other threads with that issue but no answer has been provided.
    Thanks,
    Patrick

    Hi
    Try this, go to RSRT and give your query and in properties change to H. And do all queries which you are using in the workbook. Hope it works.
    Vishal.

  • Error "document not saved" when want to save Word/Excel files on NAS server

    Hello everybody!
    I have a NAS server (QNAP storage).I want to have some folders with these permissions : 
    1.nobody can create or delete folders in first parent folders (blue folder and red folders )
    2.everybody can create/save folders,docs... in it. (Black folders)
    when I set permission like picture below,people can not save documents in Excel or Word format in folders ( I have this problem just for Word and Excel).they face with errors : document not saved / access denied,contact your administrator.
    special permission for blue folder (domain users) 
    (include inheritable permission) and (replace all child subfolders...) are unchecked.
    traverse / execute files
    List folders/ read data
    Read attribiutes
    Read extended attribiutes
    Read permission
    special permission for red folder :
    (include inheritable permission) and (replace all child subfolders...) are unchecked.
    traverse / execute files
    List folders/ read data
    Read attribiutes
    Read extended attribiutes
    create files / write data
    create folders / append data
    write attributes
    write extended attributes
    delete subfolders
    delete
    Read permission
    special permission for black folder :
    these folders inherit permissions from parents.
    (include inheritable permission is checked.
    (replace all child subfolders...) is unchecked.
    when I uncheck "delete" permission in red folders and save it,"modify" permission in main permission will uncheck,too.I dont know why?in this situation,people can save docs, but they can rename/delete folders,too ( I dont want they delete
    or rename parent folders).
    what I must do?
    regards,
    atiye moghaddam

    Hi.
    How are the rights configured to be inherited? Could you do a "icacls <folder>" on each level and post it back.
    Also worth considering is that this is a Linux Samba system, so it might not work as a regular windows system.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. Even if you are not the author of a thread you can always help others by voting as Helpful. This can
    be beneficial to other community members reading the thread.
    Oscar Virot

  • In an eMail message, when I attempt to save two photos by clicking the 'Save 2 Images' link, not the 'Save Image' link, the images are not saved. (I use I I apologize for the late notice, butOS7 on IPhone5). Is this feature broken?

    In an eMail message, when I attempt to save two photos by clicking the 'Save 2 Images' link, not the 'Save Image' link, the images are not saved. (I use I I apologize for the late notice, butOS7 on IPhone5). Is this feature broken?

    Please don't post the same question multiple times!

  • Before when I scanned a photo, it would automatically save and ask to scan another photo. Now, the photo is not saving and it doesn't ask to scan again. Help?

    Before when I scanned a photo, it would automatically save and ask to scan another photo. Now, the photo is not saving and it doesn't ask to scan again. Help?

    What Scanner and scanware are you using....?
    Check out > Mac Basics: Using a scanner
    I only use Image Capture and it always sends my photos to wherever I tell it to.

  • HT1923 got notification that new Itunes version is available, once i installed it I'm no longer able to open Itunes, I get the error message, Not installed properly. Reinstall itunes. Error 7(Windows error127),

    got notification that new Itunes version is available, once i installed it I'm no longer able to open Itunes, I get the error message, Not installed properly. Reinstall itunes. Error 7(Windows error127), I tried repairing itunes, Apple Aplication support, apple mobile device support, bonjour and I even uninstalled and reinstalled Itunes and still problem exist, any solution?
    I have windows 8

    I got this message today too. I understand that my music is stored on my computer, however I want to be certain that if I re-install iTunes, it won't erase my library....playlists, playcounts, checked songs, etc.

  • Is my HD Dead? Reformat Disk Utility Error: secure disk erase failed with the error could not open disk.

    Hi,
    Fed up with seeing the spinning beach ball I decided to reformat my MacBook Pro...
    After backing up everything on an external hard drive I put in the OSX install DVD, restarted the machine and held down 'C'.
    I followed the install prcedure, clicking next a few times etc...
    I then went into Utilities > Disk Utility. I chose 7-Pass to erase the Macintosh HD and set it off erasing.
    I checked the process an hour in and message on screen read:
    Secure disk erase failed with the error:
    could not open disk
    The internal hard drive no longer exists in the disk utility so I cant retry erasing it.
    The only thing that appears in disk utility is the OSX install DVD.
    I can't even shut down the mac as everything under the apple tab is greyed out!
    I'm guessing this means my hard drive is broken right?
    If anyone has any other ideas of what to try I'd really appreciate that.
    How do I turn the machine off?
    If my hard drive is gone then should I consider getting an SSD drive?
    Any recommendations for such a drive would be great.
    Hope you can help!

    Did you partition the drive?
    Extended Hard Drive Preparation
    1. Open Disk Utility in your Utilities folder. If you need to reformat your startup volume, then you must boot from your OS X Installer Disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger or Leopard.)
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area. If it does not say "Verified" then the drive is failing or has failed and will need replacing. SMART info will not be reported on external drives. Otherwise, click on the Partition tab in the DU main window.
    3. Click on the Options button, set the partition scheme to GUID (only required for Intel Macs) then click on the OK button. Set the number of partitions from the dropdown menu (use 1 partition unless you wish to make more.) Set the format type to Mac OS Extended (Journaled.) Click on the Partition button and wait until the volume(s) mount on the Desktop.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    Steps 4-6 are optional but should be used on a drive that has never been formatted before, if the format type is not Mac OS Extended, if the partition scheme has been changed, or if a different operating system (not OS X) has been installed on the drive.

  • Trying to download iTunes 64-bit version on my new Windows 7 PC. Getting the error 'could not locate "%APPDATA%". How do I get past this error? The software doesn't install.

    Trying to download iTunes 64-bit version on my new Windows 7 PC. Getting the error 'could not locate "%APPDATA%". How do I get past this error? The software doesn't install. Appreciate if someone in the forum can help.

    The backup and restore from the iCloud was a little unnerving since the restore erased all information from the iPod.  The iCloud backup and restore took a long time, but worked.  I was very grateful.
    Trying again to backup to iTunes locally proved to be the same challenging problem.  The same backup to corrupt file was the message.  The status bar showing backup seemed to move faster to start, but then slowed to a creep toward the end before the error. 
    When trying to restore a backup in iTunes, the "Restore" button is grayed out since it is looking for a local copy.  Any restore would need to be from the iCloud which already worked but isn't the final solution.
    Your suggestions were good, I am just in the same boat.  Any thoughts about doing the following?
    1) creating a cloud backup
    2) resetting the iPod to factory defaults
    3) removing all traces of iTunes from my computer and
    4) installing iTunes and setting up iPod from scratch.
    This is the next thing on my list.

  • HT4859 I have the error message "Not enough storage. Cannot backup, not enough backup space in ICloud . . . ", but now the "close" and "settings" buttons don't respond and I cant get the IPad to open so I can go change settings. What do I do?

    I have the error message "Not enough storage. Cannot backup, not enough backup space in ICloud . . . ", but now the "close" and "settings" buttons don't respond and I cant get the IPad to open so I can go change settings. What do I do?

    For a "hard" restart of your iPad just press the home and power button at the same time and hold it for at least 10-15 sec. until it restarts.

  • I have a new computer and my old drive has my UNSAVED bookmarks on it and I want to import them, how do I do it when the bookmarks are not SAVED?

    I have a new computer and my old drive has my UNSAVED bookmarks on it and I want to import them, how do I do it when the bookmarks are not SAVED?

    You can backup the bookmarks on the old computer and create a JSON or HTML backup and restore or import this file in the Bookmarks Manager (Bookmarks > Show All Bookmarks).
    You can use an USB stick to transfer the saved bookmarks file to the new computer.<br />
    You can also copy the places.sqlite file from that computer to have the bookmarks and the history.
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox
    *http://kb.mozillazine.org/Backing_up_and_restoring_bookmarks_-_Firefox

  • In a adress board the website is not saving, when i clink on arrow in a panel board this is blank

    In a adress board the website is not saving, when i clink on arrow in a panel board this is blank

    The only difference I see between looking your site between Firefox and IE is that Firefox is slightly less tolerant of a narrower window than IE but I don't see parts
    missing they may be covered up but that happens on both browsers where the picture overlays wording down left side.
    I can't really tell whether you are saying Firefox or IE is missing parts, but they look the same to me. First time looked it like Firefox was missing portion but it was just dropped down for some distance text and pictures were not missing.

  • Hello I have a mac book pro (lap top) and it's version is 10.6.8.i want to up grade it to 10.9.2. version .i downloaded version from apple store twice and it is un able to installing; give me error massage of installing.the error has not any number and it

    Hello
    I have a mac book pro (lap top) and it’s version is 10.6.8.i want to up grade it to 10.9.2. version .i downloaded version from apple store twice and it is un able to installing; give me error massage of installing.the error has not any number and it says :installation can not be complete with a red sign. please say the solution.also how i can get  the 7.0.0. version up date from apple store . i searched very much but i did not find the version .

    What MacBook Pro model do you have?  Check the apple, left side of the menu bar, About This Mac, More Info, System Report, Hardware and then the Model Identifier...has to be at least MacBook Pro3,1 to install Mavericks.

  • DPM encountered a retryable VSS error. (ID 30112 Details: VssError:The writer experienced a transient error. If the backup process is retried, the error may not reoccur. (0x800423F3))

    I got this error, how to fix it?
    DPM 2010 with latest roll-up (KB2615782) | DELL Server R710 (Windows 2008 R2 SP1) RAM: 24GB PF: 36-60GB | DELL TL4000 (4 Drives) | DELL TL2000 (2 Drives) | And still struggling and monitoring... Battle continues... life never happy ever after.. :(

      In Hyper-v, I have this errors: 
    List Writers
    Writer name: 'Microsoft Hyper-V VSS Writer'
       Writer Id: {66841cd4-6ded-4f4b-8f17-fd23f8ddc3de}
       Writer Instance Id: {52a247b1-bd8e-499c-915d-314f9080e993}
       State: [11] Failed
       Last error: Retryable error
    Eventvwr:
    SOURCE: VSS ID: 8229
    A VSS writer has rejected an event with error 0x800423f3, The writer experienced a transient error.  If the backup process is retried,
    the error may not reoccur.
    . Changes that the writer made to the writer components while handling the event will not be available to the requester. Check the event log for related events from the application hosting the VSS writer. 
    Operation:
       PostSnapshot Event
    Context:
       Execution Context: Writer
       Writer Class Id: {66841cd4-6ded-4f4b-8f17-fd23f8ddc3de}
       Writer Name: Microsoft Hyper-V VSS Writer
       Writer Instance ID: {52a247b1-bd8e-499c-915d-314f9080e993}
       Command Line: C:\Windows\system32\vmms.exe
       Process ID: 2460
    SOURCE: HYPER-V-VMMS ID: 10143
    Failed to delete the shadow copy (VSS snapshot) set with id '3ED86740-3BFC-4FD5-B6B6-5ADD63E87DB0' in the running virtual machine 'MACHINENAME': This operation returned because the timeout period expired. (0x800705B4). (Virtual machine ID E130C3C7-D2BC-4234-BD2A-766054A163F9)

  • HT4009 Unfortunately, I keep getting the error "can not connect to iTunes. Code:0" I've tried rebooting, signing out of my apple ID, can someone please help or advise me on what to do? Many thanks, Ryan

    Unfortunately, I keep getting the error "can not connect to iTunes. Code:0" I've tried rebooting, signing out of my apple ID, can someone please help or advise me on what to do? Many thanks, Ryan

    hi i had the same problem today when i updated my itunes to latest version. however, i have just found my songs in the 'itunes media' folder. this was accessed through 'my music'  then keep clicking through until you find itunes media and all my library songs were in there and i then just added these files to my library and all were restored however, i have lost all my playlists but at least my 700 songs are back. very dissapointed with apple that they have let this happen with their latest update, the previous version was miles better than this one . hope you find them. stevo

Maybe you are looking for

  • IPod Nano 6G Case

    Hi, I just received my replacement iPod Nano.  I had a generation one and now Apple replaced it with a generation six.  I want to use this for when I go to the gym. I purchased the arm band for my G1, but the G6 is a lot smaller. I'm looking for two

  • Is there a limit to the number of plugins you can install in PS CC

    I have installed 5 which I can see but the last teo I installed are not visible!

  • Which trigger is best to validate list item

    Dear all, I have one form. Inthis form I have one list item named occupation_status.I have one text field called "Age". In the occupation_status property palette I set the "elements in the list" as follows List Elements: Professional Student Housewif

  • Wifi not working after 2.0.1 Update

    I can connect to facebook and apps. But not the itunes store or safari. anyone else?

  • Failing to install sapgui

    Dear all i have an HP compaq 6720s after finishing installing sapgui its reporting a number of errors which shows that its failing to register some dll and ocx files to the os which is windows Xp. i hve installed different sapgui but its the same err