Write a Java method static String caps(String str) that returns a capitalized version of a given...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Java method static String caps(String str) that returns a capitalized version of a given string. For example: String s1 = "Hello world!"; s1 = caps(s1); System.out.println(s1); would cause "HELLO WORLD!" to be printed. Q2. Write a Java method static int[] randomArray(int N) that returns an array of N random numbers, with each number falling between 0 and 9, inclusive. Implement the method so that it is twice as likely that a number falls in the range [0,5) as in the range [5,9]. Q3. Write a recursive method (using no loops) in Java to compute the number of space characters in a given string. Q4. In question Q1 above, could we re-write the caps method in the form static void caps(String str)? That is, could such a method change the contents of string s1 by calling caps(s1)? Why/ why not? Write a Java method static String caps(String str) that returns a capitalized version of a given string. For example: String s1 = "Hello world!"; s1 = caps(s1); System.out.println(s1); would cause "HELLO WORLD!" to be printed. Q2. Write a Java method static int[] randomArray(int N) that returns an array of N random numbers, with each number falling between 0 and 9, inclusive. Implement the method so that it is twice as likely that a number falls in the range [0,5) as in the range [5,9]. Q3. Write a recursive method (using no loops) in Java to compute the number of space characters in a given string. Q4. In question Q1 above, could we re-write the caps method in the form static void caps(String str)? That is, could such a method change the contents of string s1 by calling caps(s1)? Why/ why not?
Expert Answer:
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
The new line character is utilized solely as the last person in each message. On association with the server, a client can possibly (I) question the situation with a client by sending the client's...
-
The following is a condensed income statement for Sweets & Treats, a confectionary. Required: Determine (a) The cost of purchases and (b) Costs associated with sales and administration. Sweets &...
-
Is Equal Employment Opportunity Sufficient? Why do we as a society still need Affirmative Action? Why isn't Equal Employment Opportunity sufficient to prevent workplace discrimination? Discuss.
-
What is meant by authentication of the user, and how may authentication be achieved?
-
\(P(A)=73 \%, P\left(A^{\prime} ight)=27 \%, P(B \mid A)=46 \%\), and \(P\left(B \mid A^{\prime} ight)=52 \%\) According to Bayes' Theorem, the probability of event A, given that event B has...
-
(a) From what sources might a corporation obtain funds through long-term debt? (b) What is a bond indenture? What does it contain? (c) What is a mortgage?
-
The annual return on the S&P 500 Index was 12.4 percent. The annual T-bill yield during the same period was 5.7 percent. What was the market risk premium during that year?
-
Your company is considering investing in its own transport fleet. The present position is that carriage is contracted to an outside organization. The life of the transport fleet would be five years,...
-
On December 1, Jasmin Ernst organized Ernst Consulting. On December 3, the owner contributed $83,540 in assets to launch the business. On December 31, the company's records show the following items...
-
When Deborah Karish wakes up in the morning, she does not have to worry about a long commute to work. Her office is in her home. As an Amgen ( www.amgen.com ) pharmaceutical sales representative,...
-
As noted in this chapter, demonstration software is becoming increasingly popular. Real estate salespeople are using this software to showcase homes to prospective buyers. Assume you are a...
-
Dave Levitt, featured at the beginning of this chapter, is a regional sales manager for Salesforce.com . The CRM solution provider is exclusively a cloud-computing vendor offering hosted...
-
For the Grunfeld data, replicate the Hausman test results given in example 1 of Sect.4.3.
-
Assume your college or university is considering buying 100 new PCs for student labs throughout the campus. Describe who you think will be involved in the buying centre (by role), and what you think...
-
To analyze a rod assembly in three-dimensional space and determine the support reactions by using the equations of equilibrium for a rigid body. The rod assembly shown has smooth journal bearings at...
-
Refer to the table to answer the following questions. Year Nominal GDP (in billions) Total Federal Spending (in billions) Real GDP (in billions) Real Federal Spending (in billions) 2000 9,817 578...
-
Write some code that asks the user to enter either of the words append or new. According to the user response, open either an existing text file to which data can be appended or a new, empty text...
-
Write a program that demonstrates type casting of double values by performing the following tasks: Use Scanner to read a floating-point value x. Type cast x to an int value and store the result in y....
-
Write a grading program for an instructor whose course has the following policies: Two quizzes, each graded on the basis of 10 points, are given. One midterm exam and one final exam, each graded on...
-
Suppose you increase the gauge pressure in the tires of your car by \(10 \%\). (a) How does the area of the tires in contact with a level road change? (b) If the gauge pressure in the tires is \(2.0...
-
In a service station's hydraulic lift, the diameter of the large piston is \(200 \mathrm{~mm}\) and the diameter of the small piston is \(30 \mathrm{~mm}\). Force is exerted on the small piston by an...
-
Initially, both legs of a mercury manometer are open to the atmosphere, and the mercury height in the left leg is \(40.0 \mathrm{~mm}\). You inflate a balloon until it has a surface area of \(0.300...
Study smarter with the SolutionInn App