Using an array to read from and write to files

my problem is, I do not know how to do this program, it's like an inventory warehouse program that uses an array to store the items, then I have to use a keyboard input to run through the program the first time, using a write method to save the file, and a read method to go through the program a second time and resave it to a different file with the write method, I've asked countless times for help, but the instructor just won't help, so I was hoping I could get some help here, and if I don't get this done, I'm going to end up failing the class.
also, the requirements are listed here as well, so it can be better understood.
Write a program that:
1. allows the user to choose whether the inventory data comes from a file or from the keyboard
2. allows for up to 20 inventory items
3. if the data comes from the keyboard, asks for all inventory information (item name, number in stock,
initial warehouse, and value of one item)
4. if the data comes from a file, displays the inventory information for the item.
5. for each item, asks the user how many items to add or delete from inventory
6. determines whether an item must be moved to a different warehouse and changes the location if
necessary (note, it may be necessary to move an item to a smaller warehouse)
7. once all inventory changes have been made, for each warehouse displays the items in the warehouse, the
total number of items in the warehouse, and the total value of the items in the warehouse.
8. once all inventory changes have been made, stores the item information in a file (which can be used for
the next program run)
9. asks the user for the names of the input file (if data is coming from a file) and the output file (always).
p.s. I can post the source code for it if it's required for the help.
Thanks,
Xandler

my specific question is how I would go about using the scanner utility to tell it to input from the file or keyboard, if from keyboard it's manually item information is done manually, if from file it asks the user for the file name and the user selects it, then it saves it to a file, can't really post what I've tried because that's the problem, I don't know how to go about doing it and the instructor won't help me, I know though that it requires a file read method for the 2nd run, and a keyboard input for the first and a write for the saving of the file(s).
Thanks,
Xandler

