Lost and Confused

I am trying to understand arrays.
Where do you declare an array?
I understand that an array is basically a container of like items/objects, but how do I fill the container? How do I get the information into the array? If I don't know the information before hand how do I put it in the array? If I have to be specific and put the information in the array then why do I need an array?
If I have a main that works, and I have a class that works how do I add an array to make the application hold more than one item and then print out the multiple items?
In my mind the application should simply use the loop to gather the information then print out the information when the loop reaches it's end.
All the examples I have found basically show the same thing, just the part of the code that declares the array.
What the example do not show is how the declaration applies to an application.
I'm getting nowhere fast, except more confused and frustrated :-(

petes,
You helped me work out a problem before :-) If you are not a teacher, you would make an excellent one!
Turing, I read your link as well!
I don't know why I can't figure this array part out. It all reads like it should be obvious, but I'm going from bad to worse! I went from 12 errors to 1 error to 22 errors!
I'm already late on the assignment, that isn't my main objective now. I want to KNOW what I'm doing wrong. It has to be something I can fix. Something I am just not getting.
//Inventory Program Part 1
//Inventory enters and displays Part information
//for product inventory
*Parts used for testing include Glass Break: part # FG730,
*Motion Detector: part# Aurora, and W/L Contact: part # 5816.
*any quantity for units on hand and unit price is appropriate
*for testing purposes.
import java.util.Scanner;    // program uses class Scanner
import java.text.*;
public class Inventory
private static void Quit()
         System.out.println("Goodbye");
     System.exit (0);
    // main method begins execution of Java application
     public static void main(String args[])
                 // create Scanner to obtain input from command window
        Scanner input = new Scanner(System.in);
     while(true)// starts loop to test name
             System.out.print("\nEnter Part Name (stop to quit):  "); // prompt for name
                   part.setName(input.nextLine());   // get name
          if(part.getName().compareToIgnoreCase("stop") == 0)
                 System.out.println("Stop entered, Thank you");
                 Quit();
                 } //end if
        System.out.print("Enter part number for " + part.getName() + ":  ");  // prompt
                   part.setitemNum(input.nextLine());    // read part number from user
        System.out.print("Enter Units on hand: ");    // prompt
                   part.setunits(input.nextDouble());    // read second number from user
     if(part.getunits() <= 0)
                  System.out.println ("Invalid amount, Units on hand worked must be positive");
                  System.out.print("Please enter actual units on hand: ");
                    part.setunits(input.nextDouble());
                  } //end if
     System.out.print("Enter Unit Price: $ ");    // prompt
                   part.setprice(input.nextDouble());    // read third number from user
     if(part.getprice() <= 0)
                  System.out.println ("Invalid amount, Unit Price must be positive");
                  System.out.print("Please enter actual unit price: $ ");
                       part.setprice(input.nextDouble());
                  } //end if
     String fmtStr = "\n%-7s %-10s %12s %12s %12s\n";
     System.out.printf(fmtStr, "Part #", "Part Name",
           "Units On Hand", "Unit Cost", "Total Cost");
      for(int i = 0; i<5; i++)
         part[] Partarray = new part[5];      // allocates memory for 5 strings
         part[0] = "Glass Break"; // initialize first element
         part[1] = "Motion"; // initialize second element
         part[2] = "Keypad"; // etc.
         part[3] = "W/L Contact";
         part[4] = "Contact";
          System.out.println("Element at index 0: " + part[0]);
          System.out.println("Element at index 1: " + part[1]);
          System.out.println("Element at index 2: " + part[2]);
          System.out.println("Element at index 3: " + part[3]);
          System.out.println("Element at index 4: " + part[4]);
     }//end for
        }//end while
    }//end main
}// end class Inventory
// Class Part holds Part information
class Part
   private String name;
   private String itemNum;
   private double units;
   private double price;
   //default constructor
    public Part()
        name = "";
        itemNum = "";
        units = 0;
         price = 0;
    }//end default constructor
     //Parameterized Constructor
    public Part(String name, String itemNum, double units, double price)
         this.name = name;
         this.itemNum = itemNum;
         this.units = units;
         this.price = price;
    }//end constructor
     public void setName(String name) {
         this.name = name;
        String getName()
            return name;
    public void setitemNum ( String itemNum )
        this.itemNum = itemNum;
    public String getitemNum()
     return itemNum;       }
     public void setunits ( double units )
         this.units = units;
     public double getunits()
          return units;
     public void setprice ( double price )
         this.price = price;
     public double getprice()
     return price;
     public double getvalue()
     return (units * price);
}//end Class PartAnd the original code I started from, which works beautifully......
//Inventory Program Part 1
//Program enters and displays part information
//for product inventory
import java.util.Scanner;    // program uses class Scanner
import java.text.*;
public class Inventory1
private static void Quit()
        System.out.println("Goodbye");
     System.exit (0);
    // main method begins execution of Java application
    public static void main(String args[])
        Part part = new Part();
        // create Scanner to obtain input from command window
        Scanner input = new Scanner(System.in);
     while(true)// starts loop to test name
             System.out.print("Enter Part Name (stop to quit):  "); // prompt for name
                   part.setName(input.nextLine());   // get name
             if(part.getName().compareToIgnoreCase("stop") == 0)
                System.out.println("Stop entered, Thank you");
                Quit();
                } //end if
                System.out.print("Enter part number for " + part.getName() + ":  ");  // prompt
                 part.setitemNum(input.nextLine());    // read part number from user
                 System.out.print("Enter Units on hand: ");    // prompt
                part.setunits(input.nextDouble());    // read second number from user
                         if(part.getunits() <= 0)
                                System.out.println ("Invalid amount, Units on hand worked must be positive");
                                System.out.print("Please enter actual units on hand: ");
                                part.setunits(input.nextDouble());
                           } //end if
          System.out.print("Enter Unit Price: $ ");    // prompt
                part.setprice(input.nextDouble());    // read third number from user
                         if(part.getprice() <= 0)
                                System.out.println ("Invalid amount, Unit Price must be positive");
                                System.out.print("Please enter actual unit price: $ ");
                                part.setprice(input.nextDouble());
                           } //end if
          System.out.printf("\n%s    %s       %.2f    %.2f      %.2f\n", part.getitemNum(), part.getName(), part.getunits(), part.getprice(), part.getvalue());
