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

  Area-glass tabletop

Ellie bought a circular etched-glass tabletop to use as her dining room table. The glass is 18 ft in diameter. Find the cost of the tabletop at $ 96 per square yard of glass.

  Inverses of modulus

Show that the positive integers less than 11, except 1 and 10, can be split into pairs of integers such that each pair consists of integers that are inverses of each other modulo 11.

  Find an 85 percent confidence interval

Find an 85 percent confidence interval

  Missing dimension of a cone

Find the missing dimension for this three-demensional figure to the nearest tenth, given the volume and other demensions.

  Student''s first reason for application to the school

Probabilities, A survey of MBA students obtained the following data on "student's first reason for application to the school in which they matriculated".

  Question regarding poincare model

Poincare's model of Lobachevskian geometry was to say that points of the plane are represented by points in the interior of a circle and lines by both the diameters of the circle and the arcs of circles orthogonal to it. Draw a diagram(s) to illus..

  What is the probability that the first individual to whom

What is the probability that the first individual to whom measure is given is not truly depressed if not diagnosed as depressed.

  Find the probability of 14

Find the probability of 14 or more widowed people in a random sample of 290 bowling league members?

  What is the probability of getting an a on the exam

What is the probability of getting an A on the exam? What is the probability of getting an A in the course?

  Constraints, decision variables, objective functions

Constraints, Decision variables, Objective functions

  What is the expected value for the recessive phentotype

What is the expected value for the recessive phentotype of the cross Long versus Short and what is the Chi Square Sum (rounding to 3 significant figures) for Long versus Short cross?

  Proof by contradiction

Assume that n is a positive integer. Use the proof by contradiction method to prove: If 7n + 4 is an even integer then n is an even integer.

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