"a menu must be provided that asks the user of the software what task they would like to perform; it then activates the required task. The menu should loop until the user requests to exit"- that is the requirement. And i haven't learn about switch-case. So how can i create my menu? thanks
vincecamha
0
Newbie Poster
Recommended Answers
Jump to PostStart a loop
Print the menu using System.out.println
Get the user's input using a Scanner
if the input was "exit" then break out of the loop
use a switch to invoke the appropriate action
(end loop)
Jump to PostOK. You don't need to use a switch, you can do the same thing with a lot of if tests. Similarly, you don't need break, you can use a while loop to keep looping as long as the input is not "exit".
Jump to Postyes, it goes like this (pseudo code)
input = "" while (input is not "exit") prompt user with menu choices get user input if (input is abc) do task abc else if (input is def) do task def (etc)
Jump to PostOr see it as a good reason to start reading about switch statements :)
Never be afraid to experiment and learn something new.
All 13 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
vincecamha
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
vincecamha
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
vincecamha
0
Newbie Poster
jwenting
1,889
duckman
Team Colleague
vincecamha
0
Newbie Poster
stultuske
1,116
Posting Maven
Featured Poster
Lewin Villar
0
Newbie Poster
jwenting
1,889
duckman
Team Colleague
iamthwee
vincecamha
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.