JAVA PPROGRAM ASAP   Please Modify this program ASAP BECAUSE IT IS MY LAB ASSIGNMENT so it passes all the test cases. It does not pass the test cases when I upload it to Hypergrade. Because RIGHT NOW IT PASSES 0 OUT OF 1 TEST CASES. I have provided the failed the test cases and the inputs as a screenshot. The program must pass the test case when uploaded to Hypergrade.   import java.util.Scanner; // creating class WordCounter public class WordCounter {     public static void main(String[] args)     {         // creating a scanner object         Scanner sc = new Scanner(System.in);         // if while loop is true         while (true)         {             // then enter a string             System.out.print("Please enter a string or type QUIT to exit:\n");             // Taking string as user input             String str = sc.nextLine();             // if user enters quit then ignore the case             if (str.equalsIgnoreCase("QUIT")) {                 break;             }             // Counting the words present in inputted string and store it in count variable             int count = countWords(str);             // print rhe number of words in the given string             System.out.println("There are " + count + " words in that string.\n");         }         sc.close();     }     // creating a method countWords for counting the words     public static int countWords(String input)     {         // counting the words which are splitted with space         String[] words = input.split(" ");         // Return the length of the words         return words.length;     } } Test Case 1 Please enter a string or type QUIT to exit:\n Hello World!ENTER There are 2 words in that string.\n Please enter a string or type QUIT to exit:\n I have a dream.ENTER There are 4 words in that string.\n Please enter a string or type QUIT to exit:\n Java is great.ENTER There are 3 words in that string.\n Please enter a string or type QUIT to exit:\n quitENTER

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
icon
Related questions
Question
JAVA PPROGRAM ASAP
 
Please Modify this program ASAP BECAUSE IT IS MY LAB ASSIGNMENT so it passes all the test cases. It does not pass the test cases when I upload it to Hypergrade. Because RIGHT NOW IT PASSES 0 OUT OF 1 TEST CASES. I have provided the failed the test cases and the inputs as a screenshot. The program must pass the test case when uploaded to Hypergrade.
 

import java.util.Scanner;
// creating class WordCounter
public class WordCounter
{
    public static void main(String[] args)
    {
        // creating a scanner object
        Scanner sc = new Scanner(System.in);
        // if while loop is true
        while (true)
        {
            // then enter a string
            System.out.print("Please enter a string or type QUIT to exit:\n");
            // Taking string as user input
            String str = sc.nextLine();
            // if user enters quit then ignore the case
            if (str.equalsIgnoreCase("QUIT")) {
                break;
            }
            // Counting the words present in inputted string and store it in count variable
            int count = countWords(str);
            // print rhe number of words in the given string
            System.out.println("There are " + count + " words in that string.\n");
        }
        sc.close();
    }
    // creating a method countWords for counting the words
    public static int countWords(String input)
    {
        // counting the words which are splitted with space
        String[] words = input.split(" ");
        // Return the length of the words
        return words.length;
    }
}

Test Case 1

Please enter a string or type QUIT to exit:\n
Hello World!ENTER
There are 2 words in that string.\n
Please enter a string or type QUIT to exit:\n
I have a dream.ENTER
There are 4 words in that string.\n
Please enter a string or type QUIT to exit:\n
Java is great.ENTER
There are 3 words in that string.\n
Please enter a string or type QUIT to exit:\n
quitENTER
 
 
 
Test Case 1 Failed Show what's missing
Please enter a string or type QUIT to exit: \n
Hello World! ENTER
There are 2 words in that string.\n
Please enter a string or type QUIT to exit: \n
I have a dream. ENTER
There are 4 words in that string.\n
Please enter a string or type QUIT to exit: \n
Java is great. ENTER
There are 3 words in that string.\n
Please enter a string or type QUIT to exit: \n
quit ENTER
Transcribed Image Text:Test Case 1 Failed Show what's missing Please enter a string or type QUIT to exit: \n Hello World! ENTER There are 2 words in that string.\n Please enter a string or type QUIT to exit: \n I have a dream. ENTER There are 4 words in that string.\n Please enter a string or type QUIT to exit: \n Java is great. ENTER There are 3 words in that string.\n Please enter a string or type QUIT to exit: \n quit ENTER
Test Case 1 Failed Show what's missing
Please enter a string or type QUIT to exit: \n
Hello World! ENTER
There are 2 words in that string. \n
|\n
Please enter a string or type QUIT to exit: \n
I have a dream. ENTER
There are 4 words in that string. \n
|\n
Please enter a string or type QUIT to exit: \n
Java is great. ENTER
There are 3 words in that string.\n
|\n
Please enter a string or type QUIT to exit: \n
quit ENTER
Transcribed Image Text:Test Case 1 Failed Show what's missing Please enter a string or type QUIT to exit: \n Hello World! ENTER There are 2 words in that string. \n |\n Please enter a string or type QUIT to exit: \n I have a dream. ENTER There are 4 words in that string. \n |\n Please enter a string or type QUIT to exit: \n Java is great. ENTER There are 3 words in that string.\n |\n Please enter a string or type QUIT to exit: \n quit ENTER
Expert Solution
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
Unreferenced Objects
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education