Write a java method that takes an array of type

Assignment Help English
Reference no: EM133390170

PROBLEM 1
Write a Java method that takes an array of type int and a variable of type int. The method returns true if the sum of values in the array is evenly divisible by the second argument in the method, otherwise, the method returns false.

The method header is as follows.

public static boolean threshold(int[ ] x, int y)

Sample run

Result

Consideration

int[ ] x = {1, 2, 3};

boolean b = threshold(x, 3);

true

The remainder of 6 divided by 3 is zero

int[ ] x = {8, 8, 8, 8};

boolean b = threshold(x, 8);

true

The remainder of 32 divided by 8 is zero

int[ ] x = {5, 2, 4, -3};

boolean b = threshold(x, 5);

false

The remainder of 8 divided by 5 is 3

PROBLEM 2

Write a Java method that takes a variable of type String and returns a value of type boolean. The method returns true if the parameter string contains a valid password, and false otherwise. A valid password should satisfy all the following conditions:
• It can contain only hexadecimal digits (hexadecimal digits are the values 0 to 9 and the characters a to f)
• Its length is larger than or equal to 9 characters
• It starts with a decimal digit (0 to 9).

The method's header is as follows.

public static boolean password(String s)

Sample Run

Result

String s = "8abc93def0";

boolean b = password(s);

true

String s = "abcde189715";

boolean b = password(s);

false

PROBLEM 3
Write the following class: Person.

Details
Class Person is to have the following data members: firstName of type String, lastName of type String representing a person's first and last names and ssn of type int representing a social security number. Each data member has an access specifier of type private.

Implementation
Class Person is to have two constructors with the following specifications:
a no-arg constructor that initializes each String to an empty String and the integer data member to zero;

a constructor that takes three arguments, each representing one of the class data members. The arguments are to be listed in the order of (firstName, lastName, ssn);

Class Person is to have standard get/set methods for each data member.

Class Person is to have a method named equals(Person other ) method to do the following:
determine if the calling object and the parameter object (other) store identical data values for the corresponding data members (firstName, lastName, ssn)

Class Person is to have a method named display( ) that displays the following information in the format presented:
First Name: display firstName data
Last Name: display lastName data
SSN: display ssn data

Reference no: EM133390170

Questions Cloud

Literature search on the topic of workplace discrimination : Imagine that you are a leader in a large organization that has received multiple complaints of discrimination. You are not a subject matter expert
How do the facts of that armed conflict fit : Were the beginnings of the U.S. Civil War a terrorist action? Why or why not? How do the facts of that armed conflict fit with the definitions of terrorism
What is the role of strategic hrm in large organization : What is the role of Strategic HRM in large Organizations who value diversity - we miss the opportunity to ask the right questions. That's what enables us
Describe elements of good teamwork : Describe elements of good teamwork. You must discuss how or why good teamwork is important, relying on the comments from Sinek
Write a java method that takes an array of type : CS200 Programming Write a Java method that takes an array of type int and a variable of type int. The method returns true if the sum of values in the array
What are your priorities for the teaching : What are your priorities for the teaching, what drugs are they probably going home with? How will they take them?
Discuss the ethical aspects of acquiring : Discuss the ethical aspects of acquiring and sharing knowledge, and how to share the knowledge with the body of the industry. In today's complicated
Define your reason for writing thesis and treat : Define your reason for writing thesis and treat both ideas equally as to pros and cons,costs to promote ,validity, efficiency to use, probability of success
What are advantages of the subcultural theory of urbanism : What are the advantages of the subcultural theory of urbanism? Is the theory persuasive and What are the limitations or weaknesses of the theory

Reviews

Write a Review

English Questions & Answers

  Write a profile

Write a profile on bishop poleni.

  Education system

Write a rearch paper on education system

  Write an report

The U.S. President Barack Obama said America can "win the future" by rebuilding its manufacturing sector (on June 8, 2011, after visiting an automotive training center at a community college in Virginia, outside Washington). Do you agree, and why?

  Discuss the accuracy of this statement

'Consideration does not have to be adequate or commercially realistic, nor does it need to be expressed in monetary terms, it merely needs to be "sufficient".' Discuss the accuracy of this statement.

  Write an essay on the youngest billionaire

Write an essay on the youngest billionaire

  Transformational leadership in the public sector

The more hierarchical an organization's authority structure, the lower the reported practice of transformational leadership behaviors.

  Modal verbs or modal constructions

Identify all the modal verbs or modal constructions in the passage

  Write a latter to mom thanking to adopting and caring

Write a latter to mom thanking for adopting and caring,

  Ways of knowing & authority in your discipline

To explore and become familiar with your discipline; to prepare you for your major researched essay.

  Writing an effective business letter

Prepare a letter in either block or modified block format, addressed to your employer or supervisor and copied to your marker.

  Discuss the kingdom of saudi arabia

Discuss the Kingdom of Saudi Arabia

  Developing an annotated bibliography

Developing an annotated bibliography

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