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 4 of 4

Thread: Beginner Java Course, Stuck on my First Assignment. Help Needed.

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Beginner Java Course, Stuck on my First Assignment. Help Needed.

    I am taking my first Java course and I am stuck on my assignment which is the following:

    Write a java program that prompts the user to input two integer values, swap the values of two variables (don’t just display them in opposite locations), and then display the swapped values back to the user.

    I have an idea of what it is supposed to look like:

    Please enter two values:
    Value #1 = 1
    Value #2 = 4
    Swapping…
    Value #1 = 4
    Value #2 = 1

    I understand that i have to use the Scanner object to get the user inputs and I understand how to prompt the user to insert values. What I really need help on is the "swapping" of the values and displaying them back to the user.

    Any help is really appreciated. Thank You.
    Last edited by jlcarrillo; September 12th, 2014 at 01:36 AM.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,034
    My Mood
    Mellow
    Thanks
    184
    Thanked 646 Times in 633 Posts

    Default Re: Beginner Java Course, Stuck on my First Assignment. Help Needed.

    Welcome to the forum! Please read this topic to learn how to post code correctly and other useful info for new members.

    Start with what you know and code/test that. Come back with that code and ask for help with the next part, if you still need it. Be sure to post your code correctly per the above link.

  3. #3
    Junior Member
    Join Date
    Sep 2014
    Location
    Mumbai
    Posts
    7
    My Mood
    Fine
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Beginner Java Course, Stuck on my First Assignment. Help Needed.

    Try to build logic and if it do not workout post the algorithm here we will try to help you.Building logic is the very important part of programming.so try yourself.

  4. #4
    Junior Member
    Join Date
    Sep 2014
    Location
    India
    Posts
    13
    My Mood
    Worried
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default Re: Beginner Java Course, Stuck on my First Assignment. Help Needed.

    first of all...get the two values that is to swap from the user with the help of scanner object.... then you can swap the values by taking a third temporary variable that stores the value of the first two variables temporarily, one by one, for sometime.

Similar Threads

  1. Java beginner - help needed!
    By Mace in forum Object Oriented Programming
    Replies: 1
    Last Post: August 29th, 2014, 03:58 AM
  2. Help needed in deadlock assignment using java
    By prince143 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 13th, 2014, 03:36 PM
  3. Beginner... stuck on how to use FormattedFields in java for inserting dates
    By Interface123 in forum Java Theory & Questions
    Replies: 4
    Last Post: February 11th, 2014, 06:15 AM
  4. Java Beginner. Help needed.
    By Jack1 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 3rd, 2013, 12:18 AM
  5. Help me with my 1st Java Assignment! Stuck!!
    By adnan.alvee in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 2nd, 2013, 06:55 PM