Write a program that removes all non alpha characters from the given input. Ex: If the innut is:
Write a program that removes all non alpha characters from the given input. Ex: If the innut is:
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%
There is something wrong with my code
It prints more than one line of code help me get my expected output please
I’m using Java for this one
![LabProgram.java
1 import java.util.Scanner;
e output a
3 public class LabProgram {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
5
differs. See highlights below.
Special character legen
7.
String sentence= sc.nextLine();
String newSentence="";
int character = sentence.length();
9.
Input
-Hello, 1 world$!
10
11
12
for (int i = 0; i < character; i++) {
13
He
14
if (sentence.charAt(i)
'1') {
15
newSentence += "";
16
Hee
17
Hele
18
else if (sentence.charAt(i) ==
19
newSentence += "":
}
} (,$.
Helle
20
21
Helloe
Hello, e
22
else if (sentence.charAt(i) == ' ') {
newSentence += "";
23
24
Hello, e
25
26
Your output
Hello, e
else if (sentence.charAt(i) == '.') {
newSentence += "";
27
28
Hello, e
Hello,we
29
30
else if (sentence.charAt(i) == '@') {
newSentence += "";
31
Hello,wod
32
33
Hello,word
Hello,world
34
else if (sentence.charAt(i) == '-') {
newSentence += "";
35
36
37
Hello,world
38
else if (sentence.charAt(i) == '!') {
39
Hello,worlde
newSentence += "";
}
40
Hello,worlde
41
42
else {
newSentence += sentence.charAt(i);
43
44
pected output
Helloworld
45
46
System.out.println(newSentence);
47
48
49
50
re output a
I](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6961aa18-8474-4466-bd14-b02bea60c27d%2F6490658c-500f-4ff3-adc2-aa42b7e49e40%2Fypdo85_processed.jpeg&w=3840&q=75)
Transcribed Image Text:LabProgram.java
1 import java.util.Scanner;
e output a
3 public class LabProgram {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
5
differs. See highlights below.
Special character legen
7.
String sentence= sc.nextLine();
String newSentence="";
int character = sentence.length();
9.
Input
-Hello, 1 world$!
10
11
12
for (int i = 0; i < character; i++) {
13
He
14
if (sentence.charAt(i)
'1') {
15
newSentence += "";
16
Hee
17
Hele
18
else if (sentence.charAt(i) ==
19
newSentence += "":
}
} (,$.
Helle
20
21
Helloe
Hello, e
22
else if (sentence.charAt(i) == ' ') {
newSentence += "";
23
24
Hello, e
25
26
Your output
Hello, e
else if (sentence.charAt(i) == '.') {
newSentence += "";
27
28
Hello, e
Hello,we
29
30
else if (sentence.charAt(i) == '@') {
newSentence += "";
31
Hello,wod
32
33
Hello,word
Hello,world
34
else if (sentence.charAt(i) == '-') {
newSentence += "";
35
36
37
Hello,world
38
else if (sentence.charAt(i) == '!') {
39
Hello,worlde
newSentence += "";
}
40
Hello,worlde
41
42
else {
newSentence += sentence.charAt(i);
43
44
pected output
Helloworld
45
46
System.out.println(newSentence);
47
48
49
50
re output a
I

Transcribed Image Text:4.20 LAB: Remove all non alpha characters
Write a program that removes all non alpha characters from the given input.
Ex: If the input is:
-Hello, 1 world$!
the output is:
Helloworld
354532.2042412.qx3zgy7
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education