I need help please if you can aid me in my quest to write this code

I am trying really hard to accomplish this and my head hurts from trying mulitple ideas on the right code.A lottery requires that you select six different numbers from the integers 1 to 49. Write a Java program that will do this for you and generate five sets of six numbers as a result.
Details:
For generating random numbers you can use the random() static method of class Math. It returns a double so you will need to cast it as an integer. If you set the range to 49, you can generate a random number between 1 and 49 through:
number = (int) ( range * Math.random() ) + 1;
Note that you need 5 sets of numbers and in each set you have should have six different numbers. There should not be duplicate numbers within each set. Of course the same number can occur in multiple sets, but within the same set of 6 numbers it should only occur once, if at all.
Here is an example of a valid set of numbers: 5, 41, 3, 9, 22, 30
Here is an example of an invalid set of numbers: 15, 8, 19, 33, 8, 21
It is invalid because the number 8 appears twice.
This is the dilema the code I have so far (I know it is not much) is import java.util.Scanner;
import java.util.Random;
public class Lottery
public static void main(String[] args)
          int[] numbers = new int[6];
number = (int) (range 49 Math.random() ) + 1;
am I on the right track totally wrong or???? Please help me and god bless

Tinkerbell... wrote:
Navy_Coder wrote:
Tinkerbell... wrote:
Navy_Coder wrote:
Yeahhhhh, don't do that...Why not?because you butchered an otherwise simple process by the whole generic list with 50 numbers and sorting mess.
java.util.Random. <-- learn how to use it.Well, please explain how you would better do it using java.util.Random then?
Random r = new Random();
int[] vals = new int[6];
for(int i = 0; i < vals.length; i++ )
    vals[i] = (r.nextInt(49) + 1);

