Skip to content

No "Invalid Input" after input "Alas! it failed#' In Pangram Word #12

Discussion options

You must be logged in to vote

package ISC_XII_Computer_Science;

import java.util.Scanner;

public class PangramWord {
String sentence = "";

public void accept() {
    Scanner scanner = new Scanner(System.in);
    System.out.println("Enter a sentence (end with '.', '!', or '?'):");

    while (true) {
        String input = scanner.nextLine();
        for (int i = 0; i < input.length(); i++) {
            if (input.charAt(i) == '.' || input.charAt(i) == '!' || input.charAt(i) == '?') {
                sentence += input;
                if (input.charAt(input.length() - 1) == '.' || input.charAt(input.length() - 1) == '!' || input.charAt(input.length() - 1) == '?') {
                    System.out.println("Sentence: " + …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@YashDoesCode
Comment options

YashDoesCode Oct 29, 2024
Maintainer Author

Answer selected by YashDoesCode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants