Northern Virginia Community College Java Program Worksheet
Purpose – to practiceWriting and invoking methods
Using multiple arguments
· Creating and using a method in another class
Problem Statement
Code a Java program and a method.
Phase 1
• In the Main(), Ask the user to enter an amount they wish to bet and which game they want to play.
Pass the bet and game as an arguments into a method
Your method will validate based on these rules
o if the game is poker, the bet amount must be in the range of $50 to 500.
o any other game, the bet amount must be in the range $10 to $100
Return the validated bet amount to the main().
Print a message in the main. “Thank you for your bet of $
for the game of
Phase 2 – Required
Invoking a Method from another Class
. Move the method out of your program Class and into a file in the same folder as your Main().
Phase 3 – Optional Challenge
• Write the bet amount to a .txt file.
.
Required Material to be Submitted to Canvas
A copy of your MAIN program source code saved to a .TXT file
• A copy of your methods CLASS source code (ex. MyMethods.class)
• A screen capture of your program being executed, with the result showing
Phase 3 – Optional Challenge
Write the bet amount to a .txt file.
nts
Required Material to be Submitted to Canvas
• A copy of your MAIN program source code saved to a .TXT file
A copy of your methods CLASS source code (ex. MyMethods.class)
. A screen capture of your program being executed, with the result showing
Your source code must include the following comment code at the beginning of your program:
// Lab #1
// Name:your name
PS
4/7
Lab 5c
ing
dations
Criteria
Ratings
Pts
invoke method from another class
3 pts
Set up method header
3 pts
Return variable to main()
2 pts
Print message in the Main()
1 pts
Overall
1 pts
Total Points: 10
< Previous
Next >
M +
F3
D
to
F4
C
PrtSc
F5
F6
F7
F8
F9
F10
F11
F12
%
&
*
#
3
in t
&
4
(
9
5
6
7
8
0
Top-quality papers guaranteed
100% original papers
We sell only unique pieces of writing completed according to your demands.
Confidential service
We use security encryption to keep your personal data protected.
Money-back guarantee
We can give your money back if something goes wrong with your order.
Enjoy the free features we offer to everyone
-
Title page
Get a free title page formatted according to the specifics of your particular style.
-
Custom formatting
Request us to use APA, MLA, Harvard, Chicago, or any other style for your essay.
-
Bibliography page
Don’t pay extra for a list of references that perfectly fits your academic needs.
-
24/7 support assistance
Ask us a question anytime you need to—we don’t charge extra for supporting you!
Calculate how much your essay costs
What we are popular for
- English 101
- History
- Business Studies
- Management
- Literature
- Composition
- Psychology
- Philosophy
- Marketing
- Economics