Similar Messages

  • Iphone, i really need help, please if you REALLY!! know help me

    hi, I want to buy an iPhone but i want to know if it is good, because i really want it, my question is: if i buy an iphone from united states can i use in Costa Rica? or ther is any dammage?
    Thanks a lot!

    An iPhone from the US will be carrier locked to AT&T. The phone can roam on ICE in Costa Rica, but the voice and data rates are very expensive. Also, calls while roaming are limited to within Costa Rica and to the US. In any event, AT&T will not activate an account for you unless you live in their service area. None of the phone's features will work until it is activated by AT&T.
    At this time, the iPhone is not offered for sale in Costa Rica. Check this Apple article for changes: http://support.apple.com/kb/HT1937
    You should wait until the iPhone is available in your country or look at the linked article to find where you can buy an unlocked phone. Another thing to think about, the iPhone's warranty requires it be returned to the original country of purchase for service.
    Have you looked at getting an iPod Touch? http://www.apple.com/ipodtouch/ It has everything except the phone, camera and GPS. Cellular data is not possible but WiFi is.

  • Please..need help now if you can..sent prev. post

    got this message today. Core audio: System Overload. The audio engine was not able to process all required data in time....recently got some waves plugs. Running an L3 Lin MB Eq on the OUT fader and a doubler on a track. MAybe 5 buses and 13 tracks with logic plugs. Seems like my system should be able to handle this. Any suggestions?? buffer size is 512. ram 5gigs. 24bit 96k session

    My 1st guess is the
    Lin MB Eq on the OUT fader
    512@96 is the time you are giving to process the entire chain ( in to track to bus to master... ), in this case - probably not enough if you think about it from a sample sized signal flow perspective including what needs to be processed in what time. That plug is probably requesting a fair amount of lookahead, etc - depends on your PDC settings. What do your system performance meters show? At some point, there is probably just an odd bottleneck bringing Logic down if you expect much more and are familiar with your tools. It's up to you to try to find exactly where it is. Some plugs won't operate at smaller buffer sizes ( keep SR in mind ) - or will cause Logic to falter, or even cause Logic to look like it's working - but produce no sound.
    J

  • Mr. Steven help please : How you can pass paremeter by(ADF)

    if you have two tables
    (table a : E_mail{primary key},a_name)
    (table b : E_mail{primary key},b_name)
    & the relation between this tables by {E_mail} .
    I create view have this two table(two entity) , but i hide the fields
    E_mail & b_name from (table b) , then i drag and drop this view to JSP
    page called (saveData) and put Commit and create . So, what i need ?
    When i commit the page(saveData)i want put E_mail from (table a) to E_mail(table b)
    How i can do it ?????
    ==> if you have an example please give it to me ?

    I am working with JDev 10.1.2
    -what i did ?
    -(1)I create view have the entity objects(from two table) named : testview-
    (2)i am go to java file of the view(testview) and write :
    public void seta_Email(Number value)
    setAttributeInternal(a_Email, value); //from table A
    setAttributeInternal(b_Email, value); //from table B
    protected void create(AttributeList attributeList)
    a t1 = get_a();
    b t2 = get_b();
    try
    t1.create(attributeList);
    t2.create(t1);
    }catch (JboException ex)
    t1.revert();
    t2.revert();
    throw ex;
    (3)then i am go to AppModule(javafile) and write :
    public void account()
    ViewObject vo = get_bView1();
    vo.clearCache();
    vo.setMaxFetchSize(0);
    vo.executeQuery();
    Row newRow = vo.createRow();
    vo.insertRow(newRow);
    newRow.setNewRowState(Row.STATUS_INITIALIZED);
    vo.setCurrentRow(newRow);
    (4) .................
    then what i do ????
    please Mr.Steven tell me what's next step ???

  • DVD from Animations - Help please if you can

    We have an 3min animation sequence that needs to be put to DVD.
    Animation was created in Maya, it's a 3D building walkthrough, constant movement.
    It is supplied as AVI (video track is WRAW) 720x576 (for PAL)
    We have placed it on FCP sequence set to Animation, best, millions colours, keyframe every frame.
    Sent to compressor - 8Mbps CBR, best motion, GOP size =7 / Structure =IBP, closed.
    The resulting M2V looks fine in QT
    It also looks fine in DVDSP Simulator
    However the DVD created (from an image) both in Apple's DVD player and on set top players looks badly pixelated, grainy and flickery.
    Is there something in the make up of the animation that doesn't suit DVD playback? Why wouldn't we see it in the Simulator?
    Any help greatly appreciated.

    Thanks Colin,
    I have exported the supplied file as QT movies using different QT Codecs, DV PAL, Animation, Motion JPEG, also DV stream. If the option is there I have set the field order to Lower first. I have also imported the supplied AVI to FCP onto sequences with differing compression settings as above. All produce the same effect.
    I have exported the AVI from QT as an image sequence, once as is and once with the deinterlace ticked in movie properties and imported each image as a frame to FCP onto a DV PAL timeline, this you would think would work around any issue of field order and behave as the sequence settings dictate? I get the same result, the final DVD image looks fine in DVD Player, unless you UNTICK "deinterlace" (which is wierd in itself), then it flickers badly, as does a DVD written from the image.
    The best result I have had so far is following your instructions (thanks) in another post for 24fps NTSC, the final DVD was not flickering anywhere as badly but motion overall was a bit jittery. Is there a work around for animation like this with PAL do you know?
    Also - maybe this might be a clue?
    When I have the clip looking fine in FCP as a DV clip or image sequence on a DV timeline, with the play line stopped or running, the Canvas ONLY looks good at 100%, anything smaller or larger creates this striping moire effect on the image, visible even with the play line in stop.

  • Need help, please! how can i close the iexplore?

    Hi!
    i wrote a application, which start the internet explorer with the following code segment:
    /* cmd = 'rundll32 url.dll,FileProtocolHandler http://www....' */
    cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    Process p = Runtime.getRuntime().exec(cmd);
    it works very well, but now i would like to close the internetexplorer and this is my question. How can i close the iexplore?
    with p.destroy(), there is nothing
    please, can anyone help me?
    sorry, i hope my english is not to bad, i came from austria!
    mfg, volkmar

    I've found it.
    i can close all internetexplorer with
    Runtime.getRuntime().exec("taskkill /F -IM iexplore.exe");

  • Help, please (if you can) !!

    I'm using HomeSite for my web pages, and have for years.  Recently I got a new computer, with Windows 7, (previously running under XP) and tried running HomeSite on it.  For some reason it doesn't seem to want to run.  The configuration wizard starts up and I get this:
    Clicking 'next' brings up this:
    And 'finish' brings up this:
    I can still run it on my old computer, but that's a pain as it's agonizingly slow (really old!) and then I have to transfer the files, etc. etc.
    Any help someone can give would be greatly appreciated.  Have tried searching for that error message without much luck.
    Thanks!
    Maggie

    Sorry... I put in scrren shots, but didn't do it correctly.
    First one;
    Second one:
    Third one:
    Hopefully this will work!
    M

  • HT204088 hi i need help please if anyone can

    Hello i have a problem and i need to dispute a charge. I never made this charge and i was wondering how i could dispute or something. 

    To Contact the Mac App Store Customer Service:
    http://www.apple.com/support/mac/app-store/contact.html?form=account
    To Contact iTunes Store Customer Service:
    Apple - Support - iTunes Store - Contact Us

  • TS3694 My iPad won't update software saying it can 't connect to the Internet which is not true as you can see from me being able to write this. there is no error code. It just says unable to verify, try again later. Any suggestions?

    My iPad won't update iOS 7.0.4 software saying it is unable to verify because it can 't connect to the Internet and to try again later.  It doesn't display an error message number. Obviously I can connect otherwise you wouldn't be reading this. Any suggestions? Many thanks for your help.

    You didn't specify which way you are trying to update - using the Software Update setting on the iPad or by using iTunes. I will assume that you are using iTunes because the kb article that linkd you to here was the one about iTunes error codes.
    Quit iTunes, reset your iPad, restart your computer and try again. Disable your firewall and antivirus software of you are using it.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I can se

    Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. When I playing game I can see what someone else trying connecting to my game And I don't know what to do.So if you can help me please? I don't wanna lose my game. 

    Hello Vaidas Vaidas,
    It sounds like you are noticing someone else is accessing your Clash of Clans data by playing the game and you have tried to reset your Apple ID password. If you are following the steps outlined in this article:
    Apple ID: Changing your password
    http://support.apple.com/kb/ht5624
    What is preventing you from changing your password? Any error messages or prompts?
    Thank you for using Apple Support Communities.
    All the best,
    Sterling

  • My iPhone 6 can't find my macbook pro on the airdrop list, although everything is in place, bluetooth, wi fi gets, need help please ?

    My iPhone 6 can't find my macbook pro on the airdrop list, although everything is in place, bluetooth, wi fi gets, need help please ?

    Dear Niel, thank you but my mac is (MacBook Pro (Retina, 15-inch, Early 2013).
    and i can send from it to my iPhone , but not vice versa

  • HT1199 I need your help, PLEASE. How can to fix "NO MOUNTABLE FILE SYSTEM" error of my back up hard drive on Mountain Lion OS?

    I need your help, PLEASE. How can to fix "NO MOUNTABLE FILE SYSTEM" error of my back up hard drive on Mountain Lion OS?

    Did you format the drive for Mac use before you tried to use it as a backup drive?
    Are you using Time Machine on the drive? You can't view the contents of its backup database and the only way to access the info is directly from the Time Machine app.

  • My MBP didn't recognise my password, started it in safe mode, I can see my files, but I don't know what to do next, as the image of reset password isn't selectable. I just moved from PC. Need help please...

    My MBP didn't recognise my password, started it in safe mode, I can see my files, but I don't know what to do next, as the image of reset password isn't selectable. I just moved from PC. Need help please...

    Safe mode is not what you want in this case. Reboot to recovery mode - hold down cmd-R as the Mac reboots. Go past the language-selection screen, click the Utilities menu, then Terminal. Type:
    resetpassword
    Followed by the return key, and follow the prompts. Reboot normally when done.
    Matt

  • I can not play any games on the new ipad 32 G wifi after take over to  oversea , need help please

    After I turn off Airplane mode and I want to play games when was downloaded before fly to oversea. I was palying all games on ipad before fly.
    now when I turn on ipad and want to paly games but It can not play games on ipad.???
    Anyone can fit it on setting?
    Need help please.
    Thank you.

    OK. I am having a little bit of trouble understanding your responses, but let's start with this since you are having an issue with other apps as well.
    Reboot your iPad.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. Let the iPad start up completely and then try again.

  • HT204380 I can't access my FaceTime and messages through my iPod touch, I need help please!!!

    I can't access my FaceTime and messages through my iPod touch, I need help please!!!

    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
    Using FaceTime and iMessage behind a firewall
    http://support.apple.com/kb/HT4245
    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/
    Unable to use FaceTime and iMessage with my apple ID
    https://discussions.apple.com/thread/4649373?tstart=90
    For non-Apple devices, check out the TextFree app https://itunes.apple.com/us/app/text-free-textfree-sms-real/id399355755?mt=8
    You posted in the iPad forum instead of the iPod forum. To get answers to your question, next time post in the proper forum. See https://discussions.apple.com/index.jspa  I'll request that Apple relocate your post.
     Cheers, Tom

Maybe you are looking for