Due on Monday at 5:50 PM for in-class, and 10:00 PM for DL.
Remember that COL will not allow assignments to be turned in late – don’t wait until the last second to submit!
For this assignment you will only have to turn in a single file, but one that is made up of several functions. None of these functions are very long, but they do cover nearly all of the major concepts we have discussed in class to date. The emphasis is on demonstrating an understanding of introductory programming fundamentals (creating classes, loops, if statements, functions) in Java. This is neither a long nor difficult assignment; the goal is to make sure everybody is well caught up with basic concepts.
The grader will also evaluate based on:
- Code compiling (your code must compile – you will not receive a grade if it doesn’t)
- Following all naming conventions
- Use of whitespace (it doesn’t have to be identical to mine, but you must display an understanding of the need for clarity in your code)
Create a class in which you
1. Declare a Scanner object as a class-level variable. As a comment at the bottom of your program, explain why it is convenient to make this object class-level. Be sure to use the word ‘scope’ in your discussion.
2. Have a method that prompts the user for their first name and returns that information as a String.
3. Have a method that prompts the user for 3 doubles and returns the highest of those three numbers.
4. Have a method that accepts two Strings and returns the length of the longer String.
5. Have a method that accepts a String and a char. The method should return the number of times that character shows up in the string. For example, countLetters("hello", 'l '); would return a 2.
6. Have a method that accepts two chars and returns true if the first char is “greater” than the second char. Recall that chars are stored as numbers internally. For example, ‘A’ is stored as a 65 while ‘B’ is stored as 66, etc. For example, compareChars('a ', 'A '); would return true.
7. Have a method in which you prompt the user for two doubles and return the first number to the power of the second number using the ‘pow()’ method from the Math class. However, when asking the user to enter their numbers, you should require that they only enter a number between -5.0 and +5.0. As long as they enter a number outside of this range, require themt to re-enter.