103 Replies
⌛
This post has been reserved for your question.
Hey @zeus! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Implement a menu system to allow the user to perform the following operations:
• View Account: Display the user's name and balance.
• Deposit Money: Prompt the user to enter an amount to deposit. Update the balance
accordingly.
• Withdraw Money: Prompt the user to enter an amount to withdraw. Ensure that there
are sufficient funds before performing the withdrawal.
• Check Balance: Display the current balance
i do not know how
its part of my hw
Which part of that is the issue? What UI framework are you using?
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Where can i learn methods
I kinda missed the class
U mean what i write to write the code?
If you are looking for a Java course, consider https://java-programming.mooc.fi/ which is a free course on Java Programming from the University of Helsinki.
When doing the course, it is recommended to use Eclipse or IntelliJ instead of NetBeans.
Netbeans if thats wym
Swing? JavaFX? Something else?
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
I overread tthat part lol
anyways for methods: https://dev.java/learn/classes-objects/
Dev.java: The Destination for Java Developers
Classes and Objects - Dev.java
Defining your own classes, declaring member variables, methods, and constructors.
confusion
its my first year so yeah
wasnt useful
couldnt find what my teacher asked for
he gave a example
of how the program should be
may i send it
output
what does he mean by implement a menu system
im so confused and i only have 2 hours left
idk what you want to know
ok so
im stuck here
what do i do for the other numbers
What do you want to do?
First you can use else-if
if user inputs 2 sout etc
use an else-if
havent studied that
could u help
Dev.java: The Destination for Java Developers
Control Flow Statements - Dev.java
This section describes the decision-making statements, the looping statements, and the branching statements supported by the Java programming language.
I think that site can explain it better than me
but essentially it means:
- if number is 1, do XYZ (you already have that)
- if not and the number is 2, do something else
- if none of the previous conditions are true and the number is 3, do ...
- etc
how do i add the useres deposit
to the initial balance
What exactly should happen?
so if the user wants to deposit x money to x balance
What exactly should the program do?
Should it ask the user for input?
Should it change variables?
Should it output something?
so the user wants to deposit 500 to his account
How does the program know?
how do i update the balance to x + 500
x which is the balance before the deposit
Yeah but how does the program know about it being 500?
input from the user
So it needs to ask the user for input
ye
ok so first you want to do something if the user enters 2, right?
yes
so i use else if
yes
Initial balance = initial balance + the amount of the deposit
?
looks good so far
Are you using Eclipse or IntelliJ?
If this is Eclipse, press Ctrl+Shift+F.
If it's IntelliJ, press Ctrl+Alt+L.
This should reformat your code.
none
its net beans
yes except that it needs to get the amount of the deposit from the user first, right?
yeah
Alt+Shift+F I think
Do you know how to get it?
@dan1st | Daniel
whats wrong here
you need to put the else if after the
}
of the ifso i need another if?
no for the corresponding else if
see this
@dan1st | Daniel
same as before
@dan1st | Daniel
im done but i have one last problem
how do i make the menu repeat the menu
unless the user enters number 5
You can use a loop
howw and where
around the whole thing you want to repeat
so after the number 4?
what do i write idk
What do you want to repeat?
Where should it continue if you don't exit?
ok so
after user chooses 1
it gives name and balance and ends
i dont want it to end i want it to display the menu again
Should the
println
s be repeated as well?and again until the user chooses option num 5
ah ok
then you probably want to include everything except the menu in the loop
Do you know how loops work?
so for (number>5; number++)?
Do you want to count anything?
I think you want a
while
or do
-while
loopso while (number>5 then what
So you want to repeat it as long as the number is >5?
yes
if user enter 5 i want it to
break
btw
Do you want to repeat as long as the number is >5?
break didnt work so i used return
Or until the number is >5?
is that ok
at 5 i want it to break
so less than 5 ig
I don't know whether your teachers are ok with you using
return;
like thatits a presentation
so i think he would give me extra marks
for
doing somth diff
idk
so how do i make it
repeat itself
you make the loop depend on number
Note that I used
!=
here meaning it repeats as long as it isn't 5
you can also use something elseit repeats the account balance
instead of the menu
Is the part reading the number inside the loop?
You can split the
int number = sc.nextInt();
into two statements
int number = 0;
creates the number variable
and number = sc.nextInt();
sets it to a variable from the input
Also don't forget about the curley braceswill that fix
the problem
Note that you'd need to put that before the loop
How do statements in Java end?
you should use the correct names
and that
confused
arent they correct
Java is case sensitive
nextint
still doesnt work
no
nextInt
lastly where do i put the while
As I said, the loop should be around everything you want to repeat
it's a block withh
{}
like if.
which loop
my brain hurts
the if
i tried still doesnt run
ok now ir runs
but it wont stop running
the while loop
if isn't a loop
Can you show your code?
is this good now
nice
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.