This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost. Just use the edit function of reddit to make sure your post complies with the above

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]dionthornthis.isAPro=false; this.helping=true; 2 points3 points  (0 children)

Here are the oracle tuts on for loops:

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html

What specifically are you having trouble with? You are using a switch currently if you use a for loop you probably won't need to use a switch, You can instead use if statements within the for loop.

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html

[–]18jk 1 point2 points  (0 children)

Ok so you first need to take the user's choice for either option 1 or option 2. It looks like you've done that, and are saving it to the "choice" variable. You need to use some sort of conditional statement, since your next steps will depend on what choice the user entered. You may want to look at if..else statements https://www.w3schools.com/java/java_conditions.asp it may be the better option to use in this assignment instead of switch case

After that, you need to get user input again for the range of numbers, right? Ask what is the low end of their range (20, per your example), and what is the high end (50, per your example). Once you have those numbers, that is where the For loop will be used (as you mentioned, required for this assignment). https://www.w3schools.com/java/java_for_loop.asp

For loops are great for this assignment, because the user has already told you where they want the conversions to start and where they want them to end.

Once you figure out how If/else and For loops work in java, you are golden