Create a new string called passwd

Assignment Help JAVA Programming
Reference no: EM13802285

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.
<Output> The starting sentence is: ___________
<Output> 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.
<Output> 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.
<Output> The new password in task 3 is: ___________

Reference no: EM13802285

Questions Cloud

What is not considered a cloud application : One day you decide to turn in a resource paper that you found on the Internet. What is not considered a Cloud application
Political party loyalty or campaign money may influence : Discuss fact-based evidence about how interest groups, political party loyalty, or campaign money may influence your representative. Can these influences weaken his or her effectiveness as a true "representative" of the district
Making effective and ethical decisions : Complete the experiential exercise 5.1 Assessing Yourself at the end of the chapter, "Ethics and Corporate Responsibility." Based on your score, create a plan to increase your skills in making ethical decisions in the workplace.
Visual language and culture paper : Visual Language and Culture Paper
Create a new string called passwd : Create a class called Hw1FirstLastName.javain a project called hw1firstlastname. Create a new string called passwd formed by concatenatingevery alternate non-spacecharacter in sentencestarting with the first
Inefficiencies in managing human resources : Inefficiencies in Managing Human Resources
Homeland security and emergency management : What challenges exist or may emerge as a result of unclear pathways of command, control/coordination, and convergence during disaster or incident response operations?
What are your thoughts regarding monopolies : What are your thoughts regarding Monopolies? Do you think Microsoft still runs a Monopoly? Why should they be penalized for having "all the ideas
Write a paper about language development in the primary year : Write a paper about Language Development in the Primary Years.

Reviews

Write a Review

JAVA Programming Questions & Answers

  A game of tic-tac-toe

A game of tic-tac-toe, two players (one the computer) take turns marking an available cell in a 3 X 3 grid (a two dimensional array) with their respective tokens (either and X or an O). When one player has placed three tokens in a horizontal

  Web engineering principles

web application development, Web Engineering methodology, UML-based Web Engineering (UWE), models to the expansion of web applications, Object Oriented Web Solutions (OOWS),Web Modeling Language (WebML) methodology, Object-Oriented Hypermedia Design..

  Write a program called product1ton

Write a program called Product1ToN to compute the product of integers 1 to 10 (i.e., 1×2×3×...×10). Try computing the product from 1 to 11, 1 to 12, 1 to 13 and 1 to 14.

  T an array using insertion sort and track the number of swap

How to sort an array using insertion sort and track teh number of swaps during the sorting

  Primary care-secondary care and tertitary care

Discuss the differences among primary care, secondary care, and tertitary care and the 6 C's of primary care

  Write an expression that concatenates the string variable

Write an expression that concatenates the string variable suffix onto the end of the string variable prefix.

  Disadvantages to using data structures

How are data structures managed and organized in this language. How does the management or syntax of data structures in this language differ from how data structures are handled in other language.

  Complete the method named countoutofrange

The element is greater than or equal to min AND less than or equal to max. The method should return the new array -

  Teaching software componentization

Describe one way in which one could apply Java graphics in education. Provide one example of such use to support your response and analyze at least three commands that you would use in order to draw a bar chart. Provide a rationale for your respons..

  Instantiate two savingsaccount objects

saver1 and saver2, with balances of $2000.00 and $3000.00, respectively (was trying to figure out the formula, what I have written so far is as follows, and I am trying to see if I missed something

  Write methods to retrieve information about a note

calculate the frequency, use the formula 440 x 2^(n/12) where n is the note number - implement a class that will be used to hold information about a musical note.

  Algorithm analysis with advanced data structures

Write a program to help the merchants devise a sequence of transmutations that would change silver into gold with the smallest possible total fee paid to the alchemists.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd