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
How can you tell if a website is biased?
Leona [35]

Answer:

the author has not considered other points of view.

7 0
1 year ago
If you have long column labels with columns so wide that they affect the readability of a worksheet, you should first
Alla [95]
The answer is (C) consider how you could shorten the column labels.

The label at the top of a column is sometimes wider than the data stored in the column. Expanding a column is an option but this may mean that you will not see as many columns on a page as possible. Wrapping text is also an option but has a downside to it as well since it will make the row with great height. 

Rotating the labels is also a possibility but is also not recommended. This leaves us with shortening the column labels and keep dictionary worksheet for users. As much as you can, consider using acronyms and abbreviations.






6 0
3 years ago
Read 2 more answers
Kali, a Python programmer, is using the turtle module to write the word "hello." Which code should she use to indicate the locat
Sever21 [200]

Answer:

a) penup()

goto(-100, 200)

pendown()

Explanation:

The python program to indicate the location to begin writing the word can be

penup()

goto(-100, 200)

pendown()

# in python is use to add comment so it is incorrect.

all other option does not have correct syntex.

4 0
3 years ago
Read 2 more answers
Which menu selection under Accessories will open a DOS-like window? A. Hyperterminal B. Command Prompt C. Remote Desktop Connect
Bezzdna [24]
B. Command Prompt, as if you were to open command prompt it is 1. Under Accessories and 2. DOS-Like
7 0
3 years ago
Select the correct answer.
Romashka [77]

Answer:

B.

Explanation:

Because

6 0
2 years ago
Other questions:
  • _____ is a valuable tool that enables you to find information on the web by specifying words or phrases know as keywords- which
    14·1 answer
  • In what ways us cyberspace is real? list at least 3 examples to support your response .
    9·1 answer
  • Write a program that lets the user enter the name of a team and then displays the number of times that team has won the World Se
    9·1 answer
  • True or False: Unity can apply multiple textures to a single object or terrain
    9·1 answer
  • From the standpoint of the governing bodies of .com, why is it important that owners of individual domains maintain authoritativ
    5·1 answer
  • Which transmission media is faster? Fibre Optic or Radio-waves? I want full explanation!
    10·1 answer
  • In creating a professional action plan it's important to
    12·1 answer
  • A _____ are devices that permit a user to connect to a digital t-carrier service.
    6·1 answer
  • What is the missing line of code?
    7·2 answers
  • Write bubblesort algorithm using random programming language
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!