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

  Write a server for multiple clients

Write a server for multiple clients. The client sends loan information (annual interest rate, number of years, and loan amount) to the server. The server computes monthly payment and total payment and sends them back to the client.

  Q1write a program called linearstringsearchjava that looks

q1.write a program called linearstringsearch.java that looks for a target string value in an array of string values.

  Statements to print a label

Add the statements to print a label in the following format (the numbers in the example output are correct for input of $4.25 per pound and 41 ounces). Use the formatting object money to print the unit price and total price and the formatting object ..

  Write an application with three labeled text field

Write an application with three labeled text fields,one each for the initial amount of a savings account, the annual interest rate, and the number of years. Add a button "Calculate" and a read-only text area to display the balance of the savings acco..

  Find the nth largest of 2 sorted arrays of length n

In java, use divide and conquer to find the nth largest of 2 sorted arrays of length n.

  Create an application in which a user can enter a phone book

Create an application in which a user can enter a phone book entry, including the subsequent elements: First Name, Last Name, Phone Number, email address

  The letters of the alphabet a through z

The letters of the alphabet A through Z can be represented in Morse code. Each letter is represented by a combination of up to four dots and/or dashes, as shown below. Use Java to write and run a console-window program that can convert an English ..

  Generates a random number between 1 and 100

Write a program that generates a random number between 1 and 100 (inclusive) and then prompts the user to guess the number. The user should be given up to 10 chances to guess the number.

  Create a japplet

Create a JApplet that contains a JLabel and JButton. You'll create a JButton that will automatically change font typeface, style, and size when clicked by the user.

  Write a java program to read the numbers from the disk file

Write a Java program to read the numbers from the disk file and store them in an integer array ( not an ArrayList ).

  Allows the user to specify a triangle with three mouse press

Write a program that allows the user to specify a triangle with three mouse presses. After the first mouse press, draw a small dot. After the second mouse press, draw a line joining the first two points. After the third mouse press, draw the entir..

  In this project you need to write a java program called

in this project you need to write a java program called mm.java to perform matrix multiplication. your code will read

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