0% found this document useful (0 votes)
79 views

Total Marks: 5 X 5 25 Instructions: COMSATS University Islamabad Department of Computer Science

This document provides instructions for a programming fundamentals lab assignment involving 5 Java programming questions. Students are asked to write Java source code to: 1) Print a nested loop pattern, 2) Prompt the user for a year and first day and print the days of the month, 3) Capitalize the first letter of words in a string, 4) Generate and print a random 0/1 matrix given its size, 5) Calculate and print the area of a pentagon given its side length. The assignment is to be submitted by November 14th 2021 with properly formatted source code and output for each question in a single folder.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Total Marks: 5 X 5 25 Instructions: COMSATS University Islamabad Department of Computer Science

This document provides instructions for a programming fundamentals lab assignment involving 5 Java programming questions. Students are asked to write Java source code to: 1) Print a nested loop pattern, 2) Prompt the user for a year and first day and print the days of the month, 3) Capitalize the first letter of words in a string, 4) Generate and print a random 0/1 matrix given its size, 5) Calculate and print the area of a pentagon given its side length. The assignment is to be submitted by November 14th 2021 with properly formatted source code and output for each question in a single folder.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

COMSATS University Islamabad

Department of Computer Science


Programming Fundamentals (CSC103) – BSCS-2A & 2B
LAB Assignment – 2 (CLO-3)

Due Date: November 14, 2021 (11:59 pm)

Total Marks: 5 x 5 = 25
Instructions
Answer to all questions must be submitted in MS Word.

Answer to all questions should begin on new page.

Assignment document must contain a title page showing LAB-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

Submit your work via MS Teams

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
LAB Assignment – 2 (CLO-3)

Question – 1: ______
Write a nested for loop that prints the following output:

Question – 2: ______
Write a program that prompts the user to enter the year and first day of the year, and displays the first
day of each month in the year. For example, if the user entered the year 2013, and 2 for Tuesday,
January 1, 2013, your program should display the following output:
January 1, 2013 is Tuesday

...
December 1, 2013 is Sunday

Question – 3: ______
Write a function capitalize(lower_case_word) that takes the lower case word and returns the word
with the first letter capitalized. Eg., System.out.println(capitalize(“word”)) should print the word
Word.
Then, given a line of lowercase ASCII words (text separated by a single space), print it with the first
letter of each word capitalized using the your own function capitalize().

Question – 4: ______
Write a method that displays an n-by-n matrix using the following header: public static void
printMatrix(int n)
Each element is 0 or 1, which is generated randomly. Write a test program that prompts the user to
enter n and displays an n-by-n matrix. Here is a sample run:
Enter n: 3
010
000
111
COMSATS University Islamabad
Department of Computer Science
Programming Fundamentals (CSC103) – BSCS-2A & 2B
LAB Assignment – 2 (CLO-3)

Question – 5: ______
The area of a pentagon can be computed using the following formula:

Write a method that returns the area of a pentagon using the following header:
public static double area(double side)
Write a main method that prompts the user to enter the side of a pentagon and displays its area
Sample Run
Enter the side: 5.5
The area of the pentagon is 52.04444136781625

You might also like