Question
Write a program in java and draw a flowchart that keeps prompting ( a loop is needed) for the user to enter a string of
Write a program in java and draw a flowchart that keeps prompting ( a loop is needed) for the user to enter a string of their choosing as long as the string is not "quit". After each string entered, the program outputs the string, counts number of characters except for white space (spaces, tabs) in the user's string, also outputs the string's characters except for white space (spaces, tabs). Notes: the tab character is '\t'.
The program MUST have the following two methods, in additional to the main method (4 points):
(1) A method named getNumOfCharacters that returns the number of characters except for white space (spaces, tabs) in the user's string, the header of the method should be public static int getNumOfCharacters(String )
(2) )A method named outputWithoutWhitespace() that outputs the string's characters except for white space (spaces, tabs), the header of the method should be public static void output Without White space(String )
Here is an example of output
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: 37 String with no white space: Theonlythingwehavetofearisfearitself. Enter a sentence or phrase: How are you doing? You entered: How are you doing? Number of characters: 15 String with no white space: Howareyoudoing? Enter a sentence or phrase: quit You entered: quit The Program Ends
/the program counts char in a string without whitespace and outputs the string without whitespace
import java.util.Scanner;
public class pro6_TextAnalyzer_method {
public static void main(String[] args) {
//type your code here
}
// Method counts the number of characters
public static int getNumOfCharacters(String ) { //a variable is needed after String
//type your code here
}
// Method outputs string without whitespace
public static void outputWithoutWhitespace(String ) { //a variable is needed after String
//type your code here
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started