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

Lab Task

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Lab Task

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Question – 1: ______

Write a Menu Driven JAVA program that creates a string array by taking input from user and
perform following tasks by displaying menu to user, the menu operations are implemented using
methods:

a) Calculate length of string.


b) Count number of words in string.
c) Check a string is palindrome or not.
d) Find a word within the array. If found display its starting position.
e) Convert a string in lowercase.
f) Convert a string in uppercase.

Question – 2: ______
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 – 3:
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 – 4:

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