Answer to Question #298910 in Java | JSP | JSF for Mesew

Question #298910

import java.util.*;



class App {


public static void main(String[] args) {

Scanner in = new Scanner(System.in);

System.out.println("Enter a String: ");

String line = in.nextLine();

boolean space = true;

boolean first = false;

for (Character letter : line.toCharArray()) {

if (letter == ' ') {

System.out.print(letter);

space = !space;

first = false;

} else if (space) {

if (!first) {

System.out.print(letter + ".");

first = true;

}

} else {

System.out.print(letter);

}

}

System.out.println();

in.close();

}

}

Do this coding without using array, split, Character letter, line.toCharArray, boolean


1
Expert's answer
2022-02-21T01:27:32-0500
import java.util.*;
public class App{
public static void main(String []args){
Scanner in = new Scanner(System.in);

System.out.println("Enter a String: ");

String line = in.nextLine();
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS