Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 15 of 15

Thread: DO WHILE LOOPING

  1. #1
    Junior Member
    Join Date
    May 2013
    Location
    Durban South Africa
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default DO WHILE LOOPING

    7. Write a driver class which contains methods:
    a. Write a method to input and return a number.
    b. Write a method to receive a number and to output if the number is even or odd.
    c. Write a method to receive a number and to output double the number.
    d. Write a method to receive a number add 100 to the number and output the answer.

    8. Write the test driver class to contain a menu with the following options:
    1. Even or Odd
    2. Double number
    3. Add 100 to number
    4. Exit


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,166
    My Mood
    Hungover
    Thanks
    141
    Thanked 597 Times in 512 Posts

    Default Re: DO WHILE LOOPING

    Did you have a question, or did you just want to dump your homework here?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    May 2013
    Location
    Durban South Africa
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: DO WHILE LOOPING

    can you code this progamm YES/NO?

  4. #4
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    571
    My Mood
    Sleepy
    Thanks
    9
    Thanked 84 Times in 78 Posts

    Default Re: DO WHILE LOOPING

    YES

  5. #5
    Junior Member
    Join Date
    May 2013
    Location
    Durban South Africa
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: DO WHILE LOOPING

    PLEASE HELP ME THEN

  6. #6
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    571
    My Mood
    Sleepy
    Thanks
    9
    Thanked 84 Times in 78 Posts

    Default Re: DO WHILE LOOPING

    Ok, post your code and ask specific questions. Posting my code is not helping, but spoon feeding.

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,166
    My Mood
    Hungover
    Thanks
    141
    Thanked 597 Times in 512 Posts

    Default Re: DO WHILE LOOPING

    Quote Originally Posted by njabulo ngcobo View Post
    PLEASE HELP ME THEN
    Just because we CAN code this does not mean we're going to simply do your homework for you. You're going to have to show some initiative.

    What have you tried? Where are you stuck?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    Junior Member
    Join Date
    May 2013
    Location
    Durban South Africa
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: DO WHILE LOOPING

    well I have coded and compiled this application and its runs the problem is test driver I just do not know how to create a menu (the last part in the question)

  9. #9
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,166
    My Mood
    Hungover
    Thanks
    141
    Thanked 597 Times in 512 Posts

    Default Re: DO WHILE LOOPING

    Does the menu have to be a gui? Or a command line interface?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  10. #10
    Junior Member
    Join Date
    May 2013
    Location
    Durban South Africa
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: DO WHILE LOOPING

    it has to be Graphical User Interface and must compile on J GRASP /J CREATOR OR NETBEANS

  11. #11
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,166
    My Mood
    Hungover
    Thanks
    141
    Thanked 597 Times in 512 Posts

    Default Re: DO WHILE LOOPING

    In that case, this is the tutorial on creating a menu. It is the first result for googling "java menus": How to Use Menus (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  12. #12
    Junior Member
    Join Date
    May 2013
    Location
    Durban South Africa
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: DO WHILE LOOPING

    UNFORTUNATELLY I do not have it on my laptop but its the test drive that I am confused with
    this is my test driver

    public class Numbers
    {
    public static void....
    {
    // suppose these are my methods in the driver class


    Number obj=new Number(); // creating a link between the driver class and the Test Driver

    int number=inputNumber(); //inputing the number from the keyboard

    int product=Double_number(number); //doubling the number and storing it in a variable I named product

    int sum=add_number(number); // adding 100 to the number and storing it in a variable I named sum

    obj.Check_Even_Odd..........bla bla bla. //calling other methods


    now my question is how do I code this
    8. Write the test driver class to contain a menu with the following options:
    1. Even or Odd
    2. Double number
    3. Add 100 to number
    4. Exit
    to be a menu
























    90;

  13. #13
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,166
    My Mood
    Hungover
    Thanks
    141
    Thanked 597 Times in 512 Posts

    Default Re: DO WHILE LOOPING

    You say your test driver needs to be a gui, but I don't see any gui code. Are you sure you aren't supposed to create a command line interface?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  14. #14
    Junior Member
    Join Date
    May 2013
    Location
    Durban South Africa
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: DO WHILE LOOPING

    axactlly CLI please code it for me

  15. #15
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,166
    My Mood
    Hungover
    Thanks
    141
    Thanked 597 Times in 512 Posts

    Default Re: DO WHILE LOOPING

    Quote Originally Posted by njabulo ngcobo View Post
    axactlly CLI please code it for me
    Absolutely not. Asking people to do your homework for you again will get you banned. This is your final warning.

    If you want help, you need to ask a more specific question. What have you tried? What about this is giving you trouble? What specific step are you stuck on?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Looping Over and Over Again?
    By avalanche72 in forum Loops & Control Statements
    Replies: 1
    Last Post: February 1st, 2012, 04:11 AM
  2. Need help with looping!
    By crsoccerplayer6 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 29th, 2011, 04:09 PM
  3. Help in looping
    By endframe in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 28th, 2010, 02:24 PM
  4. need help looping with a string
    By beandip408 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 29th, 2010, 09:08 AM
  5. [SOLVED] looping, for,while,do-while.
    By chronoz13 in forum Loops & Control Statements
    Replies: 4
    Last Post: August 6th, 2009, 01:32 PM