Consider the following JAVA code snippet: String greeting int count = 0; Hello!; for (int k...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following JAVA code snippet: String greeting int count = 0; "Hello!"; for (int k = 0; k< greeting.length(); k++) { count += 1; letter = greeting.charAt (k) if (count & 2 == 0) System.out.println (greeting.charAt (k)); (letter); System.out.println System.out.println ("done"); Answer the following questions: 1) How many times does each of the characters H, e, 1, o and ! print out? 2) How many times does the string done print out? Consider the following JAVA code snippet: String greeting int count = 0; "Hello!"; for (int k = 0; k< greeting.length(); k++) { count += 1; letter = greeting.charAt (k) if (count & 2 == 0) System.out.println (greeting.charAt (k)); (letter); System.out.println System.out.println ("done"); Answer the following questions: 1) How many times does each of the characters H, e, 1, o and ! print out? 2) How many times does the string done print out?
Expert Answer:
Answer rating: 100% (QA)
H Printed once because its at index 0 Printed again because its at index 0 and the coun... 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
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
What is the difference between MouseListener and MouseAdapter? [3 marks] (b) Via suitable HTML, the compiled version of the following Java code is presented to the appletviewer application: import...
-
Given the following marginal utility schedule for good X and good Y for an individual A, given that the price of X and the price of Y are both $10, and that the individual spends all his income of...
-
An article in the New York Times has the headline "U.S. Trade Deficit Widened Over Summer." The first sentence in the article is, "The current-account trade deficit widened slightly in the...
-
Refer to the Practice Set data provided in Chapters 2 and 3. Consider the following adjustment data: a. Cleaning supplies on hand at the end of November were $ 50. b. One months combined depreciation...
-
Consider the Latin Square design and data from Bliss and Rose [1940] shown in Table 5.9. a. Use R to compute the ANOVA table. Interpret the results. b. Estimate the treatment effects. Interpret the...
-
Tanaka Manufacturing Company is considering three new projects, each requiring an equipment investment of $22,000. Each project will last for 3 years and produce the following cash inflows. The...
-
A company borrows $80,000 at a simple interest rate of 6.7% per annum for 90 days. What is the total amount they will need to repay after 90 days (rounded to the nearest dollar)?
-
6.2. Data has been collected from a chemical reactor. The inlet concentration was the only input variable that changed when the data was collected. The input and output data is given in Table Q6.2....
-
Phillips Co. acquired all of the common stock of Sanchez Co. on January 1, 2020. As of that date, Sanchez had the following trial balance: Debit Credit Accounts payable $ 40,000 Accounts receivable $...
-
a. Think about your past and present contacts with people who have irritated you the most. Make a specific list of what bothered you about these people. Suppose that you are working in a law office...
-
Which of the following disposals might give rise to a CGT liability? (a) The sale of antique furniture by a UK company, (b) The gift of shares from husband to wife (assuming that the couple live...
-
In the following cases, to what extent might an individual be hampered in delivering legal services because of personal reactions toward the client? Identify potential bias. a. Mr. Smith, the client...
-
Jane is self-employed. Her recent adjusted trading profits/(losses) are: Jane has other income of 10,000 per annum. Assuming that the trading loss is carried forward and set against future trading...
-
On 1 June 2021, Stephen was provided by his employer with an interest-free loan of 20,000. He repays 5,000 of this loan on 1 January 2022 and repays another 3,000 on 1 March 2022. Compute the taxable...
-
Suppose the government in each province of country X sets the price of health care. a. Using the data in table 3.1 for Year 1 only, calculate the arc price elasticity of demand for visits to the...
-
The Ferris wheel in the figure has a radius of 68 feet. The clearance between the wheel and the ground is 14 feet. The rectangular coordinate system shown has its origin on the ground directly below...
-
Write a piece of code that inserts a String into an ordered linked list of Strings, maintaining sorted order. For example, for the list ["Alpha", "Baker", "Foxtrot", "Tango", "Whiskey"], inserting...
-
Write a method called symmetricSetDifference that accepts two Sets as parameters and returns a new Set containing their symmetric set difference (that is, the set of elements contained in either of...
-
Add the following mutator method to the TimeSpan class: public void add(TimeSpan span) Adds the given amount of time to this time span.
-
If investors are holding optimal portfolios, how will the portfolios of a more risk averse and a more risk-tolerant investor differ?
-
Using the data from Table 11.3, what is the covariance between the stocks of Alaska Air and Southwest Airlines? Alaska Southwest Ford General Microsoft HP Air Airlines Motor Kellogg Mills Volatility...
-
According to the managerial entrenchment theory, managers choose capital structures so as to preserve their control of the firm. On the one hand, debt is costly for managers because they risk losing...
Study smarter with the SolutionInn App