Create a class called hw1firstlastnamejavain a project


In this assignment, you may use your knowledge of the following concepts:

1) Math (+, %, ++, +=) and relational operators (!=, ==, <,>)
2) For loop, if-else
3) Arrays - accessing elements in a location, finding the length of the array
4) String class - length(), toCharArray(), charAt(),substring()
5) Making a simple method call to built-in classes and sending an input (known as argument)

Create a class called Hw1FirstLastName.javain a project called hw1firstlastname

In the main method of this class file, create a string called sentence and assign it a word or sentence of your choice. The rest of the assignment involves working with the contents of this sentence. You should test and ensure that your program works with sentences of different lengths and characters (letters/numbers/special characters).

We will use this sentence as a password starting phrase to automatically create a new password as follows.

Task 1. Create a new string called passwd formed by concatenatingevery alternate non-spacecharacter in sentencestarting with the first. To do this, you need to a loop to go through the string sentence and retrieve characters from alternate index positions. If the extracted alternate character is NOT a space, then add it to the new String. Do not include spaces.
Print out the following.
The starting sentence is: ___________
The password in task 1 is: ___________

Task 2. If the length of passwd is even, extract a substring which is the first half of passwd and use this as the new passwd. Leave passwd as is if its length is odd. Print this passwd.
The password in task 2 is: ___________

Task 3. Convert passwdfrom task 2 to a character array called pwdArray. Sum the numeric value (Unicode value) of all the characters in pwdArray. To do this, create a new int variable called sum, and in a loop, add each char obtained from the array to sum (the underlying int value of the char will be obtained and added to sum). Once the loop has ended, divide this sum by 2 if the sum is even, or leave it as it is if the sum is odd. Then append the sum to the end of the passwd.
Print out the following.
The new password in task 3 is: ___________

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Create a class called hw1firstlastnamejavain a project
Reference No:- TGS01082562

Expected delivery within 24 Hours