Write a program whose input is a character and a string, and whose output indicates the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. The output should include the input character and use the plural form, n's, if the number of times the characters appears is not exactly 1. Ex: If the input is: on Monday the output is: 1 n Ex: If the input is: z Today is Monday the output is: 0 z's Ex: If the input is: n It's a sunny day the output is: 2 n's Case matters. Ex: If the input is: n Nobody Ex: If the input is: n Nobody the output is: 0 n's n is different than N. 450974 1755466.qx3zqy7 LAB ACTIVITY 1 import java.util.Scanner; 2 3 public class LabProgram { 4 5 6 3.16.1: LAB: Count characters 7 } 8 public static void main(String[] args) { /* Type your code here. */ } Develop mode Submit mode LabProgram.java 0/10 Load default template... Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. The output should include the input character and use the plural form, n's, if the number of times the characters appears is not exactly 1. Ex: If the input is: on Monday the output is: 1 n Ex: If the input is: z Today is Monday the output is: 0 z's Ex: If the input is: n It's a sunny day the output is: 2 n's Case matters. Ex: If the input is: n Nobody Ex: If the input is: n Nobody the output is: 0 n's n is different than N. 450974 1755466.qx3zqy7 LAB ACTIVITY 1 import java.util.Scanner; 2 3 public class LabProgram { 4 5 6 3.16.1: LAB: Count characters 7 } 8 public static void main(String[] args) { /* Type your code here. */ } Develop mode Submit mode LabProgram.java 0/10 Load default template... Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box.
Expert Answer:
Answer rating: 100% (QA)
Java program that takes a character and a string as input and counts the number of times the charact... View the full answer
Related Book For
Computer Organization and Design The Hardware Software Interface
ISBN: 978-0124077263
5th edition
Authors: David A. Patterson, John L. Hennessy
Posted Date:
Students also viewed these programming questions
-
Northwestern Bank (NB) offers only checking accounts. Customers can write checks and use a network of automated teller machines. NB earns revenue by investing the money deposited; currently, it...
-
This week you will seek support from leadership as you implement the plan you crafted in Week 2. Draft a memo to leadership that begins with your organization's vision, mission, and goals. Then align...
-
Create an improved Marketing Strategy that innovates how Innisfree sells Korean skincare in the US. Revitalizing Innisfree's US Market Penetration and Competitive Edge in Korean Skincare. Industry...
-
Let Go n! + 1, where n is a positive integer. We will generate a sequence of primes by performing the following steps. Begin by finding P which is any prime divisor of G, then compute P2 by finding...
-
A sign is subjected to a wind loading that exerts horizontal forces of 300 lb on joints B and C of one of the side supporting trusses. Determine the force in each member of the truss and state if the...
-
Suppose Evan contributes $2000 to his RRSP at the end of every quarter for the next 15 years, and then contributes $1000 at each months end for the subsequent 10 years. How much will he have in his...
-
Let us consider the norm Loo
-
Harwood Company uses a job-order costing system. Overhead costs are applied to jobs on the basis of machine-hours. At the beginning of the year, management estimated that the company would incur...
-
Mary is a regional demand planner at The Home Depot. For the past 6 months she has been using three forecast methods to forecast sales for the hand tools product category. The table below shows...
-
Elizabeth Soltis owns and operates Aunt Ibby's Styling Salon. A year-end work sheet is provided on the next page. Using this information, prepare adjusting entries, financial statements, and closing...
-
A cylindrical timber pile of diameter 400 mm is driven to a depth of 10 m into a clay with cu= 40 kPa, and '= 28, OCR = 2, and Ysat = 18 kN/m. Groundwater level is at the surface. Estimate the...
-
1. What is gender pay gap? How has the gender pay gap been changing during the past 20 years? 2. According to the article, how did women's wage change during the pandemic comparing with men's wage in...
-
Article Research Summary Cameron, I. D., Dyer, S. M., Panagoda, C. E., Murray, G. R., Hill, K. D., Cumming, R. G., Why you chose this article and/or how it relates to the clinical issue of interest...
-
A survey is a method often chosen by companies that require primary data. Data obtained from surveys provides a company with information that is needed prior to introducing new products or making...
-
The Clements believe that they need six months of cash flow net of all taxes, savings, vacation, and net cash flow in an emergency fund. They are willing to include the savings account and Nicholas's...
-
Given the following is a recursive definition for myFunct (num) where num is an integer. if num < 0 myFunct (num) = myFunct (num 1) + num otherwise 1. Write the definition of the recursive...
-
Daffy Duck Enterprise produces prenatal vitamins at its factory. The following information relates to the production of the vitamins for the period ending 31 December 2020. Production Sales (Units)...
-
Evenflow Power Co. is considering a new project that is a little riskier than the current operations of the company. Thus, management has decided to add an additional 1.5% to the company's overall...
-
Assume the following register contents: $t0 = 0xAAAAAAAA, $t1 = 0x12345678 1. [5] For the register values shown above, what is the value of $t2 for the following sequence of instructions? 2. For the...
-
Using your code from Exercise 2.43 as an example, explain what happens when two processors begin to execute this critical section at the same time, assuming that each processor executes exactly one...
-
AMD has recently announced that they will be integrating a graphics processing unit with their x86 cores in a single package, though with different clocks for each of the cores. This is an example of...
-
Let us consider the scenario tree of Fig. 11.10 and define consider decision Data From Fig. 11.10 Data From Example 11.17 cision variables Z and Z, representing the number of stock shares that we buy...
-
You are considering purchasing a defunct mine in Africa. Your firm has developed a method to extract valuable rare earth minerals from the mining entrails. The cost of the mine together with the...
-
Consider the following bonds: a. What is the percentage change in the price of each bond if its yield to maturity falls from 6% to 5%? b. Which of the bonds AD is most sensitive to a 1% drop in the...
Study smarter with the SolutionInn App