CSC1110 Homework 4
Complete the following CodingBat problems
farEnough
makeChange
sumDigits
middleThree
Complete the following program
Write a program called VariableNameChecker
that checks the properness of a given variable name. More specifically, your program should specify whether a user-entered variable name is:
- illegal
- legal, but uses poor style
- good.
There are different opinions as to what constitutes good style for a variable name. For this program, check for good style using these rules:
- Only use letters and digits.
- Use a lowercase letter for the first character.
You don’t need to check for an uppercase letter for the first letter in the second word, third word, etc.
Remember that it is illegal to have spaces in a java variable name and you cannot start a variable name with a numeric digit.
Sample session output
This program checks the properness of a proposed Java variable name. Enter a variable name (q to quit): streetAddress2 Good! Enter a variable name (q to quit): street address2 Illegal. Enter a variable name (q to quit): StreetAddress2 Legal, but uses poor style. Enter a variable name (q to quit): 2ndStreetAddress Illegal. Enter a variable name (q to quit): street$address$2 Legal, but uses poor style. Enter a variable name (q to quit): q
Submission Instructions:
Make sure you are logged into CodingBat so your progress is saved. Submit your VariableNameChecker.java file.