1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Zarrin [17]
3 years ago
15

Complete the getNumOfCharacters() method, which returns the number of characters in the user's string. We encourage you to use a

for loop in this function. (3) In main(), call the getNumOfCharacters() method and then output the returned result. (1 pt) (4) Implement the outputWithoutWhitespace() method, which outputs the string's characters except for whitespace (spaces, tabs). Note: A tab is '\t'. Call the outputWithoutWhitespace() method in main().
Computers and Technology
1 answer:
photoshop1234 [79]3 years ago
5 0

Answer:

The Java code is given below with appropriate comments

Explanation:

//Program

//Import the necessary libraries

import java.util.Scanner;

//Define the class

public class CountStringCharacters

{

//Start the main method

public static void main(String[] args)

{

//Prompt the user to enter the input line

Scanner scan = new Scanner(System.in);

System.out.println("Enter a sentence or phrase: ");

String s = scan.nextLine();

 

//Take the number of characters and keep the count

int numOfCharacters = getNumOfCharacters(s);

System.out.println("You entered: "+s);

System.out.println("Number of characters: "+numOfCharacters);

 

//Call the method outputWithoutWhitespace

outputWithoutWhitespace(s);

}

//The method getNumOfCharacters

public static int getNumOfCharacters(String s)

{

int numOfCharCount = 0;

for(int i=0; i<s.length();i++)

{

numOfCharCount++;

}

return numOfCharCount;

}

//Definition of the method outputWithoutspace

public static void outputWithoutWhitespace(String s)

{

String str = "";

for(int i=0; i<s.length();i++)

{

char ch = s.charAt(i);

if(ch != ' ' && ch != '\t')

str = str + ch;

}

System.out.println("String with no whitespace: "+str);

}

}

You might be interested in
Ill give alot of points if you answer: How do I get a 100 dollar ps4
stepladder [879]
Uh how do you get a little blue box in a sandwich
8 0
3 years ago
Read 2 more answers
Imagine that you work for an organization that has no Internet use policy. Employees use the Internet in whatever way they want
Strike441 [17]

Answer: Yes

Explanation:

It would force the company to either enforce the policy and fire all of its employees.

8 0
1 year ago
The following are reasons why many organizations are trying to reduce and right-size their information foot-print by using data
blagie [28]

Answer:

C.<em> improve data quality and reduce redundancies, reduce increased and staggering storage management costs</em>

<em></em>

Explanation:

Excess data retention can lead to retention of redundant and irrelevant data, which can reduce data handling and processing efficiency, while at the same time increasing the cost of data storage and management. This can be curbed be reducing data to the right size by using data governance techniques like data cleansing and de-duplication

6 0
3 years ago
A program is required to three (3) numbers. calculate and print their total
podryga [215]

A program that is required to three (3) numbers. calculate and print their total is given below:

<h3>The Program</h3>

import java.util.Scanner;

public class SumAndAverage {

public static void main(String[ ] args) {

System.out.println("Enter three numbers - ");

// Accepting and finding sum of numbers.

int sum = 0;

Scanner sc = new Scanner(System.in);

for (int i = 0; i < 3; i++)

sum += sc.nextInt( );

// Printing sum and average.

System.out.println("Sum - " + sum);

System.out.println("Average - " + (sum / 3f));

}

}

The output would request three different numbers, then add them up, and display the output of the sum and then display or print their total


Read more about programming here:

brainly.com/question/23275071

#SPJ1

5 0
1 year ago
LIST THE 7 BEST COMPUTER SCIENCE MOVIES.
Serggg [28]

The Pirates of Silicon Valley.

Tron

Hackers

Antitrust

The Social Network

The Internship

The Imitation Game

5 0
2 years ago
Other questions:
  • Why has unicode become the standard way of converting binary to text
    7·1 answer
  • What does utp stand for?
    11·2 answers
  • Name one app that currently has a positive impact on society and explain why you think it has had a positive effect.
    10·1 answer
  • A newly opened law firm in Kirkland decides to create a small website that provides a brief introduction of the firm, its missio
    8·1 answer
  • A 1000 elements array is used to store integers ascending order . The array is used to search binary search algorithm for the in
    14·1 answer
  • Wired network are the most reliable and provide the highest speed?
    7·1 answer
  • Convert each of the following base 10 &amp; base 2 numbers in signed magnitude, one’s complement and two’s complement. Each of t
    8·1 answer
  • The ______________ shows that you have fully researched the topic and gives you a chance to prove your claim.
    8·1 answer
  • What is phishing?
    14·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!