Help?  Beginning Student--error msgs

Hi, I'm a college student taking Java with the 3rd edition Deitel and Deitel Text.
In Chapter 5, problem 5.11 is killing me.
I've tried moving things around, and it just changes the error messages from "type expected" to "variable may not have been initialized."
Here is the current version, with the "variable may not have been initialized" error message. Please help me?
import javax.swing.*;
import java.awt.Graphics;
public class Applet511 extends JApplet {
int n = 0, r, d = 1;
public void init () {
     String input;
for (r = 1; r <= 5; r++ )
     //read in number from user as a string
input = JOptionPane.showInputDialog(
     "Enter a number between 1 and 30: " );
     //convert number from type String to type Int
n = Integer.parseInt ( input );
     public void paint ( Graphics star ) {
     while ( d <= n ) {
          star.drawString ( "*", 50, 50 );
          d++; }
The error message says:
Applet511.java:19: Variable input may not have been initialized.
n = Integer.parseInt ( input );
^
1 error
Thank you!
Robin

import javax.swing.*;
import java.awt.Graphics;
public class BallB extends JApplet {
int n = 0, r, d = 1;
public void init () {
String input;
for (r = 1; r <= 5; r++ ){
//read in number from user as a string
input = JOptionPane.showInputDialog(
"Enter a number between 1 and 30: " );
//convert number from type String to type Int
n = Integer.parseInt ( input );
System.out.println(n);
public void paint ( Graphics star ) {
while ( d <= n ) {
star.drawString ( "*", 50, 50 );
d++; }
}u have misplaced your { } braces, and you have
declared paint method inside init() method, which you
cannot do
hope the above code helpsActually paint is not in init. It's just looks strange since the program gets a String five times using JOptionPane but only uses that last one. So the for loop may need { } so that n may be assigned the String each time also, but paint is only going to use the last assigned value of n, anyways...
Here's the original init:
public void init ()
  String input;
  for (r = 1; r <= 5; r++ )
    //read in number from user as a string
    input = JOptionPane.showInputDialog( "Enter a number between 1 and 30: " );
  //convert number from type String to type Int
  n = Integer.parseInt ( input );  // this was not in for loop

Similar Messages

  • Can anyone help with this error msg "The disc can't be burned because an unexpected error occurred (error code 0x8002006E)." ?

    I was also getting the message telling me it is a medium problem however that has changed more to the  latest 0x8002006E one.
    I use to be able to record all the time on DVD-R, then all of a sudden that has stopped and get
    The dic can't be burned because of a unexpected error 0x8002006E.
    I have looked at most of the discussions on this subject, I have also done most of what people have suggested, nothing has worked so far.
    I am able to record music on cd's, I am able to record on DVD-RW, I can't however record on DVD -R anymore and have tried three different brands.
    I have gone through about 30 or more discs trying to fix this problem so any help right now would be great.

    http://www.apple.com/support/mac/app-store/contact.html?form=account

  • ERROR MSG DURING ATTEMPT TO SAVE A QUERY ON LOCAL

    Hi Experts,
    Kindly help me out
    ERROR MSG DURING ATTEMPT TO SAVE A QUERY ON LOCAL
    status message : Errors: Authorization change not available for query

    Hi Surendra,
    Nw while i executing this query in production system
    Error i gt:   1.  Infoprovider was changed or activated at runtime
                      2.  system error in program CL_RSD_Multiprov and form GET_PART_IOBJNM_CMP_01
    Kindly give me some inputs
    Thnks
    Sinu

  • Photoshop CS2 (program error msg)... Help please!!

    I have installed the full creative suite 2 on my new iMac. everything works fine except photoshop?!!?
    Illustrator works great, In-Design works great, But when i try to open a file or create a new page in PS it tells me "Could not create document because of a program error"???? ***?
    I had a previous version of CS and it worked fine for one day, then that started happening. I installed the CS2 trial version, and it would still give me the same error msg. I erased everything and installed the new CS2 (photoshop, illustrator , in-design and acrobat). It still gives me the same darn msg.???
    Any help would be greatly appreciated!
    thanks

    See the Adobe Knowledge Base document"Error 'Could not complete your request...' or 'Could not create a new document...' (Photoshop CS2 on Mac OS X v10.4)"
    I suggest whenever you have problems with third-party applications, the first place to start troubleshooting is with the application's documentation, then vendor's web site. Usually their sites have FAQs, lists of known bugs, or application-specific forums similar to these Discussions. Sometimes, unlike the Apple Discussions, the questions are even answered by employees of the vendor.
    The document cited above was found in 10 seconds by searching the Adobe support site.
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X

  • Error msg 13019 please help

    hi
    i need help in getting rid of this error msg 13019. it started after downloaded a couple of songs. and it will not allow me to sync my nano ipod thanks

    Ive fixed this issue before. The steps are kinda long but they work.
    This is for windows computers with iPod nano that get the error 13019 during or after a sync with iTunes.
    -Open itunes
    --click, edit, click preferences
    --select advanced
    ---make a note of the iTunes media folder location on a notepad.
    ---put a check in organize files
    ---take the check out of copy files
    ---click ok
    --Click file, at the top of iTunes
    --move mouse over library, select organize, and consolidate files. ( This ensures all music in you iTunes will be in the iTunes media folder later.)
    At this point, if you have playlists you want to save:
    -Create a folder on your desktop, call it, playlists
    --Hover you mouse over your playlist in iTunes, should be at the bottom of the blue/grey column on the left.
    --right click the playlist, select export playlist
    --Navigate to your desktop and open the playlist folder and save.
    ---Do this for each playlist you want to save
    -Close itunes
    -Click your start button, and open computer or my computer
    --Using what you wrote down on your note pad, follow the path to the "iTunes folder", NOT the iTunes media folder
    --Open the iTunes folder.
    --Stop here
    -You will see icons that look like folders and you will see icons that look like files-
    -You will KEEP the FOLDERS
    -You will DELETE the FILES
    --If it makes you more comfortable you can cut the files out and paste on your desktop, but as of now we do not need the files any longer as we have the playlists backed up. Remember-Keep the folders.
    --That was the magic--
    -Disconnect your iPod if connected.
    -When you open your iTunes, it will be empty, that is OK. We are recreating the library. Everything will come back in a few seconds.
    -Click file at the top
    --Select, add FOLDER to library, not to be confused with add file.
    --In the window that pops up, locate and click on computer or my computer
    --From here follow the path to the iTunes media folder on your note pad, but do not open the iTunes media folder.
    --Click the iTunes music/media folder one time so it highlights.
    --On the bottom right you will have option to select folder, or choose folder or OK. Hit that button.
    All you music will start to import back into iTunes.
    -Plug in iPod after completed
    --a message pops up about being synced with a different library.
    --Click erase and sync
    --Watch all your songs go on your iPod with no error message.
    From here you may sync your iPod the way you want with out worrying about the persnickety error 13019!!!!!
    Hope this helps!!!
    Julian
    p.s. Follow the directions exactly.
    p.s.s. To add your playlists back to iTunes:
    -Click file at the top of the screen
    --move your mouse over library, selecte import playlist
    --on the new screen that pops up, navigate to your desktop
    --open the playlist folder, select the first playlist, hit ok
    --repeat for each playlist exported

  • I ve updated my i pod touch to version 6.0.1. Installation got failed with some error msg, and now my i pod is not getting detedted in my system.Help me to fix it up.

    i ve updated my i pod touch to version 6.0.1. Installation got failed with some error msg, and now my i pod is not getting detedted in my system.Help me to fix it up.

    What's the error mesage?

  • When I conect any ipod ,the itunes show an error msg-The syncServer found a problem and must be closed.After that another-Mobile device helper find a problem and must be closed -and this repeat more 2 times each are  related with corefoundation.dll.

    Six error msg about apple aplications that must be closed just when I connect my ipod to computers USB.SyncServer aplication and Mobile device helper is closed.The error relat.show :
    AppName: syncserver.exe     AppVer: 17.641.14.26     ModName: corefoundation.dll
    ModVer: 1.550.54.0     Offset: 00043d08
    These happens in both kind of messages that was showing three times each.After this ,Itunes can sinc music videos,photos,but I canot upgrade my ipod!
    Detail:copy photo files from ipod to computer works normal.I use panda antivirus but without it in the computer,the problem persists.Yesterday I get the last ITunes,but the problem persists.I unistall anything about apple ,install the new Itunes and the problem remains.
    And this problem occurs only after I connect ANY ipod to the computer,open Itunes for hear music,for example,still works OK.

    I have been battling against the same issue for over 2 weeks now. After tracing what was happening on the machine to find that the crashes we're happening slightly after Apple's program we're identifying the Time Zone of the computer, I had the idea of checking the date/time properties of my Windows XP machine.
    I unchecked the box to update the time from a time server (Internet time) and it's seem that this was what was causing itunes and its descendant to crash.
    Now it seems it turned back to normal operation.
    Please let me know if this fixes it for you as well.

  • HELP!! Itunes wont install on Windows 7.  I get an error msg. there is a problem with this windows installer package. A program required to install to complete could not be run.  Contact your support personnel or package vendor. WHAT NOW?

    HELP!! Itunes wont install on Windows 7.  I get an error msg. there is a problem with this windows installer package. A program required to install to complete could not be run.  Contact your support personnel or package vendor. WHAT NOW?

    Ok, Below is what worked for me somewhat. 
    Okay ... try downloading and saving a copy of the iTunesSetup.exe to your PC from the Apple website:
    http://www.apple.com/itunes/download/
    Now download a trial version of WinRAR:
    http://www.rarlab.com/download.php
    Open the iTunesSetup.exe with WinRAR, and try to run the standalone install of Apple Application Support from the AppleApplicationSupport.msi you find in there.
    It works now BUT there are still problems.  It is not allowing or recognizing my Cd/DVD player and i CANT burn.  Looking still for this fix.

  • TS1717 Installed the iTunes 10 update on my computer (Windows 7).  iTunes will no longer launch and I get no error msg. Tried uninstalling and reinstalling entire app but no help.  Tried setting up a new user, no help.  What's wrong??

    Installed the iTunes 10 update on my computer (Windows 7).  iTunes will no longer launch and I get no error msg. Tried uninstalling and reinstalling entire app but no help. What's the fix??

    Hi sahgin,
    The issue eventually resolved itself, I still don't really know why. I kept up with Windows update, and attempted downloading iTunes again from the Apple website, and it just... worked. It now works fine. I don't know why it took approximately 4 months to work, though.
    I'm sorry I don't have any more helpful information. Posting here was my last resort, and clearly Apple never bothered to reply.

  • I´m trying to open an excel file in numbers not being successful. The error msg is unexpectedly error using plugin SFCompatibility can you help me?

    I´m trying to open an excel file in numbers not being successful. The error msg is unexpectedly error using plugin SFCompatibility can you help me? Already changed the extension of the excel document to xlsx an now gives an unknown import error.

    In Excel have you tried saving directly to xls (not xlsx) and opening the xls in Numbers?
    If you have a complicated workbook in Excel that uses lots of Excel's advanced features, Numbers may not be able to handle the import.  It does pretty well on basic things, though.
    If you're just trying to get data into Numbers, then often copy-paste from Excel is easier than trying to open xls files.
    SG

  • Develop tab not working. Error msg "?;0: attempt to perform arithmetic on a string value" Help!

    I continue to get the error msg "?;0: attempt to perform arithmetic on a string value" when clicking on the 'Develop' tab in LR.  I've uninstalled and reinstalled the software 3 times from the original disc.  I'm in the middle of a wedding edit.  Help!

    It sounds like you might have a corrupted preset.
    Here's something you could try:
    Go to your Preferences/Presets tab and push the Show Lightroom Presets Folder button.
    Then close Lightroom and temporarily rename that folder. If the problem goes away, one of your presets is bad. Otherwise name the folder back to what it was and let us know what happened.
    Hal

  • Error Msg Plse Help

    I've tried to add an ebook to my Adobe Digital Editions, but I get the following Error msg " E LIC ALREADY FULFILLED BY ANOTHER USER" please help.

    Hi Vi-Rose,
    Please follow the knowledge base article: http://helpx.adobe.com/digital-editions/kb/e-lic-already-fulfilled.html.
    Regards,
    Romit Sinha

  • Error Msg Help Can't Save PSD Files

    This is the error msg its giving me,
    Could not save file.psd because you do not have the necessary access privileges.
    I own PS4 and every plugin in the system. Can't anyone help me out?
    Mac OS 10.6 PS4 with latest updates and all I was doing was working a picture as normal and tried to save and quit and it wouldn't let me bummmer lost everything I did!!!!
    Mike K

    System Maintenance (repairing permissions ((with Disc Utility in the Utilities-Folder or the free Onyx http://www.apple.com/downloads/macosx/system_disk_utilities/onyx.html)), purging PRAM, running cron-scripts, trashing Caches, etc.) might help.
    Please note that I wrote »might«.

  • Help-cannot download podcast from itunes to ipod.  error msg

    I have the IPOD video 30gb, 5th generation, and have itunes 7.02..
    I am able to download the podcast from itunes into my library, but am unable to download it onto my ipod. an error msg pops up:
    "...was not copied to the IPOD because it cannot be played on this IPOD."
    I've searched and searched for an answer to this, and it appears to be a somewhat common problem with the itunes upgradeto 7.02
    does any one have a solution?!?
    HELP! (i'm an ipod newbie-and this is driving me absolutely MAD!!)

    OMG-i just figured it out!!
    *first of all, i came across this in the itunes store help area-->
    "Why won't some video podcasts play on my iPod?
    Some video podcasts, while playable in iTunes, are encoded in formats that are not compatible with iPods. To convert those videos so that they are iPod-compatible, highlight the video in iTunes, right-click on the selection, and choose "Convert Selection for iPod". iTunes will automatically re-encode the video for playback on iPod. Go to the Movies section of your Library to find and play the converted episodes.
    *i had converted the podcast previously, but i had just continued to try and transfer it from the podcast section rather than going to the movie's section, and dragging it from there. once i did that, it worked!
    hope this helps anyone else out there, as i did come across a few other queries...

  • Im getting error msg (1) can you help

    Hi my bro asked me if i can fix his ipod touch 1st gen its not fuly restoring im getting error msg (1) can you help

    ERROR (1)
    - Place the iPod in DFU mode and then restore
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - Try on another computer
    - Try another cable
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
      Apple Retail Store - Genius Bar     

Maybe you are looking for

  • Error while changing Service Order in CRM

    Hi, After creating Service Order in CRM, i click on change mode, it shows the following error: An error occurred in system ECC during account assignment Message no. CRM_ORDER_MISC 060 Diagnosis Errors occurred when assigning an account assignment obj

  • Difference between the two modes ws_policy and sap_wsdl

    Dear All, what is the difference between the two modes ws_policy and sap_wsdl and how do we set them and where do we set them. do let me know the steps to be followed. Thanks & Regards Venugopal

  • Why don't mail show the picture of the sender in the mail I receive

    Hi everybody I am using Mail and Address book and I have pictures of my friends and colleagues etc. and therefore the mail program should show me a picture of the sender when I receive e-mail from one of them. It also does normally but when I have tw

  • How do I replace a file?

    Hi Guys, This is my first time to post a question so please bear with me. I recently got done editing a set of shows for a client. They're standard 28:30 show with lots of Graphics, lower thirds and Full Screen Graphics, many of which have the client

  • Windows Vista frozen when running on a MacBook

    Hello all - I have a brand new MacBook running OSX 10.6.2. I've successfully installed Windows Vista Ultimate 32 via BootCamp. Apple drivers are loaded correctly and everything seems to work fine except Vista seems to FREEZE after running for a few m