A. Write a method named mysteryWord that accepts a single integer parameter and returns a String...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A. Write a method named mysteryWord that accepts a single integer parameter and returns a String of that length with random (upper case) characters. (Hint: (char)65 is 'A' and (char)90 is 'Z'). Example use shown below. B. Write a method named countOf9 that accepts a single integer parameter and returns the count of number of times digit 9 appears in that integer. For example, countOf9(23969) will return 9 whereas countOf9(8757) will return 0. Make sure your code works for single digit as well as negative numbers correctly. You are not allowed to convert the number to a string and use any string methods. Reminder: Class name, and correct 1,2,3 (return, name, parameters) for each method is the best place to start!!! Here's a main() method for Quiz5.java that will work if you do this correctly: public static void main(String[] args) { } String thing mysteryWord(4); System.out.println(thing); // "SDTL" on my first test do { thing mysteryWord (4); } while (!thing.equals("SURE")); System.out.println(thing); // ultimately I get "SURE" System.out.println("countOf9 in 45894399 is " + count0f9 (45894399)); //Should be 3 System.out.println("countOf9 in 424 is " + count0f9 (424)); //Should be System.out.println("countOf9 in -919199 is " + countOf9(-919199)); //Should be 4 A. Write a method named mysteryWord that accepts a single integer parameter and returns a String of that length with random (upper case) characters. (Hint: (char)65 is 'A' and (char)90 is 'Z'). Example use shown below. B. Write a method named countOf9 that accepts a single integer parameter and returns the count of number of times digit 9 appears in that integer. For example, countOf9(23969) will return 9 whereas countOf9(8757) will return 0. Make sure your code works for single digit as well as negative numbers correctly. You are not allowed to convert the number to a string and use any string methods. Reminder: Class name, and correct 1,2,3 (return, name, parameters) for each method is the best place to start!!! Here's a main() method for Quiz5.java that will work if you do this correctly: public static void main(String[] args) { } String thing mysteryWord(4); System.out.println(thing); // "SDTL" on my first test do { thing mysteryWord (4); } while (!thing.equals("SURE")); System.out.println(thing); // ultimately I get "SURE" System.out.println("countOf9 in 45894399 is " + count0f9 (45894399)); //Should be 3 System.out.println("countOf9 in 424 is " + count0f9 (424)); //Should be System.out.println("countOf9 in -919199 is " + countOf9(-919199)); //Should be 4
Expert Answer:
Answer rating: 100% (QA)
Here are the methods mysteryWord and countOf9 java import javautilRandom public class Quiz5 Method t... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
Concrete Solutions manufactures concrete paving bricks. The processing takes place in two sequential departments. The following cost data relate to the month of January: Required: Prepare journal...
-
(a) Use the following text to derive distributions for rat and chased. Use a five-word window, including open- and closed- class words, ignore case, punctuation and sentence boundaries and weight...
-
Use the data in Exercise 13.28.To familiarize yourself with recursive least squares, estimate the savings functions for 19701981, 19701985, 19701990, and 19701995. Comment on the stability of...
-
Refer to Exercise 13.10. a. Use the values of SSR and Total SS to calculate R2. Compare this value with the value given in the printout. b. Calculate R2(adj). When would it be appropriate to use this...
-
Good Slings Inc. manufactures several wood and string instruments. In particular, it is well-known for its production of classic violins. Assume that Good Slings uses a periodic inventory system and...
-
What is the difference between real objects and virtual objects? Give an example for each.
-
For the extraction of Cu 2+ by dithizone in CCl 4 , KL= 1.1 10 4 , K M = 7 10 4 , K a = 3 10 - 5 , = 5 10 22 , and n = 2. (a) Calculate the distribution coefficient for extraction of 0.1 M Cu 2+...
-
How many times will each account on the trial balance be used within the financial statements?
-
1. Consider the below search graph (Figure 1). S is the start state and G is the goal state. Find the optimal path using the Algorithms given below. a) A graph search [10] S 1 B 3 A me C 12 3 2 D G...
-
Hannah Toberman had enjoyed her engineering job at Allstar Electronics, but she was beginning to grow restless. Most of her work for the past 5 years had involved designing minor adjustments to...
-
Diane and Rudy Conrad own a small lodge outside Yellowstone National Park. Their lodge has 15 rooms and can accommodate up to 50 guests. Their busy season runs from May through September, but they...
-
More and more consumers determined to save money are winding up at deep-discount retailers popularly known as dollar stores. These relatively small storesincluding Dollar General, Family Dollar, and...
-
a. Download the series EXCHUS from the FRED database. This expresses the exchange rate between the yuan (one of the names for the Chinese currency) as the number of yuan per US dollar. Convert that...
-
The Baseball data set (in Appendix A and Connect) reports information on the 30 Major League Baseball (MLB) teams for the 2021 season. 1. In the MLB, each team plays 162 games in a season. A...
-
The net income of Edwards Corporation amounted to $75,000 for this year. The beginning balance of owner's equity was $30,000 and the ending balance was $72,000. The company received no new...
-
Why did management adopt the new plan even though it provides a smaller expected number of exposures than the original plan recommended by the original linear programming model?
-
Under IAS 36, any necessary impairment charge will be equal to: A. Carrying value after depreciation at the current balance sheet date less the lower of net selling price and value in use. B....
-
Depreciation of a non-current asset is an estimate of the loss in value of the asset over the accounting period. A. True. B. False.
-
A firm buys a delivery van on 1 January 20X1 for 60,000. The estimated physical life is 10 years, but the firm has a policy of trading in all vans after 5 years, when the trade-in price is usually...
Study smarter with the SolutionInn App