java代写/game代写/算法代写:  phone’s keyboard Game

 phone’s keyboard Game

java代写/game代写/算法代写: 这是一个比较简单的通过java进行手机键盘操作的代写编写项目

Now that we all live in the 305 area code, we can use the letters on a phone’s keyboard to encode our phone numbers as strings, e.g., my office number 3052842158 can be encoded as the string “E0KAUHA1JV” (note the zero and one are left as 0 and 1). It could also be encoded as “F0LAVIC1KU”, or “D0JCUHB1LU”, or “E0LCUGB1JU”, or … there are lots of random options. You must write a program to make a random string code for a 305 phone number that is entered as the last seven digits of the number.

Your program must:

  1. Use a do-while loop to make sure the user enters a 7 digit number.
  2. Have a method that accepts an integer parameter (the number) and returns a String that is a random encoding of the number according to the normal phone keyboard.
    • The method must use have two arrays. The first array contains the first letters for encoding each digit, i.e., ‘0’, ‘1’, ‘A’, ‘D’, … ‘W’. The second array contains the number of letters for each digit, i.e., 1, 1, 3, 3, … 4.
    • The method must use a while loop to extract each digit of the number (hint, use the modulus operator), encode the digit randomly as one of those corresponding to the digit as specified by the arrays (hint, use Math.random and Math.floor), and build the encoded string (hint, use the concatenation operator).
  3. Call the encoding method twice, once to encode 305, and once to encode the seven digit number.
  4. Print out the encoded number.

Here what a sample run should look like (with the keyboard input shown in italics) …

Please enter your 305 phone number: 2842158
The phone number 3052842158 can be encoded as E0KAUHA1JV


电子邮件地址不会被公开。 必填项已用*标注