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

  Personalize the time zone application of section 24.3

Personalize the time zone application of Section 24.3. Prompt the user to log in and specify a city to be stored in a profile. The next time the user logs in, the time of their favorite city is displayed automatically.

  Provide java code for a method

Provide Java code for a method that would perform functionality of your choice. Try to create functionality that is unique - something that you could use. Be sure to include an example call to your method and explain the code you developed.

  Write an application that displays a table of the pythagorea

Write an application that displays a table of the Pythagorean triples for side1, side2 and the hypotenuse, all no larger than 100.

  How many tickets for each class of seats were sold

Prepare a program that asks how many tickets for each class of seats were sold, then shows the amount of income generated from ticket sales.

  Definition of a method named copy receives

Write the definition of a method named copy receives a reference to a Scanner object associated with a stream of input. The method reads all the Strings remaining to be read from the stream and displays them

  Write a java program to simulate a die

Write a Java program to simulate a die. A die has values of either 1, 2, 3, 4, 5 or 6 on the face. You should use the Math.Random() or the java.util.Random() class to generate the values on the die. The program should prompt the user to enter how ..

  Reverse the array, and find the largest element

find the max block of an array by splitting it into three parts: left, middle, right. And then reverse the array, and find the largest element.

  Multiplexors whose control bit allows you

Design a 4-bit up/down counter that has 2 to 1 multiplexors whose control bit allows you to select between one of two counting modes up or down

  Implement program that uses priority queues of strings

Write a program in Java that uses priority queues of strings to sort lines of text in reverse alphabetic order. You may choose how you define alphabetic order.

  Implement a class student

Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply a suitable constructor and methods getName( ), addQuiz(int score), getTotalScore( ), and getAverageScore ( ).

  Latin squares - puzzle

Solve button causes the program to display a single solution by using only the symbols from the top row of six text fields in such a way that the non-empty grid symbols are not altered.

  Write program to keep track of a hardware stores inventory

Write a program to keep track of a hardware store's inventory. The store sells various items. For each item in the store, the following information is kept: item ID, item name, number of pieces in stock, manufacturer's price of the item, and the s..

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