Java Reference
In-Depth Information
Enter a year: 2016
Enter a month: Feb
Jan 2016 has 29 days
*4.18
( Student major and status ) Write a program that prompts the user to enter two
characters and displays the major and status represented in the characters. The first
character indicates the major and the second is number character 1, 2, 3, 4, which
indicates whether a student is a freshman, sophomore, junior, or senior. Suppose
the following chracters are used to denote the majors:
M: Mathematics
C: Computer Science
I: Information Technology
Here is a sample run:
Enter two characters: M1
Mathematics Freshman
Enter two characters: C3
Computer Science Junior
Enter two characters: T3
Invalid input
4.19
( Business: check ISBN-10 ) Rewrite the Programming Exercise  3.9 by entering the
ISBN number as a string.
4.20
( Process a string ) Write a program that prompts the user to enter a string and dis-
plays its length and its first character.
*4.21
( Check SSN ) Write a program that prompts the user to enter a Social Security
number in the format DDD-DD-DDDD, where D is a digit. Your program should
check whether the input is valid. Here are sample runs:
Enter a SSN: 232-23-5435
232-23-5435 is a valid social security number
Enter a SSN: 23-23-5435
23-23-5435 is an invalid social security number
4.22
( Check substring ) Write a program that prompts the user to enter two strings and
reports whether the second string is a substring of the first string.
Enter string s1: ABCD
Enter string s2: BC
BC is a substring of ABCD
 
Search WWH ::




Custom Search