Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Object-Oriented Programming [Needs Solve Code very shortcut And Code Should run more fast] Programming Language: Java 1. (Check password) Some websites impose certain rules for

Object-Oriented Programming [Needs Solve Code very shortcut And Code Should run more fast]

Programming Language: Java

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
1. (Check password) Some websites impose certain rules for passwords. Write a method that checks Whether a string is a valid password. Suppose the password rules are as follows: I A password must have at least eight characters. I A password consists of only letters and digits. I A password must contain at least two digits. Write a program that prompts the user to enter a password and displays Valid Password if the rules are followed or Invalid Password otherwise. 2. (Phone keypads) The international standard letterfnumber mapping for telephones is shown below. Write a method that returns a number, given an uppercase letter, as follows: int getNumber(char uppercaseLetter) Write a test program that prompts the user to enter a phone number as a string. The input number may contain letters. The program translates a letter (uppercase or lowercase) to a digit and leaves all other characters intact. Here is a sample run of the program: Enter a string: LBW-Flowers luau-r 1-800-3569377 Enter a string: 1800f'louers IIhr 18003569377 3. (Game: craps) Craps is a popular dice game played in casinos. Write a program to play a variation of the game, as follows: Roll two dice. Each die has six faces representing values 1, 2, ..., and 6, respectively. Check the sum of the two dice. If the sum is 2, 3, or 12 (called craps), you lose; if the sum is 7 or 11 (called natural), you win; if the sum is another value (i.e., 4, 5, 6, 8, 9, or 10), a point is established. Continue to roll the dice until either a 7 or the same point value is rolled. If 7 is rolled, you lose. Otherwise, you win. Your program acts as a single player. Here are some sample runs. You rolled 5 + 6 = 11 You win You rolled 1 + 2 = 3 You lose You rolled 4 + 4 = 8 point is 8 You rolled 6 + 2 = 8 You win You rolled 3 + 2 = 5 point is 5 You rolled 2 + 5 = 7 You lose4. (Game: chance of winning at craps) Revise Exercise 6.30 to run it 10,000 times and display the number of Winning games

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

Step: 3

blur-text-image

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions