Write a program that allows a user to enter a line of text

Assignment Help JAVA Programming
Reference no: EM13376228

Write a program that allows a user to enter a line of text, counts number of words and number of vowels in the sentence, and gives the average number of vowels per word in the message (vowels are letters a, e, i, o, u or A, E, I, O , U). Your program should contain a class SentenceCounter and a graphical user interface called SentenceCounterGUI.

1. The class SentenceCounter can be used to count words, vowels and the average number of vowels per word in the sentence. It has the following methods:

  • a constructor accepts a sentence as a parameter, and calls relevant methods to evaluate instance variables;
  • a method countWords counts number of words in the sentence;
  • a method countVowels  calculates a number of vowels in the sentence;
  • a method averageVowels calculates the average number of vowels per word in the sentence;
  • accessor (get) methods return a number of words, vowels and average number of vowels;
  • the method toString returns a full information about an object of the SentenceCounter class.

The following UML diagram might be of assistance:

     SentenceCounter

- sentence: String

- numberOfWords: int

- numberOfVowels: int

- average: double

      +   SentenceCounter(sentence : String)

      +   countWords ( ) : void

      +   countVowels ( ) :  void

      +   averageVowels ( ) : void

      +   getNumberOfWords( ) : int

      +   getNumberOfVowels( ) : int

      +   getAverage( ) : double

      +   toString( ) : String

2. Write a graphical user interface class called SentenceCounterGUI. It should be able to manipulate the sentence of words and have the following behaviour: 

  • label "Enter a sentence";
  • text field to enter a sentence and create a SentenceCounter object;
  • button "Count words" and the label to display it;
  • button "Count vowels" and the label to display it;
  • button "Average vowels" and the label to display it;

The class should include a main method that prepares a frame in which the panel is displayed.

Reference no: EM13376228

Questions Cloud

Overview1 created a document describing the business and : overview1. created a document describing the business and identifying the problems being experienced by the assignment
Part-1for task 1 list the things you changed and the : part-1for task 1 list the things you changed and the purpose of changing it. good reasons include making code easier
Hyundai case studycommon case focuses on the operations of : hyundai case studycommon case focuses on the operations of hyundai the korean automobile manufacturer in china. the
Question 1 entity-relationship er model create an er : question 1 entity-relationship er model create an er diagram using the set of requirements provided for oxford city
Write a program that allows a user to enter a line of text : write a program that allows a user to enter a line of text counts number of words and number of vowels in the sentence
What do prion and virus have in common what do capsid and : what do prion and virus have in common? what do capsid and prion have in common? what do virus and retrovirus have in
Problem 1 pre-contribution balance sheets and fair : problem 1 pre-contribution balance sheets and fair valuesjune 30 20x9in thousands of
1 list four methods used for the distribution of : 1. list four methods used for the distribution of end-of-meeting reports to senior management or ceo.2. list four
Backgroundsylvesters bike shop has stored its data in excel : backgroundsylvesters bike shop has stored its data in excel for many years but has experienced some data quality

Reviews

Write a Review

JAVA Programming Questions & Answers

  Method summarizesequences that takes a string as a parameter

Now implement the method summarizeSequences that takes a String as a parameter. This method should open the file named by this String, and read a sequence from that file into an array list using the getSequence method you wrote above

  Write a java program called salesinfominer

Write a Java program called SalesInfoMiner that reads in a file of products, stored in text format. The program must then read in information about past sales transactions and output all the products to a new file, sorted by product description,..

  Your task in this assignment is to develop a graphical user

your task in this assignment is to develop a graphical user interface based java program that can communicate with a

  Part-11 suppose we have a rectangle class that includes

part-11. suppose we have a rectangle class that includes length and width attributes of type int both set by the

  Task 1 create a new project in eclipsecreate a package

task 1 create a new project in eclipse.create a package called lsquopeople within this project. download the start up

  Rock-paper-scissors :- java problem

Design decision marks are based on how you implemented our programs/classes.

  Ceate an application which represents a simplified course

create an application which represents a simplified course registration system using arraylists and hashmaps.define a

  Simple single-server queue has one line of waiting

simple single-server queue has one line of waiting customers and one server who wait on customers. suppose that

  Describe different professional levels in this discipline

What is Anesthesiology and critical care medicine describe the specific discipline, what is their focus (i.e., emergency medicine, education and prevention, psychiatric treatment etc.) Describe the different professional levels in this discipline

  A method with the signature public static void

A method with the signature public static void printDetails(City[] cities) that will iterate through the cities and printthe details of the city using the displayDetails(...) method.

  Write a java program

To become familiar with how infix expressions can be converted to postfix expressions.

  Allow the user to display a work history report

The 'report screen' shall:Allow the user to display a work history report for an individual or for all employees for the two weeks prior to the report request.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd