You are on page 1of 11

Assignment: 01

Course Title: Object Oriented Programming

Course Code: PMSCS 602


Chapter: 2
Submission Date: 30 APR 2021

Submitted To:
Dr. Md. Ezharul Islam
Associate Professor
Dept. of CSE.
Jahangirnagar University.
Submitted By:
Shantanu Mazumder
Student Roll: CSE202101154
Jahangirnagar University
CSE, PMSCS.
 Level 1 Programming Exercise:
17. Write a program that displays a frame window 800 pixels wide and 600 pixels

high. Set the title of the frame to Welcome to Java.

Answer: Input and output are shown below


19. Input the user’s first, middle, and last name as three separate strings and display the name
in the order of the first name, the middle initial, and the last name. Include the period after the
middle initial. If the input strings are Wolfgang, Amadeus, and Mozart, for example, then the
output would be Wolfgang A. Mozart. Use the console window for output.

Answer: Source code and output are shown below:


20. Write a program to display today’s date in this format: 10 December 2008.

Use the console window for output.

Answer:

Source Code:

Output:
21. Write a program to display today’s date in this format: Monday December 10, 2008.

Answer: Source code and output are given below:

 Level 2 Programming Exercise:


22. Write a program that displays a frame window W pixels wide and H pixels high. Use the
Scanner to enter the values for W and H. The title of the frame is also entered by the user.

Answer:

Source Code:

Output:
23. Display the current time in the title of a frame window using this format: 12:45:43 PM.
Answer: Source Code and output are shown below:

 Level 3 Programming Exercise:


28. Write a program that accepts a word and prints out the middle character. The length of the
input word is odd. For example, if the input is magnificent, which has 11 characters, you output
the sixth character f.

Answer:

Source Code:

Output:
 Development Exercise:
35. Problem Statement: Write a program that asks the user for her or his full name in the
format: “first middle last” and replies with the name in the format : “last , first middle-initial.”
where the last name is followed by comma and the middle initial is followed by period.

Answer:

Source Code:

Output:

You might also like