Results 1 to 7 of 7
  1. #1
    Proera92 is offline Member
    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Default Need help with a java assignment

    I need help making a java program that allows the user to enter two numbers, and the program should list multiples of the first number to check if the second number is a multiple of the first. If it is, then the player gets +2 score, and if its not then the user gets -1, the user starts of the 0 score. The loop breaks when the value of the multiple exceeds 1000, and the program is supposed to ask the user to play the game as many times as they want as long as they have a POSITIVE score.

    Due tommorow :|

    Can anybody help me start?

    That would be great! Thanks.

  2. #2
    Wnt2bsleepin is offline Senior Member
    Join Date
    Feb 2012
    Posts
    219
    Rep Power
    3

    Default Re: Need help with a java assignment

    What code do you have so far?

  3. #3
    Proera92 is offline Member
    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Default Re: Need help with a java assignment

    Here's what I got so far:
    Java Code:
    import javax.swing.*;
    class GuessMultiple{
    public static void main(String str[]){
    int value = 0;
    double firstnumber, secondnumber;
     
    String input1=JOptionPane.showInputDialog("Enter your first number");
    firstnumber=Double.valueOf(input1).doubleValue();
    System.out.println("First number:" +firstnumber);
     
    String input2=JOptionPane.showInputDialog("Enter your second number");
    secondnumber= Double.valueOf(input2).doubleValue();
    System.out.println("Second number:" +secondnumber);
     
    	}
    }
    I don't know how to make the first number multiply by 1, 2, 3 etc and make it check that it equals to the second number.

  4. #4
    Wnt2bsleepin is offline Senior Member
    Join Date
    Feb 2012
    Posts
    219
    Rep Power
    3

    Default Re: Need help with a java assignment

    I think you are going about this the wrong way. How else would you determine if the second number is a multiple of the first? It doesn't require any loops or anything. It also does not need any multiplication.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,556
    Rep Power
    25

    Default Re: Need help with a java assignment

    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default Re: Need help with a java assignment

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    foulkelore is offline Member
    Join Date
    Dec 2012
    Location
    Des Moines, IA
    Posts
    35
    Rep Power
    0

    Default Re: Need help with a java assignment

    So you got some place to start and thats a good thing. What I do is think of the assignment as a bunch of small items and not as one big item. Next work on figuring out if the number is a multiple of the other number or work on putting what you have into a simply while loop, then move on to the next.

    Keep compiling and running your program everytime you have a change. This will help when you find a problem, it should be in the last bit you worked on and you don't have to search the whole thing to find whats wrong.

Similar Threads

  1. jAVA Assignment Help
    By tonespy in forum New To Java
    Replies: 6
    Last Post: 12-17-2012, 12:34 AM
  2. Help with java assignment
    By jason3460 in forum New To Java
    Replies: 6
    Last Post: 12-04-2012, 10:47 PM
  3. Need Help with Java Assignment
    By smurf67 in forum New To Java
    Replies: 4
    Last Post: 03-26-2011, 10:25 AM
  4. Java assignment.
    By jmsjames in forum New To Java
    Replies: 14
    Last Post: 12-07-2010, 03:18 AM
  5. Help with my assignment java
    By toby in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •