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

  Writing a java program that provides simple statistics

You will be writing a Java program that provides simple statistics about the input data. The method stubs are given below. This assignment will give you experience with methods

  1 rock-paper-scissors simplejavaproblems 1-3 are based on

1 rock-paper-scissors simple.javaproblems 1-3 are based on the rock-paper-scissors game. if you are unfamiliar with

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Create the working applet to compute tax

Write down a java applet. Your applet assits to find out how much federal tax we require to pay suppose the tax rate is 12%. Create and implement the working applet to compute tax.

  Shows the users name and program name

Java program, the program has a page that shows the users name and program name. a second jpanel that shows 4 buttons (circle square rectangle and oval) the problem i am having is that my program is not dropping where i click and the shapes are not s..

  The desired functionality is for your programs to input

the desired functionality is for your programs to input pairs of natural numbers as theyre entered by the user until

  What is overloading and what is overriding

What is overloading and what is overriding? Please use code to explain it.

  Prepare executable program and a dictionary program

Prepare executable program and a dictionary Program.

  Create a constructor in the subclass why

Assume there is a base class with multiple constructors, if the subclass inherits from the base class, do we need to create a constructor in the subclass? Why?

  Be sure to show all declarations

Write a function call that invokes function a. Be sure to show all declarations. However a complete main is not required.

  The program randomly generates the quiz question one by

the program randomly generates the quiz question one by one from a set of available questions on general knowledge

  Rock-paper-scissors :- java problem

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

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