Having compiler issues with Array, can anyone help please?

Using your Invoice class created in lab02, write a client program that allows the user to input three Invoice objects into an array of Invoice objects. After you have inputted all of the invoices, print a heading and then output all of the array elements (Invoice objects) by calling the method from your Invoice class that displays all of the data members on a single line using uniform field widths to insure that all Invoice objects will line up in column format (created in Lab04). At the end of the loop, display the calculated total retail value of all products entered in the proper currency format.
Example of possible program execution:
Part Number : WIDGET
Part Description : A fictitious product
Quantity : 100
Price          : 19.95
(etc.)
Example of possible output
Part Number          Part Description          Quantity          Price     Amount
WIDGET          A fictitious product     100          19.95     199.95
Hammer               9 pounds          10          5.00     50.00
(etc.)
Total Retail Value:                                   249.95
This is what I have so far at the bottom, can anyone tell me what I'm doin wrong please
//Invoice Lab 6
//Application to test class Invoice with arrays
public class InvoiceTest
public static void main( String args[] )
Invoice invoice1 = new Invoice( "1234", "Hammer", 2, 14.95 );
Invoice array [] = new Invoice [2];
array [0] = new Invoice ("1234", "Hammer", 2, 14.95);
array [1] = new Invoice ("5678", "PaintBrush", -5, -9.99);
double total = 0.0;
System.out.println("Part Number                    Description               Quantity          Price               Amount");
System.out.println("----------------------------------------------------------------------------------");
for (int i=0; <=2; i++)
total+=array.getPaymentAmount();
     system.out.println("The Total retail value is: %.2f\n")
// display invoice1
System.out.println( "Original invoice information" );
System.out.printf( "Part number: %s\n", invoice1.getPartNumber() );
System.out.printf( "Description: %s\n",
invoice1.getPartDescription() );
System.out.printf( "Quantity: %d\n", invoice1.getQuantity() );
System.out.printf( "Price: %.2f\n", invoice1.getPricePerItem() );
System.out.printf( "Invoice amount: %.2f\n",
invoice1.getInvoiceAmount() );
// change invoice1's data
invoice1.setPartNumber( "001234" );
invoice1.setPartDescription( "Blue Hammer" );
invoice1.setQuantity( 3 );
invoice1.setPricePerItem( 19.49 );
// display invoice1 with new data
System.out.println( "\nUpdated invoice information" );
System.out.printf( "Part number: %s\n", invoice1.getPartNumber() );
System.out.printf( "Description: %s\n",
invoice1.getPartDescription() );
System.out.printf( "Quantity: %d\n", invoice1.getQuantity() );
System.out.printf( "Price: %.2f\n", invoice1.getPricePerItem() );
System.out.printf( "Invoice amount: %.2f\n",
invoice1.getInvoiceAmount() );
Invoice invoice2 = new Invoice( "5678", "PaintBrush", -5, -9.99 );
// display invoice2
System.out.println( "\nOriginal invoice information" );
System.out.printf( "Part number: %s\n", invoice2.getPartNumber() );
System.out.printf( "Description: %s\n",
invoice2.getPartDescription() );
System.out.printf( "Quantity: %d\n", invoice2.getQuantity() );
System.out.printf( "Price: %.2f\n", invoice2.getPricePerItem() );
System.out.printf( "Invoice amount: %.2f\n",
invoice2.getInvoiceAmount() );
// change invoice2's data
invoice2.setQuantity( 3 );
invoice2.setPricePerItem( 9.49 );
// display invoice2 with new data
System.out.println( "\nUpdated invoice information" );
System.out.printf( "Part number: %s\n", invoice2.getPartNumber() );
System.out.printf( "Description: %s\n",
invoice2.getPartDescription() );
System.out.printf( "Quantity: %d\n", invoice2.getQuantity() );
System.out.printf( "Price: %.2f\n", invoice2.getPricePerItem() );
System.out.printf( "Invoice amount: %.2f\n",
invoice2.getInvoiceAmount() );
} // end main
} // end class InvoiceTest

