Assignment #2

Multiple Functions

Due: 9/24/03 at 1:00 pm

Write a Java application that provides the following capabilities:
 

  1. Computes the Cartesian distance between two points (assignment #1).
  2. Calculates the arithmetic mean and standard deviation for up to 10 user input numbers.
  3. Calculates the number of vowels in user entered string up to 30 characters.
  4. Approximates the value of an infinite series (up to 12 terms)

                                                                  

 

General Program requirements:
  1. Java source for all integer functions is contained in a single developer created package.
  2. Java source for each integer function is stored in a separate file.
  3. Upon function completion users are prompted to repeat process or exit.
  4. No more than 80 characters per line printed.
  5. Errant input should be enunciated.
  6. Java source prologue is extractable using Javadoc utility.
  7. Java source is well commented and extractable using Javadoc.
  8. All Java source and packages are stored in a single zip file for submission.
The program source should be in a file named "Lastname"2.zip. (i.e. Peter2.zip)

The completed assignment should be sent to [email protected]


Cartesian Distance



The following is a sample execution of an acceptable program:

Please enter an integer x1:> 2

Please enter an integer x2:> 3

Please enter an integer y1:> 8

Please enter an integer y2:> -5

The distance between the points (2,3) and (8,-5)  is:

                              13.03

Would you like the distance between two other points (1-yes, 2-no) :> 1

Please enter an integer x1:> 2

Please enter an integer x2:> 3

Please enter an integer y1:> 8

Please enter an integer y2:> -a

ERROR --- Y2 must be numeric !

Please enter an integer x1:> 4

Please enter an integer x2:> 3

Please enter an integer y1:> 6

Please enter an integer y2:> 3

The distance between the points (4,3) and (6,3)  is:

                               3.16


Would you like the distance between two other points (1-yes, 2-no) :> 2 

goodbye!


Arithmetic Mean and Standard Deviation 

 

Specific Requirements

1) Prompt users for up to 10 number.
2) Calculate the Arithmetic mean
3) Calculate the Standard deviation
4) Display answer for both calculations

The following is a sample execution of an acceptable program:

Please enter up to 10 integer values:> 20, 23, 25, 26

The arithmetic mean is: 23.5

The standard deviation is: 2.6457513

 


Number of Vowels

Specific Requirements:

  1) Prompt users entered string.

  2) Count number of vowels in string
  

 

Example Execution

    Character Sorting

    The string of character entered is: > "Thebrownfoxjumpedoverthelazydog"

    The number of vowels in string =  10

    


Infinite Series

Specific requirements:

  1) Prompt users for the value of x.

  2) Calculate ex

  3)Prompt users for the number of terms (n)

  4) Calculate the infinite series

 


The following is a sample execution of an acceptable program:

Please enter an  x value:> 2

Please enter number of terms (n):> 3

The value of ex  = 7.38

The value of the infinite series  = 6.33

Please enter number of terms (n):>4

The value of the infinite series = 6.35