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
o-na [289]
4 years ago
5

(2) Complete the get_num_of_characters() function, which returns the number of characters in the user's string. We encourage you

to use a for loop in this function. (2 pts) Extend the program by calling the get_num_of_characters() function and then output the returned result. (3) Extend the program further by implementing the string_without_whitespace() function. string_without_whitespace() returns the string's characters except for whitespace (spaces, tabs). Note: A tab is '\t'. (2 pt) Ex: Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself. Number of characters: 46 String with no whitespace: Theonlythingwehavetofearisfearitself. After you have completed and tested your lab, submit the code of the functions only to Zybook for autograding.
Computers and Technology
1 answer:
dybincka [34]4 years ago
8 0

Answer:

Code details below

Explanation:

// Scanner is a class in the java.util package used to get the entry of primitive types like int, double etc. and also String.

import java.util.Scanner;

// The program must be able to open any text file specified by the user, and analyze the frequency of verbal ticks in the text.  

public class TextAnalyzer {

// public : it is a access specifier that means it will be accessed by publically. static : it is access modifier that means when the java program is load then it will create the space in memory automatically. void : it is a return type i.e it does not return any value. main() : it is a method or a function name.  

 

public static void main(String[] args) {

// the program will find the length of a string without using any loops and you may assume that the length of entered string is always less than any given number

      Scanner scan = new Scanner(System.in);

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

      String s = scan.nextLine();

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

      int numOfCharacters = getNumOfCharacters(s);

      System.out.println("");

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

      outputWithoutWhitespace(s);

  }

  public static int getNumOfCharacters(final String s){

      int numOfCharCount = 0;

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

              numOfCharCount++;

      }

      return numOfCharCount;

  }

   

// Using this function, we replace all whitespace with no space(“”)

  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
Released in 1976, the Apple I was Apple Computer's first product.<br><br> O True<br> O False
Anna35 [415]
False,
The apple was not a computer
6 0
3 years ago
What does it mean? It teaches kids to play instruments.
Nady [450]
Something that teaches children to play instruments so like 'it' could be a teacher that teaches kids instruments?
8 0
3 years ago
Read 2 more answers
Computer program allowing the computer to communicate<br> with a hardware device
Airida [17]

Answer:The software that allows a computer to communicate with hardware devices is referred to by the general term known as 'Drivers.

Explanation:Transmission Control Protocol/Internet Protocol (TCP/IP) is the backbone of the Internet and the true language computers use to talk to each other. Essentially it's a set of standards for sending information from a computer's network card, through transmission lines to another network card.

8 0
4 years ago
What is the difference between software hardware ???
defon
Software are parts of a computer system that can be seen but not touched.

Hardware are parts of a computer system that can be seen and touched
3 0
3 years ago
Read 2 more answers
A data in database can be presented in _____ format​
Serggg [28]

Answer:

Data is stored in tables, where each row is an item in a collection, and each column represents a particular attribute of the items. Well-designed relational databases conventionally follow third normal form (3NF), in which no data is duplicated in the system. ... With a homogenous data set, it is highly space efficient

6 0
3 years ago
Other questions:
  • Which statement about word processing software is true? A)You can use it to perform mathematical calculations.B) You can use it
    6·2 answers
  • Jessica wants to purchase a new hard drive. She wants a drive that has fast access because she will use it to edit videos on her
    12·1 answer
  • A network is a group of two or more computers that are connected to share resources and information. T or f
    11·2 answers
  • How do particles move at higher temperatures compared to how they move at lower temperatures?
    10·1 answer
  • Malcolm is part of a team developing a new smartphone app to track traffic patterns. Because team members are located throughout
    12·1 answer
  • Which of the following statements about the break statement is false? Group of answer choices Common uses of the break statement
    12·1 answer
  • Which of the following is a strategy used to enhance communication in a presentation?
    14·1 answer
  • How do operating system work?
    5·1 answer
  • Is this a desktop or a computer, or are they the same thing
    12·1 answer
  • Which of these purchases is most likely to be paid for with a credit card
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!