SOS SOS !!The Program Asks me the same number twice

I am trying to do the exercise 5.11 from Java Deitel 4th edition it says
"Write an applet that reads five numbers, each between 1 and 30. For each number read, your program should draw a line containing that number of adjacent asterisks. For example, if your program reads the number 7, it should display *******."
This is my code:
// Java core packages
import java.awt.Graphics;
// java extension packages
import javax.swing.*;
public class Exe5_11 extends JApplet {
     public void paint( Graphics g )
int number;
String input;
     super.paint( g );
JTextArea outputTextArea = new JTextArea();
outputTextArea.setText("Hystograms\n\n");
     for ( int i = 1; i <= 5; i++ ) {
number = 0;
while ( number > 30 || number < 1) {
input = JOptionPane.showInputDialog("Enter Number " + i );
// convert user's input to an int
number = Integer.parseInt( input );
} // end while input
// display asterisks
for ( int j =1; j <= number; j++) {
outputTextArea.append ("*");
outputTextArea.append ("\n");
} // end for
JOptionPane.showMessageDialog( null, outputTextArea,"Hystograms", JOptionPane.INFORMATION_MESSAGE );
System.exit(0);
} // end paint method
} // end class Exe5_11
The problem:
The program asks me twice for the first number I don't know why? The logic is good, I think is something related with the scope of the variables or something particular with Java I don't know jet.
Please help me, I have spent 2 hours in this exercise.
THANK YOU IN ADVANTAGE!!
Samuel

double-post

