Assignment 1
Assignment 1
Question 2 (2 points):
Write a program (LargestNumber.java) that takes three integers as input and determines the largest among
them. Display the largest number. First your program must prompt the user to enter three integers.
Note: It is a good practice to close the Scanner to free up system resources.
Question 3 (5 point):
Write a program (CharacterTypeCheck.java) that takes a character as input and checks if it is a lowercase,
uppercase or number letter. If the character is a lowercase letter such as ‘a’ it must display “Lowercase
letter” message to the user. If the character is an uppercase letter such as ‘A’ it must display “Uppercase
letter” message to the user. If the character is a number such as ‘1’ it must display “Number” message to
the user. In any other cases such as ‘(’ 1’ it must display “Number” message to the user “Other character”
to the user.
Note#1: Your program must prompt the user to enter a character. Also, it must convert the character to its
corresponding ASCII value and identify lowercase, uppercase, and number based on their ASCII values.
Note#2: To write this code you will need to use the information in the ASCII Conversion Chart at
https://web.alfredstate.edu/faculty/weimandn/miscellaneous/ascii/ascii_index.html
First try to write the program without any hints, if you are stuck in any part of the code use the following
hints to figure out what might be a potential solution for that. (YOU DON’T HAVE TO FOLLOW THIS
INSTRUCTION!)
1. Understand ASCII values: Familiarize yourself with the ASCII table, which assigns numerical
values to characters. Lowercase letters have ASCII values ranging from 97 to 122, uppercase
letters from 65 to 90, and numbers from 48 to 57.
2. Prompt for user input: Use the Scanner class to prompt the user to enter a character.
3. Read and store the input: Use the charAt(0) method to read the first character entered by the user
and store it in a char variable.
4. Convert to ASCII value: Use type casting (int) to convert the character to its corresponding ASCII
value and store it in an int variable.
5. Check lowercase condition: Use an if statement to check if the ASCII value falls within the range
of lowercase letters (97 to 122). If true, print "Lowercase letter".
6. Check uppercase condition: Use an if statement to check if the ASCII value falls within the range
of uppercase letters (65 to 90). If true, print "Uppercase letter".
7. Check number condition: Use an if statement to check if the ASCII value falls within the range of
numbers (48 to 57). If true, print "Number".
8. Handle other characters: If none of the conditions are met, assume the character is something
other than a lowercase letter, uppercase letter, or number, and print "Other character".
9. Test with different characters: Verify that your program works correctly by testing it with various
input characters. Test cases should include lowercase letters, uppercase letters, numbers, and
other characters.
10. Use meaningful variable names: Choose meaningful variable names, such
as character and asciiValue, to make your code more readable and easier to understand.
11. Use comments: Add comments to your code to explain what each section or line of code does.
This will make your code more readable and easier to understand.