Easy fix I think
This is the error I get:
Exception in thread "main" java.lang.NullPointerException
at ShoppingCart.AddToCart(ShoppingCart.java:9)
at Shopper.main(Shopper.java:6)
I have this assignment that I have to do. I think I am hung up on syntax
type problems.
Thanks very much.
FIRST FILE:
public class ShoppingCart
private int _itemsInCart;
private String _itemDescription[];
private double _itemPrice[];
void AddToCart (String Item, double Price)
_itemDescription[ _itemsInCart ] = Item;
_itemPrice[ _itemsInCart ] = Price;
void DisplayCart ()
for (int i=0 ;i<itemPrice.length ;i++ )
System.out.println("Item " + ": " + itemDescription[i] + " $" +
itemPrice); //What is it unable to see what itemDescription is?
NEXT FILE:
public class Shopper
public static void main(String[] args)
/* declare the variable with type
instantiate the object using new and the name of the class
ShoppingCart myShoppingCart = new ShoppingCart();
myShoppingCart.AddToCart("Soup", .50);
myShoppingCart.AddToCart("Soup", .90);
myShoppingCart.AddToCart("Milk", 1.50);
myShoppingCart.DisplayCart();
//You forgot to initialize the arrays
private String _itemDescription[];
private double _itemPrice[];it should look like this
private String[] _itemDescription = new String[10];
private double[] _itemPrice = new double[10];
Similar Messages
-
There's a black and white striped glitch on the left side of my screen on my Macbook Air! Its happened before and has been an easy fix, usually just restart or turn off my computer but don't know what else to do. Is there anything I can try now? I wont be able to make it to the Apple store until tomorow and would prefer if there was something I could do that didnt cost money, my computers very new and I really need help.
Hi and welcome to the community! Since you're new please be sure that you have checked out our Discussion guidelines.
I suggest that you try to repair the phone software using PC Companion..
Before repairing your device you may want to backup your information first. Check out this topic for more information on how to.
How to backup?
If the issue should still remain I think that this needs to be examined and fixed at a repair center. For more information about how to submit your phone for repair and where, contact your local support team.
- Official Sony Xperia Support Staff
If you're new to our forums make sure that you have read our Discussion guidelines.
If you want to get in touch with the local support team for your country please visit our contact page. -
My headphone port only works through one ear, is there an easy fix?
Hi, I have always been careful to not leave my headphones plugged in when I'm not using my iPod (classic), but yesterday for some reason no music will play through the right headphone. I have tried three different sets of headphones and it's the same will all of them so it has to be the iPod, is there an easy fix at all? if i have to have it fixed does anyone know how much it might cost?
Thanks, Lauren.I don't think it's possible anymore. I'm mildly surprised you were able to keep podcasts in regular playlists this long - I thought this option disappeared back with iOS7.
I do share your pain. I've finally grown used to having the podcasts in a separate app, but I still don't like it. -
My Adobe has stopped allowing me to move library books from my PC to my KOBO (both show authorized on the ADE. the message reads : CE_COPY_NOT_ALLOWED - No permission to copy book. It used to work. Any easy fixed for me?(I already tried uninstall and re-install)
Welcome to the Club! Got the same Problem and had a really hard time reaching the Customer Support because they were down due to maitenance! Just wrote to their experts chat and hope to get an answer in this life!
I tried to authorize my Computer and eBookreader with a new Adobe-ID, but it says I've done used this ID too often, even though it was brandnew! Can't copy my just-purchased eBook because "Copying is not allowed".
I hold my thumbs for you that Adobe solves this Problem fast enough. Other ways I'll sell my eBookreader and buy the Kindle-Reader from Amazon and say GOOD BYE to Adobe! -
I've just signed up to iTunes Match as I have songs on my iPhone 4 which wont sync with iTunes as they are from CDs but I can't see my music in the cloud now. Anyone had the same problem and have an easy fix?
What fixed it for me:
On your computer, open iTunes > My iPhone (or whatever name you gave your iPhone) > "Music" page
Uncheck "Sync Music"
Click "Sync" button (bottom right)
Let it run and finish
Uncheck the box for every song, playlist, etc.
Click "Sync" button (bottom right) (This step may be unnecessary, but I did it and got the result I wanted.)
Let it run and finish
Check the boxes for the music you want on your iPhone
Click "Sync" button (bottom right)
Let it run and finish
See if that doesn't work for you. I tried a lot of things that did nothing, but this seems to have fixed it, and quickly. -
I had an in-game purchase that failed to give me my items purchased, this is usually an easy fix, but this one was through EA, I would like to know what steps I can take to rectify this. (I realize that NOT playing EA games is the best answer...)
Can you try to restore your inApp?
If that doesn't work:
iTunes Store Support
http://www.apple.com/emea/support/itunes/contact.html -
The macbook reads a disc, and opens up DVD player but then says not permitted when I hit play, or any other button. Sometimes the initial music plays, but the screen remains black and then it all stops. These are shop bought DVD's that have previously worked on here, and work in DVD players, but have suddenly stopped. The computer is much older than the12 months warantee so I hope there is an easy fix? Thankyou!
Three things you can try:
1. Clean the superdrive with a proprietory CD/DVD lens cleaner that uses tiny brushes.
2. Perform an SMC reset:
Resetting the SMC (System Management Controller) on Intel-based Macs:
http://support.apple.com/kb/ht3964 and
http://support.apple.com/kb/HT1237?viewlocale=en_US
Resetting your Mac's PRAM and NVRAM:
http://support.apple.com/kb/ht1379
If you are using a Wireless Keyboard:
http://support.apple.com/kb/TS3273
3. Try the free DVD player VLC:
http://www.videolan.org/vlc/
which performs better than the built-in DVD Player. -
Is there any easy fix to the problem I encountered yesterday (and which continues)? Since yesterday I have had no internet access on my MacBook Air. The icon at the top of the screen shows just the shield outline, and underneath in faded letters says "Wi-Fi: No hardware installed". I received an error message that said s
something with a minus 50 referenced.Reset SMC. http://support.apple.com/kb/HT3964
Choose the appropriate method.
"Resetting SMC on portables with a battery you should not remove on your own". -
On Windows Vista and tried several times to start up my iTunes, but keep getting 'application failed MSVCR80.dll error-7 (windows 126) is this an easy fix ...?
Click here and follow the instructions. You may need to completely remove and reinstall iTunes and all related components, or run the process multiple times; this won't normally affect its library, but that should be backed up anyway.
(99442) -
I was using my wife's MacAir while my Macbook was in for repairs and now all of my printers want to do through her Macbook Air and unless it is on and on our home wireless, I can't print. Is there an easy "fix" for this?
See this post.
tt2 -
Second day after updating to iOS 6 on my iPhone 4, my contacts have duplicated. Probably not all but many, and my contacts already numbered in the thousands.
Please tell me there is an easy fix to this problem!! I already had to go through contact-by-contact when I bought this phone and added contacts from my Blackberry and MS Outlook on the phone. Many duplicated at that time and Apple said the only fix was to go through each one and decide to keep or delete. I really don't want to do that again!I had this problem while I had iOS 5.1.1 installed for many months. Fortunately I only have about 150 contacts and only about half of them duplicated. I found that my problem was the way thing were set up in Outlook. I removed all of the duplicates and corrected everything in Outlook contacts (ignoring the address book) and have not had the problem since, Hope this helps.
-
I have a ibook that powers up but has no display, is it an easy fix? how much would it cost to fix
Hi,
Can the sounds of an active hard drive be heard at some point (indicating a normal startup)?
There is a problem with the graphics processing unit (GPU) and its ball grid array (BGA) on some iBook computers, leading to similar symptoms. Reflowing (resoldering) the BGA is a work for specialists, and is going to be expensive. A web search will return a number of more or less realistic alternative attempts to solve the issue. Outside pressure applied to the affected area has sometimes been used for troubleshooting, or even as a temporary "solution".
It is of course possible that the iBook in question has a completely different fault, such as a broken display cable.
See also the following article about resetting the Power Management Unit (PMU): http://support.apple.com/kb/ht1431
Jan -
Is there an easy fix for nonfuctional on/off button?
My power switch no longer works. Is there an easy fix?
I do not know of any.
Apple will exchange your iPod for a refurbished one for $199 for 64 GB 4g and $99 for the other 4Gs. They do not fix yours.
Apple - iPod Repair price
A third-party place like the following will fix the switch for less. Google for more.
iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens
Replace the switch yourself if you are up to it
iPod Touch Repair – iFixit -
When I burn a disc from a playlist in iTunes on my MacBook, the track names and artist info does not display on the disc when friends view/listen to it. This probably is an easy fix, but I need some advice.
No, this standard has been implemented for several decades.
How iTunes remembers audio CDs - http://support.apple.com/kb/TA27785
It is just conceivable you burned a CD that exactly matched one already in the Gracenote database. Gracenote uses track count and duration to decide what CD it is you have in a computer. If you have one that matches that it will label it. You could conceivably even have one that matches it that is not the correct one.
This script will only work on Macs:
http://dougscripts.com/itunes/scripts/ss.php?sp=cdtexttocdinfo - script to use CD-text file on CD to label CD in iTunes -
ITunes auto changed a bunch of albums to have the same name and art. Any easy fix?
So iTunes randomly changed a bunch of albums to be The Frozen Borderline by Nico with the album art (the artist names and song names are still the same though). I was just curious is there an easy fix, or do I have to go through and fix it one-by-one manually? Here's a screenshot: http://i.imgur.com/n6hfCZg.jpg
Please? I really need help on this.
Maybe you are looking for
-
I've downloaded the app clash of clans and I want to purchase an item on the game but when I go to purchase it something pops up and says I cannot connect to iTunes Store. Having said that I have a valid credit card entered into my iCloud account.
-
hi i have windows xp on my system. i installed oracle 10g. when i am trying to login in sql*plus by user name Scott / system it gives an error account locked .is there any other default user names and passwords and host sting ?coud you pleas give me
-
i am working on AFS Inter company stock transfer.. I have done all the standard configuration.. i have created PO and outbound delivery also. But while doing PGI in VL02n i am unable to see the stocks under AFS Picking Tab. Because of that i am unab
-
Here is the info that showed up the last time it crashed. Let me know if anyone can help. Thanks Date/Time: 2008-12-08 19:21:23.236 -0600 OS Version: 10.4.11 (Build 8S165) Report Version: 4 Command: Safari Path: /Applications/Safari.app/Contents/MacO
-
IMac G4 with no Line In, and no Soundpref.plist
One day, I simply had no more Line-In on my iMac G4. Trying to use my guitar emitted this horrible high pitched shrill in Garageband. Some tooling around brought me to the System Preferences instead of the Garageband preferences. In the Input pane, t