![Java: An Introduction to Problem Solving and Programming plus MyProgrammingLab with Pearson eText -- Access Card Package (7th Edition)](https://www.bartleby.com/isbn_cover_images/9780133862119/9780133862119_largeCoverImage.gif)
Explanation of Solution
a.
Method heading for each method:
- • Method heading for access method of each attribute:
- ○ Access method for person first name is “public String getPersonFirstName()”.
- ○ Access method for person last name is “public String getPersonLastName()”.
- ○ Access method for person email address name is “public String getPersonEmailAddress()”...
Explanation of Solution
b.
Preconditions and postconditions of each method:
- • Precondition and postcondition of access method for each attribute.
- ○ For method “getPersonFirstName()”:
- ■ Precondition: None
- ■ Postcondition: Returns the first name of given person.
- ○ For method “getPersonLastName()”:
- ■ Precondition: None
- ■ Postcondition: Returns the last name of given person.
- ○ For method “getPersonEmailAddress()”:
- ■ Precondition: None
- ■ Postcondition: Returns the email address of given person.
- ○ For method “getPersonTelephoneNumber()”:
- ■ Precondition: None
- ■ Postcondition: Returns the telephone number of given person.
- ○ For method “getPersonFirstName()”:
- • Precondition and postcondition of “changeEmailAddress(String nEmail)” method...
Explanation of Solution
c.
Test class for some Java statement:
//Create object "p1" for "PersonAddress" class
PersonAddress p1 = new PersonAddress();
//Create object "p2" for "PersonAddress" class
PersonAddress p2 = new PersonAddress();
//Create object "p3" for "PersonAddress" class
PersonAddress p3 = new PersonAddress();
//Set values for "p1" by calling method "setPersonAddress"
p1.setPersonAddress("John", "Merry", "john123@aaa.com", "123-4567");
//Set values for "p2" by calling method "setPersonAddress"
p2.setPersonAddress("John", "Merry", "jr@ccc.com", "123-7654");
//Set values for "p3" by calling method "setPersonAddress"
p3.setPersonAddress("Jansi", "Rose", "htr@aaa.com", "333-4444");
//Display the statement
System.out.println("Values of attributes for person 1.");
//Display person "p1" first name by calling method "getPersonFirstName"
System.out.println("First Name: " + p1.getPersonFirstName());
//Display person "p1" last name by calling method "getPersonLastName"
System.out.println("Last Name: " + p1.getPersonLastName());
//Display person "p1" email address by calling method "getPersonEmailAddress"
System.out.println("Email Address: " + p1.getPersonEmailAddress());
//Display person "p1" telephone number by calling method "getPersonTelephoneNumber"
System.out.println("Telephone Number: " + p1.getPersonTelephoneNumber());
System.out.println();
//Display the given statement
System...
Explanation of Solution
d.
Implementation of class:
PersonAddress.java:
//Import package
import java.util.Scanner;
//Define class "PersonAddress"
public class PersonAddress
{
//Declare required variables in "private" access specifier
private String first_Name;
private String last_Name;
private String email_addr;
private String telephone_number;
//Set value for "PersonAddress" class
public void setPersonAddress(String f, String l, String e, String p)
{
//Assign value to given instance variables
first_Name = f;
last_Name = l;
email_addr = e;
telephone_number = p;
}
//Access method for person first name
public String getPersonFirstName()
{
//Returns person first name
return first_Name;
}
//Access method for person last name
public String getPersonLastName()
{
//Returns person last name
return last_Name;
}
//Access method for person email address
public String getPersonEmailAddress()
{
//Returns person email address
return email_addr;
}
//Access method for person telephone number
public String getPersonTelephoneNumber()
{
//Returns person telephone number
return telephone_number;
}
//Method for change person Email Address
public void changeEmailAddress(String nEmail)
{
//Assign "email_addr" to "nEmail"
email_addr = nEmail;
}
//Method for change person PhoneNumber
public void changePhoneNumber(String nPhone)
{
//Assign "telephone_number" to "nPhone"
telephone_number = nPhone;
}
//Method for check two persons are equal
public boolean equalMethod(PersonAddress otherPerson)
{
//Returns true if persons are equal
return last_Name.equals(otherPerson.last_Name) && first_Name.equals(otherPerson.first_Name);
}
//Define main function
public static void main(String[] args)
{
//Create object "p1" for "PersonAddress" class
PersonAddress p1 = new PersonAddress();
//Create object "p2" for "PersonAddress" class
PersonAddress p2 = new PersonAddress();
//Create object "p3" for "PersonAddress" class
PersonAddress p3 = new PersonAddress();
//Set values for "p1" by calling method "setPersonAddress"
p1.setPersonAddress("John", "Merry", "john123@aaa.com", "123-4567");
//Set values for "p2" by calling method "setPersonAddress"
p2.setPersonAddress("John", "Merry", "jr@ccc.com", "123-7654");
//Set values for "p3" by calling method "setPersonAddress"
p3.setPersonAddress("Jansi", "Rose", "htr@aaa.com", "333-4444");
//Display the statement
System.out.println("Values of attributes for person 1.");
//Display person "p1" first name by calling method "getPersonFirstName"
System.out.println("First Name: " + p1.getPersonFirstName());
//Display person "p1" last name by calling method "getPersonLastName"
System.out.println("Last Name: " + p1.getPersonLastName());
//Display person "p1" email addressby calling method "getPersonEmailAddress"
System...
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 5 Solutions
Java: An Introduction to Problem Solving and Programming plus MyProgrammingLab with Pearson eText -- Access Card Package (7th Edition)
- Methods (Ch6) - Review 1. (The MyRoot method) Below is a manual implementation of the Math.sqrt() method in Java. There are two methods, method #1 which calculates the square root for positive integers, and method #2, which calculates the square root of positive doubles (also works for integers). public class SquareRoot { public static void main(String[] args) { } // implement a loop of your choice here // Method that calculates the square root of integer variables public static double myRoot(int number) { double root; root=number/2; double root old; do { root old root; root (root_old+number/root_old)/2; } while (Math.abs(root_old-root)>1.8E-6); return root; } // Method that calculates the square root of double variables public static double myRoot(double number) { double root; root number/2; double root_old; do { root old root; root (root_old+number/root_old)/2; while (Math.abs (root_old-root)>1.0E-6); return root; } } Program-it-Yourself: In the main method, create a program that…arrow_forwardI would like to know the main features about the following 3 key concepts:1. Backup Domain Controller (BDC)2. Access Control List (ACL)3. Dynamic Memoryarrow_forwardIn cell C21, enter a formula to calculate the number of miles you expect to drive each month. Divide the value of number of miles (cell A5 from the Data sheet) by the average MPG for the vehicle multiplied by the price of a gallon of gas (cell A6 from the Data sheet).arrow_forward
- Microsoft Excelarrow_forwardIn cell C16, enter a formula to calculate the price of the vehicle minus your available cash (from cell A3 in the Data worksheet). Use absolute references where appropriate—you will be copying this formula across the row what fomula would i use and how do i solve itarrow_forwardWhat types of data visualizations or tools based on data visualizations have you used professionally, whether in a current or past position? What types of data did they involve? What, in your experience, is the value these data views or tools added to your performance or productivity?arrow_forward
- Question: Finding the smallest element and its row index and column index in 2D Array: 1. Write a public Java class min2D. 2. In min2D, write a main method. 3. In the main method, create a 2-D array myArray with 2 rows and 5 columns: {{10, 21, 20, 13, 1}, {2, 6, 7, 8, 14}}. 4. Then, use a nested for loop to find the smallest element and its row index and column index. 5. Print the smallest element and its row index and column index on Java Consolearrow_forward(using R)The iris data set in R gives the measurements in centimeters of the variables sepal length and width andpetal length and width, respectively, for 50 flowers from each of 3 species of iris, setosa, versicolor, andvirginica. Use the iris data set and the t.test function, test if the mean of pepal length of iris flowers isgreater than the mean of sepal length.The iris data set in R gives the measurements in centimeters of the variables sepal length and width andpetal length and width, respectively, for 50 flowers from each of 3 species of iris, setosa, versicolor, andvirginica. Use the iris data set and the t.test function, test if the mean of pepal length of iris flowers isgreater than the mean of sepal length.arrow_forwardRecognizing the Use of Steganography in Forensic Evidence (4e)Digital Forensics, Investigation, and Response, Fourth Edition - Lab 02arrow_forward
- Write a Java Program to manage student information of a university. The Javaprogram does the following steps:a) The program must use single-dimensional arrays to store the studentinformation such as Student ID, Name and Major.b) The program asks the user to provide the number of students.c) The program asks the user to enter the Student IDs for the number of studentsand stores them.d) The program asks the user to enter the corresponding names for the numberof students and stores them.e) The program then asks the user to provide the corresponding major for thestudents and stores them.f) The program then should display the following options:1. ID Search2. Major Enrollment3. Exitg) On selecting option 1, the user can search for a student using Student ID. Theprogram asks the user to enter a Student ID. It then should print thecorresponding student’s details such as Name and Major if the user providedStudent ID number is present in the stored data. If the user’s Student IDnumber does not…arrow_forward(a) Algebraically determine the output state |q3q2q1q0> (which is a 4-qubitvector in 16-dimensional Hilbert space). Show all steps of your calculations. (b) Run a Qiskit code which implements the circuit and append threemeasurement gates to measure the (partial) output state |q2q1q0> (which is a 3-qubit vector in 8-dimensional Hilbert space). this is for quantum soft dev class, you can use stuff like Deutsch Jozsa if u wantarrow_forwardWrite a C++ program that will count from 1 to 10 by 1. The default output should be 1, 2, 3, 4, 5, 6 , 7, 8, 9, 10 There should be only a newline after the last number. Each number except the last should be followed by a comma and a space. To make your program more functional, you should parse command line arguments and change behavior based on their values. Argument Parameter Action -f, --first yes, an integer Change place you start counting -l, --last yes, an integer Change place you end counting -s, --skip optional, an integer, 1 if not specified Change the amount you add to the counter each iteration -h, --help none Print a help message including these instructions. -j, --joke none Tell a number based joke. So, if your program is called counter counter -f 10 --last 4 --skip 2 should produce 10, 8, 6, 4 Please use the last supplied argument. If your code is called counter, counter -f 4 -f 5 -f 6 should count from 6. You should count from first to last inclusively.…arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781305480537/9781305480537_smallCoverImage.jpg)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)