Similar Messages

  • At the very end of creating an email account the program asks for a software security device password, I have no idea what this is or where to find it.

    At the very end of creating an email account the program asks for a software security device password, I have no idea what this is or where to find it. To my knowledge I don't have a "software security device". I am using Windows 7 on an IMac.

    What is the exact prompt or error message you get?

  • I downloader all the Adobe Presenter, looks like everything downloaded but when I open the program I get the following message: The file archive part of Presenter is missing. You need all parts in the same folder

    I downloadedall the Adobe Presenter, looks like everything downloaded but when I open the program I get the following message: The file archive part of Presenter is missing. You need all parts in the same folder

    HI There,
    It seems that Presenter is not fully downloaded. Please check you have downloaded .exe and .7z files successfully. In case you are still facing the issue then please click on the following link to chat with the support :  Chat
    with an Expert
    Regards,
    Mayank

  • Using PRO XI for educators. Every time I try to change a document into a PDF document the program asks me to sign up for a monthly fee.  What's going on???

    I am using Adobe XI Pro for educators.
    Every time I try to change a document into a PDF document the program asks me to sign up for a monthly fee. What’s going on???

    Hi Peter,
    Are you still facing this issue.
    I am not able to see any product registered under the email id using you are registered here.
    Regards,
    Ajlan Hulda.

  • I wanted to know explain my problem down package cc2014 where I put the serial number of the problem that I have is that when you open the program asks me start of session in which he put it and go but back inside and it drives me to request the start of

    I wanted to know explain my problem down package cc2014 where I put the serial number of the problem that I have is that when you open the program asks me start of session in which he put it and go but back inside and it drives me to request the start of session and I take 3 weeks or more with this problem if they can support me solve it was the number of seire wearing this being installed at a private university

    Cloud programs do not use serial numbers... you log in to your paid Cloud account to download & install & activate... you MAY need to log out of the Cloud and restart your computer and log back in to the Cloud for things to work
    Some general information for a Cloud subscription
    Log out of your Cloud account... Restart your computer... Log in to your paid Cloud account
    -Sign in help http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html
    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html
    Does your Cloud subscription properly show on your account page?
    If you have more than one email, are you sure you are using the correct Adobe ID?
    https://www.adobe.com/account.html for subscriptions on your Adobe page

  • HT201251 I can not cancel the authorization authorized to itunes devices The program asks me to contact support   What to do graduate as I can not back up any of my own computer Please attention thanks

    I can not cancel the authorization authorized to itunes devices
    The program asks me to contact support
    What to do graduate as I can not back up any of my own computer
    Please attention thanks
    MAHMOUD
    <Personal Information Removed by Host>

    If you haven't already done so then you will need to do as the message tells you and contact iTunes Support (these are user-to-user forums) :
    - go to http://www.apple.com/support/itunes/ww
    - click on your country's flag
    - click on the Contact Support at the bottom of the left-hand column
    - click on Contact iTunes Store Support on the right-hand side of the page

  • When I bought the program asks enter Albasword and when enter Albasword turned into questions , and I do not remember the questions is the best teacher

    When I bought the program asks enter Albasword and when enter Albasword turned into questions , and I do not remember the questions is the best teacher

    Click here for information. If the option to have the answers emailed to you isn't available or doesn't work(the email may take a few hours to arrive), contact the iTunes Store staff via the link in the 'Additional Information' section of that article.
    (88705)

  • Tcode VF02 RAISE statement in the program "SAPLCSS3" raised the exception.

    Hi,
          I am getting a short dump in my smartform attached with vf02. For few of invoice no. its working perfectly but giving dump in few invoice no.
    Below is short dump statement. Pls guide me for this issue.
    A RAISE statement in the program "SAPLCSS3" raised the exception
    condition "CALL_INVALID".
    Since the exception was not intercepted by a superior
    program, processing was terminated.
    Short description of exception condition:
    invalid call
    Regards,
    Ranu`
    Edited by: ranu sharma on Feb 6, 2010 2:55 PM

    Hi Dipesh,
    In background SAP GUI functionalities are not available.
    This question has been asked many times on scn:
    CNTL_ERROR
    CNTL_ERROR while running a report in background mode
    Regards,
    Ashvin

  • Hello! Help me please, I have a problem with the program occurred after the upgrade to version 3. 6. 16, namely by pressing the button 'Open a new tab' nothing happens. ?

    Hello! Help me please, I have a problem with the program occurred after the upgrade to version 3. 6. 16, namely by pressing the button 'Open a new tab' nothing happens. ?

    This issue can be caused by the Ask<i></i>.com toolbar (Tools > Add-ons > Extensions)
    See:
    * [[Troubleshooting extensions and themes]]

  • The programming language of the future: a philosophical question

    So after reading some of these posts and reflecting on the history of programming languages, I find myself wondering what the programming language of the future will be? As the human-computer interface evolves (touch interfaces, voice recognition, computer vision, etc) how will this influence the process of creating computer programs? Will programming become more graphical (e.g. flow charts, UML diagrams, etc)? Setting ego's aside, does it make sense for programming to be more graphical? Will we reach a point where we can essentially just sketch out a concept and let the compiler/interpreter handle the rest?
    Perhaps this question is best left to Clark and Asimov, but they're dead. This leaves you guys.
    (Moderator, I apologize in advance if this is out of scope for this forum.)
    Last edited by bsilbaugh (2011-11-23 01:15:47)

    geniuz wrote:I think the mistake of the scientist in question was not that he re-derived the Trapezoid Rule, but that he published it as if it was a new invention, while it existed and was already published in some form. That certainly could be prevented by reconciling to literature before publishing. In fact, I'd not even blame the scientist in question too much, rather the commission that approved his paper to be published in the first place.
    Sure, he didn't publish the paper in isolation - but the peers who reviewed it would have been people from the same or a related profession. My point is that this kind of error results from splintering of the disciplines. You seem to think that the splintering should be somehow undone or reversed at the level of the peer reviewer or the publisher - but non-specialists (or specialists in other areas) will not be invited to comment, because it will be assumed that they lack the qualifications to do so.
    geniuz wrote:Still, I think its a long stretch to compare the derivation of a Mathematical rule or method to the invention of a complete DSL.
    I think I didn't make it clear where I was going with that. My point was that splintering of specialisations from each other permitted this duplication of effort to take place. I see DSLs as a way to splinter disciplines from each other. Thus, the rise of DSLs would make it easier for duplicate effort to take place.
    geniuz wrote:The whole point of a DSL is that it allows experts in a specific domain to focus their efforts on creatively solving problems directly related to their field of expertise. When specific DSL's are integrated in university curricula world-wide, I hardly think there will be much duplicate effort going on.
    Sorry, but this seems a little naive to me. I can see why you might think DSLs would permit specialists to more efficiently focus on solving their particular problems, and I don't entirely disagree, but even if it's true, I don't think it's controversial to think this will lead to considerably more duplicate effort.
    geniuz wrote:Also, in the world of OSS, there are multiple tools that can perform the exact same job. Do you for instance consider the existence of both of the mail clients Mutt and Alpine as duplicate effort?
    I haven't used Alpine, but if it's exactly like Mutt, then sure, I would certainly say that's duplicate effort. The more people who use one single piece of software, the more bugs can be filed against that software.
    Also, I think this is a false analogy from the start. Mutt and Alpine are both written in C. If we're talking about the connection between duplicate effort and DSLs, let's consider the fact that "communicating and storing computational models of biological processes" (from the Wikipedia page on SBML) could be better done in Lisp, Lex/Yacc, or with the Lemon C++ library, instead of coming up with some new way of using harmful XML.
    geniuz wrote:I still don't quite see how this can be interpreted as a necessary weakness or argument against more complex systems. Sure, DSLs can be dependent upon lower level languages, but if they are considered to increase the effectiveness and efficiency of certain experts, what exactly stops them from becoming dominant and continually evolving?
    The fact that higher and higher levels of specialisation are concomitant with smaller and smaller user bases who still need to communicate with experts in other groups. I'm not saying DSLs should never be used. I just think they are essentially self-limiting, and just as bacteria will long outlive us more complicated life-forms, so too will the lower-level languages long outlive more cumbersome DSLs.
    geniuz wrote:I wasn't implying computers will ever be able to mimic the human brain, and I'm not even sure whether it is something we necessarily want to strive for. All I was saying is that computers have already become indispensable tools in virtually every scientific and engineering discipline. They are computationally strong machines able to solve numerically involved problems at rates no human can ever hope to accomplish. It is this very aspect that will continue to guarantee the succes of computers, not AI per se. Again, I believe computers will never (at least not while I'm alive) be able to truly independently mimic and outperform the human brain, especially when it comes to aspects like creativity, i.e. the very aspects of human intelligence scientists have not even been able to understand and quantify to this date. Hence, humans will always remain "in the loop" to a large extent.
    This all seems reasonable.
    geniuz wrote:Don't forget that laws of physics are "laws" that have been defined and created by humankind for its own convenience. Even recently this year, practice has shown that a concept as fundamental as the speed of light might not be as accurate as it was so widely acknowledged by the scientific community. This however hasn't stopped mankind from using these fundamental "laws" to invent e.g. radio communication and electronic devices.
    I don't think you're disagreeing with me. I'm aware of the fragile nature of what we call the laws of physics - but like you say, they're good enough that we can do things with them. It looks like our knowledge of the speed of light breaks down on really large length scales, and it looks like our knowledge of gravity breaks down on really small length scales, but the brain is in the middle. In between, our models for how the physical world works are very accurate, and it is in this regime that the brain operates.
    Also, you should note that most scientists regard those neutrino test results as residing within the bounds of experimental error, and therefore not strongly indicative that the neutrinos really did break light speed.
    geniuz wrote:I haven't said low-level languages will be abandoned completely, I think they will remain to serve their purpose as a base upon which higher level languages (like DSLs) are built. In that sense, I believe that the user base of these low level languages will become more limited to computer scientists, i.e. to the people responsible for "formulating suitable abstractions to design and model complex systems" (source).
    Seems reasonable.
    geniuz wrote:Having said that, I still don't see why it so farfetched that for the rest of the world, physically telling a computer what to do in their native tongue as opposed to typing it in some generic-text programming language, will become the de-facto standard. Hence, I will reformulate my statement by stating that programming as most people know it today will eventually become a redundant practice.
    I don't think a friendly human interface should be considered the same as programming. This thread, if we recall the OP, is about programming languages of the future, not user interfaces of the future. I certainly agree that user interfaces will become more intelligent and attractive. I only disagree that this will have any strong impact on how we do programming.
    Last edited by /dev/zero (2011-12-12 19:20:59)

  • I Have Problems Because the System Ask Me For Serial Number, BUT I've Purchased the Creative Cloud, HELP

    The Problem is when i use the programs, the system ask me for a serial number, but i have purchased the Creative Cloud, instead the program always show the trial version, but again, i have purchased the all pack of Creative Cloud for 49 dollars, please, help

    You may refer below post :
    I paid for a yearly subscription and now it says I'm on a trial version of adobe creative cloud?????

  • I have the PE Mac 8 version and have downloaded the program.I opened the  initializer which halts 90% through checking my system profile. I have all the system requirements, what is wrong?

    I have the PE Mac 8 version and have downloaded the program.I opened the  initializer which halts 90% through checking my system profile. I have all the system requirements, what is wrong?
    Message was edited by: denconbe

    Yes I remove everything. I also have purchased the program and because I had this problem with the purchased DVD
    I downloaded the program thinking the purchased DVD was at fault but as I obtain the same result with both, there must be
    something wrong with my computer set up or it might be OSX 10.6.1 that is the problem! I will have to wait till monday.

  • I am trying to setup my new time capsule but it is not working. after entering the airport utility and locating the TC, after I tell the program to continue, the unit just disappear and the setup menu says there is an error. Any idea of what is happening?

    I am trying to setup my new time capsule but it is not working. after entering the airport utility and locating the TC, after I tell the program to continue, the unit just disappear from the menu and the setup menu says there is an error. I tried using the wireless connection, and also the cable, but none worked. Any idea of what could be happening?

    What are you setting it up as.. join wireless network .. the very worst setup, it will disappear.. reboot the whole network in order modem. router TC.. clients and it will likely reappear.
    Tell us what network setup you are using..
    If you setup with cable to a computer completely isolated from the network with TC also isolated.. finish the setup of everything you want. .before update.. then plug it into the network. .then restart everything in correct order.. it will work most of the time.

  • I am trying to install Adobe premiere elements 8 on my new computer (Windows 7). The program ansvers with "the program not installed or can be damaged".

    I am trying to install Adobe premiere elements 8 on my new computer (Windows 7). The program ansvers with "the program is not installed or can be damaged". Then aborts the installation.
    It`s right, the program is not istalld, it is  what i`m trying to do. And there is no problem whit the DVD. Any suggestions?

    "Error 1303: Installer has insufficient privileges" or "Error 1304: Error writing to file" | Install | CS3, CS4, CS5 pro…
    this link FIXED MY PROBLEM! i did the steps to the programdata\adobe folder and it installed FINE!

  • I keep getting calls from non existing area codes and phone numbers.  They are never the same number twice.  How do I stop this?

    About a week ago I started getting phone calls on my cell phone from numbers that do not exist, including the area codes.  I can not report these to the Do Not Call list because the area code is non existent.  I'm getting these calls all the time now and never from the same number twice so there's no point in blocking them.  If I answer I may or may not get a person who has an accent from India so heavy that I can't understand what they are saying.  This is getting to the point where I just want to cry I'm so frustrated.  Anyone else having this issue or does anyone know how to stop it?
    Thank you

    I'm sorry that you are having all these troubles. I have sent you a private message.
    Anthony_VZ
    **If someones post has helped you, please acknowledge their assistance by clicking the red thumbs up button to give them Kudos. If you are the original poster and any response gave you your answer, please mark the post that had the answer as the solution**
    Notice: Content posted by Verizon employees is meant to be informational and does not supersede or change the Verizon Forums User Guidelines or Terms or Service, or your Customer Agreement Terms and Conditions or plan

Maybe you are looking for