input.nextLine();
          }//end while
     }// end method main
} // end class Inventory
// Class Part holds Part information
class Part
   private String name;
   private String itemNum;
   private double units;
   private double price;
   //default constructor
    public Part()
        name = "";
        itemNum = "";
        units = 0;
         price = 0;
    }//end default constructor
    //Parameterized Constructor
    public Part(String name, String itemNum, double units, double price)
        this.name = name;
        this.itemNum = itemNum;
        this.units = units;
         this.price = price;
    }//end constructor
     public void setName(String name) {
        this.name = name;
       String getName()
          return name;
    public void setitemNum ( String itemNum )
        this.itemNum = itemNum;
    public String getitemNum()
          return itemNum;
    public void setunits ( double units )
        this.units = units;
    public double getunits()
          return units;
    public void setprice ( double price )
        this.price = price;
    public double getprice()
          return price;
    public double getvalue()
          return (units * price);
}//end Class Part

Similar Messages

  • Utterly and totally LOST and CONFUSED getting IE10 in Server 2012 x64 to work

    I am at my wits end, I believe I posted in here before but am still having tons of problems with IE10 and Server 2012 x64. Can someone shed some light on ANY of the following:
    1)Is IE10 embedded with flash player by default or not? If so what version?
    2)If IE10 is embedded with flash player how do I get it to consistently work and show the flash player test movie from Adobe's site instead of a gray box (following steps on site does NOTHING to fix issue)?
    2b) I have had some success simply changing the following security settings for the Internet Zone in Security:
    Settings>Internet Options>Security>Internet Zone, click custom level> Active X Controls and Plugins> Script ActiveX controls marked safe for scripting: enable
    Settings>Internet Options>Security>Internet Zone, click custom level> Scripting> Active Scripting: enable
    on some machines the above works and I see a flash movie, other machines not.
    3)What is the shockwave flash object in my add-ons for IE? Some machines have this and some don't. Was it installed by default or installed manually? I cannot install this on non working machines where it is missing as the install page from adobe (get.adobe.com/flashplayer) says there is nothing to install since IE 10 should have flash player embeded by default. (it says flash player is integrated with Windows Explorer in Windows8. You do not need to install Flash Player and the bottom of IE says an add-on for this website failed to run).
    This is a NIGHTMARE process that doesn't work and is pathetic. Can someone please steer me in the direction to get this simple POS to work? Something that should work by default doesn't, and then should take no more than 10 minutes is wasting hours of my time.

    Hi,
    The RoboHelp 10 API should work for WebHelp created with RoboHelp 9. Since the RH10 API will now support Multiscreen HTML5 (introduced with RoboHelp 10), I imagine it will work with VS 2012. But I’ve not tried that. You can try the RH10 API, but Adobe won’t support it
    Alternatively: A colleague of mine created a custom C# API some time ago. That might work for you: http://www.wvanweelden.eu/blog/2012/08/03/custom-webhelp-apis
    Greet,
    Willam

  • Lost and Confused about Ipod!!!

    I have a first or second gen older ipod. i set up an itunes account on my boyfriends computer and purchased 10 songs on it. i put them onto my ipod and then his computer fried. so i have a new computer now and i re set up my account and i was wondering if i could get those songs off my ipod back into my library since i did purchase them?

    Plug it in and use the Transfer Purchases function, either from the resulting dialog box or from the File menu. If you need to authorize the computer, choose it from the Store menu.
    (65603)

  • Totally lost and confused

    I have no clue what I am doing here and I am hoping that someone can explain to me what I did wrong.
    I have an iPad, AppleTV and iMac. I purchased two seasons of a tv show, one through my iPad and one through AppleTV. I have home share turned "on" for all three of these. When I purchased one season on my ipad I was able to watch it on appleTV, however the second season I purchased I haven't been able to.
    What am I doing wrong? I have spent the better part of the morning trying to figure it out and I have no idea. I just want to have the flexibility of being able to watch these shows on my AppleTV or my iPad. I am able to do that right? Or where I purchase it from is where I can watch it from?
    I can't add the shows to my ipad through iTunes for some reason. If I sync the shows to my ipad it says that I will lose the previous library ... what does that mean and if I have no shows on there now, does it matter?
    I am getting so frustrated with this ...
    Any help would be so appreciated!!!
    Thank you!

    hi Sammy!
    unfortunately, you won't be able to burn that to a DVD in a form that can be read by a DVD player. for some more info, see:
    iTunes Music Store video FAQ
    do you have an ipod? if so, you can plug that into the TV (if you have the right kind of cable). for some info on that, see:
    Frequently asked questions about viewing and syncing video with iTunes and iPod
    love, b

  • I  used to have an OLD Photoshop cd but it has been lost and my program is no longer on cd. I talked with some photographer friends and this is what one of them told me to get: Adobe Photoshop Lightroom and CS CC... HELP please?

    I  used to have an OLD Photoshop cd but it has been lost and my program is no longer on cd. I talked with some photographer friends and this is what one of them told me to get: Adobe Photoshop Lightroom and CS CC... HELP please?

    If you still have your serial number, look at OLDER previous versions http://www.adobe.com/downloads/other-downloads.html
    Otherwise, the US$ 9.99 plan is what is current at Cloud Plans https://creative.adobe.com/plans

  • Trying to create a new movie.  It tells me to name my movie, and the only event choice is the last movie I made.  I don't want it there.  I'm lost and I'm just starting.  Not sure I like the new version.  Any help out there?

    I'm trying to create a new movie.  It tells me to name my movie, and the only event choice in the drop down menu is the last movie I made. IMovie Library is greyed out. I'm lost and I'm just starting.  Not sure I like the new version.  Any help out there?

    peggy818 wrote:
    … I'm lost and I'm just starting.  Not sure I like the new version.  …
    have a read in the Manual:
    http://help.apple.com/imovie/mac/10.0/?lang=en#mov755717b21

  • 've Password job a year ago to Mobil iPhone 4, and now lost and I can not wipe data from the device or transferred to the new device .. What do I do?

    've Password job a year ago to Mobil iPhone 4, and now lost and I can not wipe data from the device or transferred to the new device .. What do I do?

    iPhones require a SIM for activation.
    Put the device in DFU mode (google it) and restore via iTunes.

  • How do i run an external monitor with my macbook and change settings so that when i close the lid the signal to the monitor is not lost and i can continue using the mac with a mouse and a wireless keyboard?

    How do i run an external monitor with my macbook and change settings so that when i close the lid the signal to the monitor is not lost and i can continue using the mac with a mouse and a wireless keyboard?

    No, nothing will prevent the computer from going to sleep when you close its display except third-party hacks that are designed to do exactly that. I strongly advise against using any of those, as they may interfere with successful entry into clamshell mode (and they carry other downside risks as well). Just wait until the computer is asleep (with its sleep light pulsing), then press any key on the keyboard. It sounds as though your setup is working as it's designed to do.

  • When I recently updated FireFox, the DownloadHelper add-on was lost, and will now not download, though I have tried about 5 times??

    When I recently updated to the newer version of FireFox, (version 3.6.13) the DownloadHelper add-on was lost, and it will now not re-install, though I have tried about 5 times?? When I clicked the icon to download the add-on the download progress bar indicated that the download was underway however, when it had completed, the add-on appeared not to have downloaded - including no icon - not even if I search for one. When I tried to download the same add-on again, the download window indicated the download in a faded color and it seemed to be indicating that I already had the add-on. Try as I might, I can't get it to work. DownloadHelper always worked with no trouble on the previous version of FireFox. Are you able to help? Many thanks for this service!

    Delete the files extensions.* (extensions.rdf, extensions.cache, extensions.ini, extensions.sqlite) and compatibility.ini in the Firefox [[Profiles|profile folder]] to reset the extensions registry. New files will be created when required.
    See "Corrupt extension files": http://kb.mozillazine.org/Unable_to_install_themes_or_extensions
    If you see disabled, not compatible, extensions in "Tools > Add-ons > Extensions" then click the "Find Updates" button (Firefox 4: click the Tools button at the left side of the Search Bar) to do a compatibility check.
    You can also try "Reset all user preferences to Firefox defaults" on the [[Safe mode]] start window.
    * http://kb.mozillazine.org/Resetting_preferences
    * http://kb.mozillazine.org/Preferences_not_saved
    * http://kb.mozillazine.org/Corrupt_localstore.rdf

  • HT5622 How do I change the Apple id against a certain telephone number?  I have two iPhones and wish to use a different Apple id for each and confused as to how I do this?

    How do I change the Apple id against a certain telephone number?  I have two iPhones and wish to use a different Apple id for each and confused as to how I do this?

    Create a new Apple ID for the second phone. If you are setting the phones up as new phone enter the ID you want to use on each phone.
    If both phones are already signed in to one Apple ID then use the settings app to change Apple IDs on one phone.
    Settings > iTunes and App Store > tap on the Apple ID > sign out > sign in with alternate Apple ID.
    Note that if you have downloaded apps with the original Apple ID on the phone with the new Apple ID, those apps will still be associated with the old Apple ID and will require the old ID and password in order to update them.

  • I have a problem with my iphone 4. My 3G always stays activated but I lose my network signal. The bars all get lost and I'm not able to receive / send sms, mms or phone calls. Could you guys please help me fix this problem? Ios 5.1.1

    I have a problem with my iphone 4. My 3G always stays activated but I lose my network signal. The bars all get lost and I'm not able to receive / send sms, mms or phone calls. Could you guys please help me fix this problem? Ios 5.1.1

    I haven't gotten a new sim card because the problem has been presenting itself in various cards not only mine. So far, all I've done is reset my network settings.
    Last night, I turned off the 3G tab and it had all the signal bars. Today, I did the network reset and it's working apparently. But like I said before, previously the bars just disappear and the iphone only has the 3G activated.

  • My new events no longer show up in Events, since I upgraded to iPhoto 11 at the end of March. The number of events goes up, but they no longer show. The photos are in my photo place all right, but everything is getting every messy and confusing. Help!

    I upgraded to iPhoto 11 from iPhoto 08 at the end of March, 2012. Since then, although all my photos appear in the library,and the number of events tally goes up, no new events show up in Events. My iPhoto is getting very mess and confusing. I have checked preferences, and they are the same as what I always had (one event/day)

    Go into the Event mode and set the View ➙ Sort menu option to By Date, either ascending or descending, and look for the new events at the top or bottom of the list.
    You can view the last import in the Last Import section and then Control (right) click on one of the photos and select Show Event.  That will take you to the event where you can rename it at the top and then check to see where in the list it is placed.
    OT

  • Design Question: Can I use Rest-CsPoolRegisterState command in order start Front End Service when Quorum is lost and less than 85% of FES are available?

    Hi, 
    Assuming below setup for Enterprise edition Lync 2013
    Single Pool Stretched architecture with 4 FES servers
    Site A Data Center
    Site B Data Center
    FES
    2
    2
    SQL
    1 Primary
    1 Mirror
    Fact: In a situation when we lose network connectivity to Site A DC, and due to less than 50% FES servers, Quorum will be lost and as a result Front End Service will stop after 5 minutes. 
    The question is, would I be able to do a manual intervention by using this command
    Reset-CsPoolRegistrarState –PoolFqdn <pool name fqdn> –ResetType QuorumLossRecovery , and start FES with just 2 FES servers in Site B DC and 1 SQL
    Server?
    The reason I am asking this question is because it is mentioned in one of the Lync manuals that at least 85% of the servers must be available to recover once the Quorum has lost. The same manual also mentions to use above
    mentioned command in order to recover from Quorum Loss despite the fact that the lost FES servers are still not available.
    Thanks in Advance

    Hi,
    In Lync server 2013 Stretched pools are not supported for the Front End, Edge, Mediation, and Director server roles. It need two Lync pools.
    If one pool fail to connect, An administrator can declare an emergency and fail over the pool to the backup pool.  That is done by using the:
    Invoke-CsPoolFailover –PoolFQDN <Pool fqdn> –DisasterMode –Verbose
    More details:
    http://blog.avtex.com/2012/07/26/understanding-lync-2013-server-failover/
    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information
    found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
    Best Regards,
    Eason Huang
    Eason Huang
    TechNet Community Support

  • My email has been lost and I can't connect to it can you help me please

    In the last twenty four hours I have not been able to receive email .
    A message would say that my password or email address was wrong
    I have repeatedly tried turning my email off and on  Now i am really lost and I need my email to be on because of school and communitcation with my professor please help

    How did you turn your email on and off?

  • I need to download all of my photos from my iPhone 4S and my iPad 2 to my MacBook Air. I want to make sure all my photos are not lost and that they do not return to the original devices because of the cloud. Can someone please help ?

    I need to download all of my photos from my iPhone 4S and my iPad 2 to my MacBook Air because there is no more storage space available. I want to make sure all my photos are not lost and that they do not return to the original devices because of the cloud. Can someone please help ?

    Connect your devices to the computer with the USB cable (one device at a time) and import the photos via iPhoto or Image Capture.
    If you have not changed any default settings on your computer, iPhoto will automatically launch when you plug in the device. Then follow the import prompts.