Change this (check my comments):
for (int i=0; <=2; i++) // what is <=2??  check the fixed version
total+=array.getPaymentAmount(); //two things 1) this needs to be inside the for-loop 2) you need to tell the array which index to look at
system.out.println("The Total retail value is: %.2f\n") //no need for \n because println does it automagically
}to this:
for(int i=0; i<array.length; i++) {
    total += array.getPaymentAmount();
System.out.println("The total retail value is: " + total); //if you need another blank line like above be my guest
Honestly, I didn't look past this part so fix this and post again if something is still broken.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • My iMac 24 can no longer be paired with the keyboard; it doesn't recognise any keyboard at boot up, even the one it is paired with. Can anyone help, please?

    My iMac 24 can no longer be paired with the keyboard; it doesn't recognise any keyboard at boot up, even the one it is paired with. Can anyone help, please?
    Thank. Simon

    Brian - The batteries are fine and there has only every been one keyboard paired with it. We have tried my MacPro keyboard as well, and it will not even recognise that there is a discoverable keyboard nearby.
    Thanks, Simon

  • TS3510 Can't receive emails or messages with FaceTime can anyone help please thanks

    Can't receive emails or messages with FaceTime can anyone help please thanks

    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting
    http://tinyurl.com/a7odey8
    Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268
    iOS: About Messages
    http://support.apple.com/kb/HT3529
    Set up iMessage
    http://www.apple.com/ca/ios/messages/
    Troubleshooting Messages
    http://support.apple.com/kb/TS2755
    Setting Up Multiple iOS Devices for iMessage and Facetime
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l
    FaceTime and iMessage not accepting Apple ID password
    http://www.ilounge.com/index.php/articles/comments/facetime-and-imessage-not-acc epting-apple-id-password/
     Cheers, Tom

  • HT201210 once again my iphone not working. i have a usb sign pointing to an itune icon on the screen. this is been on for over 24 hours. tried to restore but keeps coming up with era can anyone help please

    once again my iphone not working. i have a usb sign pointing to an itune icon on the screen. this is been on for over 24 hours. tried to restore but keeps coming up with era can anyone help please

    What is the error that is occurring?  We are not mind readers.

  • HT1212 hi my daughter has disabled her iphone 4 and its never been synced with itunes can anyone help please

    hi my daughter has disabled her iphone 4 and its never been synced with itunes can anyone help please

    iOS: Forgotten passcode or device disabled after entering wrong passcode - http://support.apple.com/kb/ht1212 - Learn what to do if you have forgotten or can't remember your passcode, or if your device displays a message saying it is disabled.

  • I'm having a few issues with Safari, can anyone help?

    Hello, all,
    I'm having a few annoying little issues with Safari at the moment, hopefully someone can help and it'll be an easy fix, but I'm stumped at the moment.
    1. Every time I close and quit Safari it freezes and I have to 'force quit' the app. Not the biggest of problems but it's a little annoying.
    2. Once I open Safari back up it reloads with whatever window was open when I quit, even if my Mac has been turned off.
    3. Safari is eating up a lot of my RAM at the moment. 'Activity Monitor' is telling me it's taking up between 2-6GB of Memory.
    Anybody have any ideas?
    Thanks in advance.

    Try a basic Safari reset.
    Safari/Preferences/Advanced - enable the Develop menu, then go there and Empty Caches. Quit/reopen Safari and test. Then try Safari/History/Show History and delete all history items.  Quit/reopen Safari and test. You can also try try Safari/Clear History and Web Site Data. The down side is it clears all cookies.Doing this may cause some sites to no longer recognize your computer as one that has visited the web site.

  • TS3694 My Iphone 4 comes up with "Cannot restore due to Error 21" - have no idea what this is. When I attach a different Iphone to my PC, it updates & does everything properly, no security settings issues either. Can anyone help please?

    My Iphone 4 comes up with "Cannot restore due to Error 21". My security settings are all ok as when I connect another Iphone to my PC, it updates & works fine. Does anyone know what Error 21 means please?

    When you searched Google for "iPhone Error 21" what did you find?

  • I think I have a problem with Mavericks: can anyone help,please?

    A couple of days ago I installed Mavericks on top of my existing Mountain Lion OS. Not before I backed up the ML version with Time Machine, though.... :-)
    Initially I thought everthing was fine, but then started to notice a few things that bothered me, which have not gone away. In fact, I think this install is now a potential problem. Unlike many other people, elsewhere on this forum, I have not noticed the calamitous slowing down and general unusability of Mavericks. I'm using a prety new i7 iMac ( the new flat one) with 32 GB of RAM.Everytihng worked great with Mountain Lion. However, The following anomalies have cropped up: Mail is taking over 30" to send a simple email. In ML it was almost instantaneous. I feel that Mail is not performing as it did in ML, and the same goes for Safari. It "feels" odd and slow and can take an age to load up pages. In fact one particular page would not load properly at all, but worked fine in Firefox. In the end got it to work in Sfari, but ithis type of behaviour doesn't instill confidence. Things got wierder...
    An update to iMovie got " stuck" in the dowload process,and was perpetually downloading in Launchpad. It kept oscillating from approx 61 MB to aprrox 84 MB of a 1.94 GB file. Then I did a disk utiltiy test of my system drive and it suddenly stated that the drive need repairing. I booted up in Recovery Mode and tested the drive, which came back all clear! I booted up normally again and now the disk utility won't even complete a full diagnosis of the drive!It will diagnos all my other drives fine though.... :-s  It keeps getting stuck on: Checking Volume Bitmap, and won't go any further. So, I did what some other person did on another thread, which seemed to clear up his problems; namely: simply reinstalled Mavericks  from Recovery mode. This did not improve anything for me. The same issues remain. In fact as I type this, I notice that I'm using nearly 23 GB of my 32 GB of RAM, and all I have open is Safari, Disk Utility and Mail ! To quote Hans Solo: " I've got a b-a-a-a-d feeling about this..."
    So, this is my long-winded way of asking: what shall I do? I would like to boot in Recovery Mode and reinstall my back up from an external drive. Does anyone have any advice about this,please? If I restore from my backup, will I actually get the ML OS back on the computer, or will  I be stuck with Mavericks trying to impose itself ,as some people reported? I do want to use Mavericks, but not in the condition it's in right now. Also,  really don't want to perfom a clean install and migrate everything over from the Time Machine back up....
    Thanks for any advice.

    I don't think that a software update from Apple will solve the issues that you are having. You have a rogue installation. After you posted I have just done the following:
    Disk Utility can verify  my partitioned Volume (including my boot disk) AND REPAIR the non-boot disks on the same Volume without a glitch. It repairs the non-boot disks containing data smoothly.
    I have used Mail to send some mails from some Yahoo and Hotmail accounts to my Thunderbird client containing GMail accounts - absolutely normal.
    I have iLife '09 but my iMovie '09 and iPhoto '09 open in a jiffy and I see no issues here. I have 6GB RAM (Maximum) on an early 2008 Macbook Pro with a 750GB hard drive partitioned with 120GB reserved for the Boot Drive.
    I am sorry that I cannot help further but I am sure there must be a way to reinstall the software without having to revert to restoring your ML backup. I have two clones and if you have such I would attempt to do that through that rather than through Time Machine - that is of course if you have a cloned drive.
    Good luck!

  • At my wits end with BT - can anyone help please?

    This is a long and ongoing saga and so I apologise for the long post.
    In February due to a change in job I needed to change the payment date of my DD payment. I did this online and received an email confirming the new payment date of the 28th. I stupidly assumed that was the date BT would take payment. The account is only used for Direct Debits and so money is put in there shortly before they're due. Over two weeks before the payment was due I received an unpaid DD letter from my bank. BT had attempted to take the payment early. I contacted BT and was assured my payment date was the 28th and they had no idea why payment had been attempted early. Later that day BT called to discuss the returned DD and I explained it was a BT error. A week later BT attempted to take the DD again. Once again I contacted them to be told my DD was definitely set up for the 28th and "there must be an error on the system" Later that day I received another call from BT to inform me my DD had been returned unpaid and again I explained that it was a BT error. Not trusting BT I cancelled the DD with the intention of making my payment online on the 28th. On 28th Feb before I had chance to make the payment I received a call from someone at BT who was mentioning late payment charges etc. I made it clear that any charges would be unacceptable as the error was down to BT and my payment wasn't actually late. I was asked to make payment over the phone but as it was difficult to understand each other I made it online and gave the payment reference number.
    My online balance at this point showed as zero and so I decided against setting up another DD for BT to attempt to take money as and when they pleased. Late March I received a phone call from BT telling me my DD wasn't set up and I had an outstanding balance of £57.75. I explained I'd had a zero balance but it would appear that my online balance was showing incorrectly. The person I spoke to said he could set up a new DD for this amount but as a one off it would come out on the 13th - something to do with making sure payment was made before the new bill came out and it taking X amount of time for a DD to set up. This would be a one off payment and after it had been made I'd be contacted to set up a new DD.
    On 20th April I received a call from UK based BT asking did I want to set up my new DD However to do this I would need to pay £120 over the phone. I asked why when I definitely had a zero balance, I'd received no bill and quite simply owed BT no money at that point. I was told there was a problem seeing all the data and somebody would call me back after the Easter weekend. Instead later that same day somebody else UK based phoned me asking me to set up my DD. I explained about the earlier phone call and she was confused as to why I'd been asked to pay anything as I clearly had a zero balance. I set up a new DD with her for £60 a month, payments to be made on 28th, starting 28th May. A few days after this my new bill arrived for £109.
    On 5th May my bank called me to say once again BT had attempted to take the DD early but this time they'd attempted to take £109. Once again I called BT and this time spoke to an Indian gentleman who advised me to cancel the DD with my bank while I was on the phone with him, he'd cancel it at that end and then he would set up a new one. He said letters of confirmation would be sent out to me.
    I sent an email to BT explaining all this and also saying I wasn't happy that they'd charged me £10 late payment charge on the new bill for unpaid DD. Had BT taken the payment when they should it wouldn't have been unpaid!! A gentleman phoned me back, assured me the £60 a month DD was set up for the 28th starting 28th May. He also emailed me confirmation of this.
    On 9th May I received an email saying I had a "supplementary bill" so looked at my online account to see my bill had gone up by about £5. My DD wasn't showing as set up on the online account but I decided to leave it a couple of days before contacting BT. Later that day though I received three letters. One saying my DD had been cancelled as discussed, and two others saying my DD had been set up to be paid 28th of every month starting 28th May for the amount £104!
    Before I had chance to call BT someone UK based called me to ask did I want to set up my DD as I had no payment plan set up. By this point I'd more than had enough and told her I had one email and two letters clearly saying my DD was set up and the only reason she'd be calling to ask me to do this would be if BT had cancelled the DD themselves. I refused to set up the DD yet again and she put me through to India based billing to discuss what was happening. I was told a DD wasn't set up on my account, that I couldn't set one up unless I paid my bill in full and that line restrictions are due to come into place on 29th May if the bill isn't paid in full.
    Today my BT online account shows no DD set up. However my bank shows the new DD is in fact active. I have no idea when BT will take money, or for how much. I don't know what to do, do I cancel the DD and just pay all future bills in full when they come in and in doing so be penalised by BT for not paying by DD? Or do I just leave it and hope they finally get it right? Bearing in mind I've had two letters saying they're going to take £104 and an email saying £60 I can't see that happening.
    It appears not one BT department speaks to the other, half the calls aren't logged and nobody at BT listens to the customer. I have spoken to Ofcom about this and they've advised me to give BT one more chance to sort this out and then go to the Ombudsman. I've just come across the forums and so am giving this a try to see if I can get any joy here.
    At some point during all this I spoke to somebody UK based who told me to send my bank charge letters to BT which I have done but as yet have heard nothing in return! I've lost track of how many people I've spoken to and am at my wits end with it all.
    Solved!
    Go to Solution.

    I'm even more concerned now after hearing back regarding my initial post. Apparently any cancellations or changes are showing as done by me using the self help platform on my BT account. This isn't the case. The actions carried out on certain dates listed on the email I received were all carried out by BT over the phone and not myself. I didn't even know it was possible to cancel a direct debit using the BT website. I thought it had to be cancelled at the bank and then a phone call to BT. I was logged onto my BT account while the phone calls were taking place but any action was carried out by BT and not myself. 
    BT are insisting I have no DD set up. Yet it clearly shows on my bank account that there is an active DD for BT. To confirm that, I've spoken to my bank today who have verified there is most definitely a DD set up to pay BT on the bank account. They've double checked the account number with me and it's definitely for my BT account. The bank are sending me a letter confirming it's an active DD for me to include all other details for the Ombudsman because I really feel this needs fetching to their attention. 
    To be fair to the person who has replied I have been told I can pay a small amount and set the DD up rather than pay in full or face restrictions. But despite BT's insistence that I have no DD set up my bank clearly states I have. I'm now going to have to cancel the DD that BT are sure isn't active and set it up again.
    Incidentally the monthly payments I'm to make are £45 - less than the £60 and a lot less than the £104 previously mentioned! So on one hand I will have a satisfactory conclusion but on the other I have to still cancel a "none existent" existing DD, set a new one up and am out of pocket on bank charges caused by BT trying to take payment on the wrong date. I then have to trust they'll not do the same thing again.......
    It's all like a stupid joke that's just not funny. 

  • I am having difficulty getting my scanner (HP5590 Scanjet) working with my MacBook Pro, can anyone help please. It did work alright with my IBM notebook.

    I am having difficulty getting my scanner (HP5590 Scanjet) working with my MacBook Pro, can anyone help please. It did work alright with my IBM notebook.

    There's a new driver bundle for OSX 10.6 that you might need to install, the HP link seems to be failing at the moment but there's a version of it here: HP_Installer_Scanjet_v2.4.3_Ph4.dmg
    There's a piece on the HP Forum about it here (some folks have problems installing ...)
    http://h30499.www3.hp.com/t5/Macintosh-Compatible-Products/Scanner-Drivers-softw are-for-Snow-Leopard-Mac-OSX-10-6-will-not/td-p/2301674

  • Problem with RAM and slowing of computer when using CS5 can anyone help please?

    Hello I am having big problems at the moment with a slow computer when I am using Photoshop CS5 I am informed that I am low on memory.  I do not store any photographs on my computer they are all on an external hard drive, the only image on the computer are the ones I am working with.  I have been in touch with Norton who think it is an Adobe issue can anyone help please, looking forward to hearing from you and to a swift fix of the problem
    Best wishes
    Sheila

    How much memory do you have installed, and what operating system are you running?
    Mark

  • Hi, i cannot publish my iWeb site with  a non mac domaine name...can anyone help please?

    hi, i cannot publish my iWeb site with  a non mac domaine name...can anyone help please?

    Hi, I have a site developed by myself usinf iWeb and as iWeb are no longer hosting teh sites in 2012 i have found another domaine. It is with Go Daddy and the domaine / name is live. I have tried to publish site using fttp but keeps coming up wih a common error message saying the info i have input is incorrect. I have tread this may be an issue if host is a windows based host???
    appreciete your help

  • TS3510 I only have one apple ID and facetime has worked with it before, but now I get the message "Unable to verify email because it is already in use". I have looked ofr a solution but can't find one. can anyone help please?

    I only have one apple ID and facetime has worked with it before, but now I get the message "Unable to verify email because it is already in use". I have looked ofr a solution but can't find one. can anyone help please?

    I spoke with Apple Support this morning and they believe anything MobileMe related is due to the conversion over to iCloud that's taking place.
    As for other email clients, check with your host to see if settings have changed on their end. I use inmotionhosting.com and over the weekend the updated their outgoing requirements so that a password authentication is now needed.
    Hope that helps get some on the right path to resolving their issues!

  • Installed CS6 and all working except Photoshop. Says application will not run on this mac despite my having the necessary system requirement of OSX 10.6.8. Can anyone help please?

    installed CS6 and all working except Photoshop. Says application will not run on this mac despite my having the necessary system requirement of OSX 10.6.8. Can anyone help please?

    Hi - I have opened a second log with the same date and name and am now tracking down the problem.
    This seems to be the problem for me: Error "Exit 6" or "Exit 7" | Install log | Read, write, system file errors | CS5, CS5.5

  • Having upgraded from iPhoto 11 to iPhoto 2.0 (531) it now loads but crashes after a minute or so and none of the buttons work. Can anyone help please.

    Having upgraded from iPhoto 11 to iPhoto 2.0 (531) it now loads but crashes after a minute or so and none of the buttons work. Can anyone help please.

    Hey Ian
    That would be correct. because of the nature of your issue, you may find more information by using another one of Apple's support resources.
    Contact Apple Support
    https://getsupport.apple.com/GetproductgroupList.action
    Thank you for using the Apple Support Community.
    -Norm G.

Maybe you are looking for

  • MacBook to XP Networking

    I have a MacBook and PC running Windows XP. Access to the network and internet is using a Verizon FIOS Actiontec router. I can see the MacBook from the PC but cannot see the PC from the MacBook. I have turned off all firewalls (Norton and even the Ac

  • Include command line args in executable jar?

    Hello all, I'm trying to package up some software which takes 2 command line args to run (for example, java -jar prog.jar FooBar 3.14159). I'm using a utility called Jar2Exe to wrap it up into an exe (still needs JRE to run, but it's nicer packaging

  • HTMLLoader and clearing cookies

    Hi there, I'm using air.HTMLLoader.createRootWindow to pop up a window to a user in an AIR application to ask them to authenticate with a third party service. I'd like to know where the window opened by the HTMLLoader class accesses the user's cookie

  • Missing data in lead survey translation

    Hi everyone, I create a lead survey in transaction crm_survey_suite. After activating it I want to translate it. I login to the CRM System in the target language, translate the survey and activate the translated version. When I then choose the transl

  • HT6058 how do i get driver software for my iphone 4

    how do i obtain driver software for my iphone 4