Similar Messages

  • How to read from and write into the same file from multiple threads?

    I need to read from and write into a same file multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

    Assuming you are using RandomAccessFile, you can use the locking functionality in the Java NIO library to lock sections of a file that you are reading/writing from each thread (or process).
    If you can't use NIO, and all your threads are in the same application, you can create your own in-process locking mechanism that each thread uses prior to accessing the file. That would take some development, and the OS already has the capability, so using NIO is the best way to go if you can use JDK 1.4 or higher.
    - K
    I need to read from and write into a same file
    multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

  • How to read from and write to remote data file?

    Hi there
    I have two variables that I would like to store in a remote data file which can be accessed by my Flash file. It is for a voting system, so the first variable would be a counter that is incremented each time a user votes, and the second would be the total rating. The average rating would then be calculated from these.
    How would one store, retrieve, and then update these variables from the data file?
    I can create the system within a single Flash file for a single session, but obviously I'd like multiple users opening the file simultaneously to be able to access the data and update it.
    I'm using AS2 in CS3. Any help would be appreciated.

    Right, I've made significant progress since I started this topic. I now have my Flash and php files set up, and the communication between them is working. I'm having difficulty now retaining my variables in the php and updating them for the next session. The script that I have is as follows:
    <?
    $totalRating1 += $_POST['latestRating1'];
    $ratingCount1 ++;
    $averageRating1 = $totalRating1 / $ratingCount1;
    echo "&averageRating=$averageRating1";
    ?>
    The first line receives the variable "latestRating1" from the SWF. The new average rating is calculated and returned to the SWF as "averageRating". When I run it, however, the variables are reset each time. The average rating is always the same as the latest rating. How can I retain the variables so that they are updated and available for the next user?
    Any advice would be appreciated. I am very new to php, and don't have any experience with other scripting languages. I'm using ActionScript2.

  • Managed Metadata (Failed to read from or write to database. Refresh and try again. If the problem persists, please contact the administrator)

    When creating a new site column of the managed meta data type in SharePoint2010, and you select "customize your term set", you are presented with one of the following errors:
    - This operation cannot be completed. The term store may be unavailable.
    - Failed to read from or write to database. Refresh and try again. If the problem persists, please contact the administrator

    Hi,
    I have been facing the same issue, however managed to resolve it.
    This is due to the uncommitted statements. From Powershell try running the following script
    #Connect to Central Admin, Replace the url with the environment specific URL
    $taxonomySite = get-SPSite http://centraladmin:40000
    #Connect to Term Store in the Managed Metadata Service Application, Ensure you put the right Metadate service application name
    $taxonomySession = Get-SPTaxonomySession -site $taxonomySite
    $termStore = $taxonomySession.TermStores["Managed Metadata Service"]
    write-host "Connection made with term store -"$termStore.Name
    #Connect to the Group and Term Set
    $termStore.RollbackAll()
    Hope it would help

  • "Can't read from or write to disk...." iPod error

    I recently switched from my old PowerBook G4 (running Leopard 10.5.2) to a newer MacBook Pro (running Leopard 10.5.5). I migrated my account and permissions from the PB to the MacBook Pro, and everything is working just fine except for iTunes (version 8.0.2) and my older 160 GB iPod Classic (running 1.1.2).
    NOTE: THE VERSION OF iTunes ON THE PB WAS VERSION 8.0.1.
    Since the migration, I've been getting this "can't read from or write to disk..." error whenever I attempt to sync my iPod to iTunes. Previously, I'd never had any problems. I have tried to restore the iPod using iTunes - didn't work. I have tried different USB to dock connector cables - didn't work. I have even tried completely re-formatting the iPod using Disk Utility - didn't work. Everytime I begin syncing the iPod, it starts out just fine. At varying degrees of completion it ALWAYS fails with the same error.
    I had an idea. I tried syncing the iPod to a different computer - my G5 4 x 2.5 GHz (running Leopard 10.5.5) with iTunes (version 8.0.2). I still got the same error. I haven't dropped it, submerged it in water or done anything to it that would otherwise compromise its functionality. So, I'm at a loss.
    PLEASE! PLEASE! PLEASE!
    Does anyone have any other suggestions? - OTHER THAN BUYING A NEW IPOD

    UPDATE:
    OK, after the visit to my Genius Bar; I thought of a variable that wasn't previously considered. Because their transfer of media was successful without the slightest hitch, I had to figure out something else.
    Everytime I had tried to sync the iPod with my various Macs, I was using the same process. Since all of my music and movies "live" on an external 500 GB drive, I was attempting to use that same drive whenever I would try to sync. It occurred to me that possibly the failing was in the drive and not the iPod.
    I have part of that library on a Power Mac G4 867 DP (running 10.4.9). I updated the iTunes on that machine to 8.0.2, connected the iPod and made a successful transfer of a large amount of media!
    My only problem now is that I can't figure out how to get the 500 GB drive to stop hanging on transfer and update of my Genius information. The drive just completely stalls and I get the spinning wheel from iTunes and the application ceases to respond. When I force quit iTunes, the drive recovers fine. I don't have any problems transferring data to and from it and Disk Utility reports that the drive is healthy.
    I have tried re-installing iTunes on all affected Macs - didn't help. I believe my problem may exist in the iTunes Library file or in the associated .xml document. My only concern is that if I do a completely fresh install of iTunes where those files would be re-created, I would lose all of my play and ratings data as well as the information about when my files were added. On a related note, when playing the music from this drive through iTunes. I don't have any issues at all.
    ANY SUGGESTIONS?

  • "Unable to read from or write to your play

    When I go to create a playlist with the music that is already on my Zen, this pops up. Why isnt it working? Its probably something really simple that I overlooked... but Im stumped. I came here as a last resort

    I received this same message and came on here to find some help. I am using the new Creative Zen, 6 gig.
    I am using a Windows Vista computer.
    When the player is docked and I am using the Zen Media Explorer, I go to "create playlists"
    The player loads, I can see all of my files and most of my music on the creative playlist wizard. I clicked on one file (containing most of my music) and this message pops up. "Unable to read from or write to your player"
    Any suggestions?

  • "Unable to read from or write to your player" Zen 1

    I have a new Creative Zen 6G and am using Windows Vista. While using the Creative Media Organizer, I tried to create a new playlist. The player shows all my folders, and when I try to open the folder that contains the majority of my music, the message "Unable to read from or write to your player" appears. Does anyone know what this message means or what I have to do to fix it's Thank you-Melissa

    Have you tried adding from a folder rather than iPhoto to see if that makes a difference? Create a folder on your hard drive called called "iPod Photos" or something similar and drag the photos you want on your iPod to it. Under the photo preferences for the iPod, point iTunes to "synchronize photos from" and choose to update from your new folder.

  • How to read the and Write the PDF file give me the solution

    Hi all,
    How to read the and Write the PDF file give me the solution
    My coding is
    import java.io.File;
    import com.asprise.util.pdf.PDFImageWriter;
    import com.asprise.util.pdf.PDFReader;
    import java.io.*;
    import java.io.FileOutputStream;
    public class example {
    // public example() {
         public static void main(String a[])
              try
              PDFReader reader = new PDFReader(new File("C:\\AsprisePDF-DevGuide.pdf"));
                   reader.open(); // open the file.
                   int pages = reader.getNumberOfPages();
                   for(int i=0; i < pages; i++) {
                   String text = reader.extractTextFromPage(i);
                   System.out.println("Page " + i + ": " + text);
    // perform other operations on pages.
    PDFImageWriter writer = new PDFImageWriter(new FileOutputStream("c:\\new11.pdf"));
                   writer.open();
                   writer.addImage("C:\\sam.doc");
                   writer.close();
                   System.out.println("DONE.");
    reader.close();
              catch(Exception e){System.out.println("error:"+e);
              e.printStackTrace();
    I get the pdf content then it returns the string value but ther is no option to write the string to PDF, and we only add a image file to PDF,but i want to know how to wrote the string value to PDF file,
    Please give response immtly
    i am waiting for your reply.
    thanks,
    Suresh.G

    I have some question flow
    How library to use this code.
    I try runing but have not libary.
    Please send me it'library
    Thank you very much!

  • How do I migrate files created in a Windows OS to a new external drive that is formatted as a MAC drive. I want to read and write these files back to the new drive.

    How do I migrate files from an external hard drive created in a Windows OS to a new MAC external drive? I want to read and write these files to the new drive.

    LKrzesowski wrote:
    How do I migrate files from an external hard drive created in a Windows OS to a new MAC external drive? I want to read and write these files to the new drive.
    If all you're trying to do is move the files from the Windows external to the Mac external, you can simply connect them both to the Mac and drag the files from the Windows drive to the Mac drive. If you want to move the files back and forth between them, you'll need to establish the format of the Windows external. Macs can read and write to FAT32 and exFAT (which can handle files larger than 4GB) formatted drives but can only read NTFS formatted drives without additional software. With the Windows drive connected, you can check its format with Disk Utility.

  • Zen - Can't Read from or Write to Your Pla

    I recently bought a Creative Zen and had no problems with the software until recently one day when I was trying to work with a playlist, it said it could not read from or write to my player. I tried a different computer with a different operating system, installed the playlist manager disk on that computer, and got the same result.
    Additionally, when I try to record something, the player freezes up. However, the big issue for me is not being able to manage my playlists at all. I can still download books and tunes and get updates from Creative, so that's not the problem.
    Any help? I looked in the FAQ for this, but the link is broken.

    Try the instructions in this article.
    (24952)

  • I'm trying to share folder between users on a single mac.  I put the folder in "shared," set permissions so other user can read and write, enabled file sharing, but can't find the folder on the second user's account.  Any help?

    I'm trying to share a folder between users on a single mac.  I want both users to be able to read and write so the folder stays current on both accounts.  I put the folder in "shared," set permissions on folder so other user can read and write, enabled file sharing, but can't find the folder on the second user's account.  Any help?

    Did you log out of one account and into the other or just used Fast user switching?
    Is the permissions set to anyone?
    When you move data to teh Shared folder is it copied or just moved?
    If copied then it's not a folder both can access, just a way station like a USB thumb drive that things are coped too and off of likely.
    You can run this #5 on each user account to reset the user permissions once they are taken back out of the Shared folder
    Step by Step to fix your Mac

  • Re: Beginner needs help using a array of class objects, and quick

    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ? In html, I assume. How did you generate the html code of your three classes ? By help of your IDE ? NetBeans ? References ?
    I already posted my question with six source code classes ... in text mode --> Awful : See "Polymorphism did you say ?"
    Is there a way to discard and replace a post (with html source code) in the Sun forum ?
    Thanks for your help.
    Chavada

    chavada wrote:
    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.You think she's still around almost a year later?
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ?Just use [code] and [/code] around it, or use the CODE button
    [code]
    public class Foo() {
      * This is the bar method
      public void bar() {
        // do stuff
    }[/code]

  • How can I use the "Correct camera distortion" filter and process multiple files in PSE 11?

    How can I use the "Correct camera distortion" filter and process multiple files in PSE 11?

    Did you check the help page for Correct Camera Distortion and Process multiple file
    Correct Camera Distortion: http://helpx.adobe.com/photoshop-elements/using/retouching-correcting.html#main-pars_headi ng_5
    Process multiple files: http://help.adobe.com/en_US/photoshopelements/using/WS287f927bd30d4b1f89cffc612e28adab65-7 fff.html#WS287f927bd30d4b1f89cffc612e28adab65-7ff6

  • Read and write from and to text file

     Hi All,
    I am trying to read some portion of a text file and make measurement and calculation with those numbers and write back to the same text file and also to a excel file. I need to create a 2 D  array of 20 by 20 from the text file values and write to front panel table and to text file. but I am having problem with it, obviously I am new to this. Please help me.  thanks much
    ~ Johnny

    Hi Lynn,
    the requirement is to move C1 and C2 to each position that is given in the text file in steps and percentage value.
    for example C1 has to go to first step (5%) and C2 has to go thru all steps, 5% to 95% , in 5 percent increment. 
    each 100 steps translates to 1 percent increment in the capacitor value.
    at the end, I need to enter the measured data (values of C1 for each step, vesus all values of C2 for all steps) and enter them at the bottom of the text file's table where it starts at : "IMPEDANCE_REAL in Ohmone line per C1 position, containing all values for the different C2 positions" and do the same for where it says "IMPEDANCE_IMAGINARY in Ohmone line per C1 position, containing all values for the different C2 positions"
    the reason I read the file twice, is that if it read it once, I couldn't connect it to spreadsheet string to array vi.
    as you can see, I also like to use the write to measurement file and build table express vi's to display the table on the front panel and save the data to ni data file format so later I convert it to excel  too.
    any thoughts?
    thanks for your help
    ~ Johnny
    Attachments:
    read from text2.vi ‏82 KB

  • How to read and write(a file .txt) from a URLConnection

    I try to read and write on one URLConnection. Is it possible ? How can i make it ?
    The reading part of my application work's but not the writting part
    That's a part of rhe code that i use to write :
    String Line = "Hi";
    MyUrl = new URL(this.getCodeBase(), FichierEvenement) ;
    Con = MyUrl.openConnection() ;
    Con.setDoOutput(true);
    Con.setDoInput(true);
    Con.setUseCaches(false);
    Dos = new DataOutputStream(new BufferedOutputStream(Con.getOutputStream( )));
    Dos.writeUTF(Line);
    Please help me :)

    What are you doing with the bytes written to the OutputStream? This info would help, but i do have a suggestion. I ran into this problem when trying to write strings using writeUTF. The output was all screwed up. So, maybe change your string to a character array. That way Unicode is displayed properly. This in conjunction with writing to an .html file instead of to the connection itself might work.

Maybe you are looking for

  • Conversion of Sales Orders with Original ATP Confirmation Dates/ Quantities

    Hi Please suggest best practice to maintain ATP confirmation dates/ quantities during sales order conversion. We have committed schedule lines in a legacy SAP system. Now we want to maintain the exact same dates/ quantities when loading these dates i

  • Disk can't be found

    This morning I saw the Time Machine icon in the menu bar it had an exclamation mark. So I click on the icon and a message appear saying: "Your Time Machine backup disk can't be found." I open a Finder window and click on Shared>Time Capsule>Data and

  • Where is the UTL_SMTP file found in the database?

    Hi, I would like to know where the UTL_SMTP file is located in the oracle database? How is this file configured to send email? Thanks in advance.

  • TV episodes marked as movies

    As a bit of background, I have two drives one with my media on and the other with a backup of said media. The backup is simply a copy which uses the modified date to determine if a newer version needs to be copied. The problem I have is that when I a

  • Dynamic Table display Horizontally??

    Is there any relatively easy way to make a DW CS3 Dynamic Table display horizontally? So far the best I can figure out is to do multiple <cfoutput query= lines per: <table border="1"> <tr> <cfoutput query="rsOfficeStyles" startRow="#StartRow_rsOffice