Total Marks: 5 X 5 25: COMSATS University Islamabad Department of Computer Science
Total Marks: 5 X 5 25: COMSATS University Islamabad Department of Computer Science
Total Marks: 5 x 5 = 25
Instructions
Answer to all questions must be submitted in MS Word.
Assignment document must contain a title page showing Assignment-2, your name and
registration number.
Assignment document must also contain JAVA source code along with output.
Solution to JAVA Programming problems must be created in separate .java file (for each
question). For example, Question1.java
You must follow proper JAVA naming convention for identifiers and properly document your
source code
Combine all your work in one folder. The folder must contain .JAVA source files and a
.doc/.docx file.
Name of the Assignment document file should be your Registration Number. E.g.
FA21BCS01.docx
Plagiarism: Plagiarism is not allowed. If found plagiarized, zero marks will be awarded in the
assignment.
COMSATS University Islamabad
Department of Computer Science
Programming Fundamentals (CSC103) – BSCS-2A & 2B
Class Assignment – 2 (CLO-3)
Question – 1: ______
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
Question – 2: ______
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
Question – 3: ______
Assume a vehicle plate number consists of three uppercase letters followed by four digits. Write a
program to generate a plate number.
Question – 4: ______
Write a program that displays all the leap years, ten per line, from 101 to 2100, separated by
exactly one space. Also display the number of leap years in this period.
Question – 5: ______
Write a program that prompts the user to enter a decimal integer and displays its corresponding
binary value. Don’t use Java’s Integer.toBinaryString(int) in this program.