Homework 3 Assignment:

You will be provide with a lab template that has all the problems represented by a single function that you must code to give the correct outputs based on inputs.

For instance problem P3.19 will have an entry in the lab template that looks like this:

 // Problem P 3.19
 public static boolean p319(double x, double y) {
  // START CODE
  return true;
  // STOP CODE
 }

You will be expect to only modify the code between the two START and STOP code comments. We give you an easy example to see how to very easily build up a String with a correct answer. (For those curious, a better way to do it is to use a StringBuilder, but that is more complex than we care to explain at this time)


P3.19
Write a function p319 that takes two floating-point numbers and returns whether they are the same up to two decimal places. Here are two sample runs:

double x = 2.0;
double y = 1.99998;
System.out.println( p319(x, y) );  // True;

double x = 2.0;
double y = 1.98999;
System.out.println( p319(x, y) );  // False;


P3.25 
Write a function that takes a single character from the alphabet. Return "Vowel" or "Consonant", depending on the input. If the input is not a letter (between a and z or A and Z), or is a string of length > 1, return "Error".


P4.3
Write a function that takes a string as an input and then returns:

a. Only the uppercase letters in the string.
   For example: "abCDe" -> "CD"

b. Every second letter of the string.
   For example: "abcde" -> "bd"

c. The string, with all vowels replace by an underscore (_)
   For exampple: "abcde" -> "_bcd_"

d. The number of vowels in the string.
   For example: "abcde" -> "2"

e. The positions of all vowels in the string, separated by commas.
   For example:  "abcde" -> "0,4"


P4.5
Write a function that takes a string with positive floating-point numbers separated by spaces. Then return a string in the following format:

"Average: W
Smallest: X
Largest: Y
Range: Z"

Where W is the average of all the numbers, X is the smallest of the numbers, Y is the largest number, and Z is the range (difference between the smallest and largest).

We give you help in outputing the test in the proper format in the code template.

Example:
INPUT: "1.1 2.2 3.3" -> 

"Average: 2.2
Smallest: 1.1
Largest: 3.3
Range: 2.2"


======================
Final Notes:
======================

Remember to submit your code using:

cd ~/$USER-submissions
git submit


You can use the program:
winscp

To copy files locally and back to silo. Just remember that your submission
does not count unless you submit it using git. You can verify that your
submission was successful by logging into

github.iu.edu

and browsing to your Homework3.java and making sure the file is the one you
want to submit.