Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help with java Aasbcoe AaBbC AaBboct AaB AaBbo Normal 1 No Spac... Heading 1 Heading 2 TitleSubtitle Subtle Em.. Emphasis Styles Assignment 4 Question
Need help with java
Aasbcoe AaBbC AaBboct AaB AaBbo Normal 1 No Spac... Heading 1 Heading 2 TitleSubtitle Subtle Em.. Emphasis Styles Assignment 4 Question 1 (40 points) Input and Nested If Statements and Functions s assignment is more exercise with conditional statements and code to make your program more obust. It builds on what you learned in the previous assignment in that you must now use else conditions and conditional blocks. This assignment should help you remember how to use if, else, blocks, and nested if statements in case you need a refresher The exercise is designed in a special way to show you how you should write large programs by adding a little bit refactoring Start by creating a function to get in integer from user input. Name that function, getUserValue_step10. To show your work increments, implement each step as a separate function called getUserValue step20. getUserValue step30. getUserValue setp40 and getUserValue setp50. Each time, copy the code from the previous step, and then add the new modifications to the new function. Be aware that you will not always be adding to the end of the new function, and may even have to rearrange the order of the previous pieces, in order to satsfy the new expectations presented in one or more of the steps. To test your code, call the function for whichever step you are working on from maino at a time. Please do these steps one at a time. The practice you will follow is called step1. Write the code that prompts the user to enter an integer between I and 20 (inchuding 1 and 20) reads the value using Scanner, and then prints the value that they entered in a statement that begins with "You entered a " step2. Add more code or modify your code so that if the user enters a value that is less than I or greater than 20, it prints out The value you entered is not between 1 and 20. Otherwise, and only if the value is between 1 and 20, it prints the statement as before step3. Add more code or modify your code so that if the user enters the values 8, 11, or 18, the statement that is printed is "You entered an" instead of You entered a" Note in putting these things in a particular order, that testing for 8. 11, and 18 makes more sense if you already know that the number is between 1 and 20 step4. Add more code or modify your code so that if the user enters something that is not a number ie. includes letters, your program does not print any of the above lines but instead prints out "Idiot Your input could not be read as a number. Get a life! Again, note that it doesn't make sense to test something to see if it is between I and 20 if st isn 't even a number. So sequence your tests in a logical order of ruling out the various cases Step5. Add more code or modify your code so that if the user enters something invalid or an mteger not between 1 and 20 print invalid input and keep asking the user to imput a number until a valid number between 1 and 20 is entered and then prints out the correct response Include comments in your code to explain what each of the fif statements is testing. Zap the java file in a single zip file and submit the zip file may discuss assignments with other students, but you must do your work separately. Do not submit a copy of the same work as another student. Question 2: (60 points) Same problem as in Assignment 3. But redo where your pick number is a string of three digits and the Winning number is a 3 digit number generated randomly converted into a string. You can reuse the code from Assgn 3 but use all string operations instead of integer operations. The user wins according to the following rule: If the user input matches the lottery in exact order, the award is $10,000. If all digits in the user input match all the digits in the lottery number, the award is $7,000. If two digits in the user input match two digits in the lottery number, the award is $4,000. . If one digit in the user input matches a digit in the lottery, the award is $1,000Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started