Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program to the following tasks. Use Java API Documentation to find suitable String methods to complete the tasks when needed. Declare a

image text in transcribed

Write a Java program to the following tasks. Use Java API Documentation to find suitable String methods to complete the tasks when needed. Declare a String variable str. Set the value of str to your complete name, one word for your first name (without space) and one word for your last name (without space), having one space between them, and all in lowercase. (Therefore, the format of the String str is something like "xxxxXX XXXXXXxxxx.) Display the value of str. Display the length of str. Extract your first name from str and put it into another String variable, called firstName. Do the same for your last name and put it into a String variable, called lastName. Declare another String variable, str2, and initialize it with lastName, a comma, a space and then firstName. Display str2. Display the position (index) of the first occurrence of the last character of your lastname in your firstname. Display the position (index) of the last occurrence of the first character of your lastname in your firstname. Replace the first character of the firstName variable with its uppercase and put it back into firstName variable. Do the same for lastName. Display firstName and lastName. *Note that you are not allowed to use fixed numbers to apply the requested tasks. This means that when you do the tasks, assume that you don't exactly know the exact contents of the variables. Activity 2. Follow the steps to implement a class for the following requirements' specification: Alice wants to store the information of all her books. She would like to be able to create new book by giving its name as the mandatory value. Sometimes she creates new book by indicating name and author. Except name and author, any book can have year of publication and number of pages. Alice wants to have the following functionalities as well: 1- Get the name of a book 2- Get the author of a book 3- Get the year of publication of a book 4- Get the number of pages of a book 5- Set/change each of the information of a book Having the above requirements, provide a Java class for Alice, named Book, by using all the steps we learned in order

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Third International Conference Achids 2011 Daegu Korea April 2011 Proceedings Part 2 Lnai 6592

Authors: Ngoc Thanh Nguyen ,Chong-Gun Kim ,Adam Janiak

2011th Edition

3642200419, 978-3642200410

Students also viewed these Databases questions

Question

a global history of architecture

Answered: 1 week ago