Maybe you are looking for

  • Order of Object Creation

    I need to know what order various objects are created and processed. An example will be most helpful. class A { A() { myFunc();    } public void myFunc() {} class B extends A { class innerB {       public void funcInnerB() { ... do some work ...     

  • Real HW S-ATA Raid card support in Solaris 10 x86?

    I am trying to find an SATA RAID controller (real HW raid, not the pseudo raid that comes on many mb) that works with Solaris 10 on x86. I thought maybe the LSI MegaRAID SATA 150-4 might. Solaris has an amr driver ported from FreeBSD according to the

  • Purchasing Report

    The following statement has to show the po header and Invoice lines information. The po header amount should be equal to the sum of Invoice lines amount. For example for one PO of $100 there are 3 different invoices $20 $30 $50. Originally the PO amo

  • RGZPFM stopped working after OS upgrade to V5R4 from V5R3

    Hi Guys, We recently upgraded the operating system on our DEV & TEST boxes from V5R3 to V5R4. Before the upgrade, we used to use the program ZRGZPFM attached in  SAP note number: 84081 Reorganization of database tables (RGZPFM)  for Re-Organizing the

  • No Title on Spine???

    I created and ordered a book through iPhoto last year and the title is on the spine of the book automatically. This year, I created a 2nd book with photos from 2010 and there is no title on the spine? Is there a way to add it? Is there a way to get a