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

Assignment Help Mathematics
Reference no: EM13161385

1, 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.

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: EM13161385

Questions Cloud

Why are the inoculations of value : A physician orders Tylenol for a temperature greater than 101 degrees F. The patient's temperature is 100.4 F. Explain the rationale for not medicating a fever of 100.4 F. Why do schools require inoculations for childhood diseases such as mumps, m..
State the exothermic chemical reaction : The exothermic chemical reaction CO(g) + H2O(g) CO2(g) + H2(g) has Kc = 0.034 at 25°C. We currently have a flask containing all the components listed in this equation at equilibrium at 25°C. Subsequently, we will either (1) add some H2 to the flas..
What is likely to be the man problem : A 36-year-old man enters the hospital in an extremely debilitated condition. He has purple-brown skin lesions (a symptom of Kaposi's sarcoma) and a persistent cough.
An integer on this system is 4 bytes long : Assume the following for the program below. An integer on this system is 4 bytes long. The memory address where the array "a[]" was created begins at location 8000. a. #include
Write a program that allows a user to enter a line of text : Write a graphical user interface class called SentenceCounterGUI. It should be able to manipulate the sentence of words
State oleum or fuming sulfuric acid availble commerically : Oleum or fuming sulfuric acid availble commerically in concentrations ranging from 20 to 99% sulfur trioxide. 1. What is the percentage by mass of sulfer trioxide (SO3)
Calculate the effective population size of bullfrogs : In a fictional population of bullfrogs in a lake, there are 300 mature females and 300 mature males. However, only 50 of those males hold territories (and thus, are reproductive) and a further 20 of those males employ the sneaker tactic (and thus,..
What effect does cholera toxin have on a signaling pathway : Without describing specific intracellular signaling molecules, what effect does cholera toxin have on a signaling pathway?
What happens to a water molcules at the plasma : what happens to a water molcules at the plasma membrane in the cylinders that gained weight?

Reviews

Write a Review

Mathematics Questions & Answers

  Questions on ferris wheel

Prepare a Flexible Budget Gator Divers is a company that provides diving services such as underwater ship repairs to clients in the Tampa Bay area.

  Logistic map

This assignment has two question related to maths. Questions are related to bifurcation cascade and logistic map.

  Finding the probability of cards

This assignment has questions related to probabiltiy.

  Systems of ode

Find all the xed points, and study their stability and Draw the phase portrait of the system, as well as the graphs of the solutions in all relevant cases.

  Derive the boolean expression

Derive the Boolean Expression and construct the switching circuit for the truth table stated

  System of equations

Evaluate which equations are under-identified, just-identified, and over-identified.

  Linear programming problem

Linear programming problem consisting of only two constraints with one objective function.

  Find the natural domain

Find the natural domain of the given functions.

  Introduction to numerical methods

Compute the coecients of the polynomials using the term recurrence relation.

  Chart of the topological manifold

De?nition of smoothness of functions on a smooth manifold is chart independent and hence geometric.

  Mathematics in computing

Questions related on mathematics in computing.

  Complex problems

Complex problems

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