Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For Java NetBeans 1) Using NetBeans, create a new project called MidTerm, import the appropriate packages for scanner and random, and create a scanner and

For Java NetBeans

1) Using NetBeans, create a new project called MidTerm, import the appropriate packages for scanner and random, and create a scanner and random object at the very beginning of your main method. There should be no "Class level" variables for this midterm. All variables will be passed through methods.

2) Prompt the user for their name and store that name somewhere. (Perhaps a String called userName.)

3) Create a method to display a menu. This method should have 1 parameter and returns nothing. When this method is called it should receive the user's name, great the user, and ask them to make a selection. 1 - Change your name, 2 - Test your IQ, 3 - Display a table, 4 - Play a game, 5 - Exit. (You are only displaying the menu in this method. Use a variable back in the main method to get the user's input on the next line after calling this display menu method.)

4) In your main method setup a do-while. Decide how you will keep the do while running. (hint: see #3 above...) In the do-while you should display the menu, get the user's selection, and check the user's selection using a switch statement.

5) Create a method to change the user's name. This method will receive a String and a Random object when called, and return a String. In this method you will: Display the current name, figure out how long it is, assign a new random char to each letter of the new name making sure the new name is the same length as the old name and the first letter is capitalized (The table at the bottom of page 125 should help with this). Return the new name and display the new name for the rest of the program.

6) When the user inputs 1, back in the main method, call the method you created in #5, send the user's name and the random object you created as arguments to the method. Assign the returned value to the user's name.

7) Create a method that will be used to test an IQ. This method will receive a String and a Random object when called, and return an int. In this method you will: create a new Scanner object, say hi to the user by name, get 2 random numbers between 0 and 49, and ask the user what the sum of the 2 numbers is. If the user is correct, display "Great Job!" and then assign IQ the value of 100 plus the sum of the 2 numbers. If the user is incorrect, say "No, the answer was...", display the answer, and assign IQ the value of 10 plus the sum of the 2 numbers. Return IQ.

8) When the user enters 2, back in the main method, call the method you created in #7, send the user's name and the random object you created as arguments to the method. Display the returned value as the user's IQ.

9) Create a method that will be used to create a table. This method will receive a String when called and will not return anything. In this method you will: create a new Scanner object, prompt the user (using their name) for a letter, prompt the user for a number from 1 to 10 (n), make sure the number is not less than 1 or greater than 10 IN ONE STATEMENT, if number is less than 1 or greater than 10 set it to 10, use for loops to display an n x n grid of the letter entered.

10) When the user enters 3, back in the main method, call the method you created in #9, send the user's name as an argument to the method.

11) Create a method that will be used to play heads or tails. This method will receive a String and a Random object when called and will not return anything. In this method you will: create a new Scanner object, ask the user (using their name) to choose heads or tails, randomly decide whether heads or tails has been chosen, if the user wins display their input and the randomly generated value and tell them they have won, if they lose display their input and the randomly generated value and tell them they have lost.

12) When the user enters 4, back in the main method, call the method created in #11, send the user's name and the random object to the method.

13) When the user enters 5, back in the main method, display "Thanks for playing! Please come back again!" Make sure the loop no longer executes.

14) When the user enters any number other than 1 - 5, Display "Try again...".

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

Answered: 1 week ago

Answered: 1 week ago