Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

"Using the PetRecord class stored on the K: drive, write a driver program with a main method to read in data for five Pets and display the following data: name of smallest pet, name of largest pet, name of oldest pet, name of youngest pet, average weight of the five pets, and average age of the five pets. Also, test to see if any of the five pets are the same."

Following is the PetRecord class..

public class PetRecord

{

private String name;

private int age;//in years

private double weight;//in pounds

 

public String toString( )

{

return ("Name: " + name + " Age: " + age + " years"

+ "\nWeight: " + weight + " pounds");

}

 

public PetRecord(String initialName, int initialAge,

double initialWeight)

{

name = initialName;

if ((initialAge < 0) || (initialWeight < 0))

{

System.out.println("Error: Negative age or weight.");

System.exit(0);

}

else

{

age = initialAge;

weight = initialWeight;

}

}

 

public void set(String newName, int newAge, double newWeight)

{

name = newName;

if ((newAge < 0) || (newWeight < 0))

{

System.out.println("Error: Negative age or weight.");

System.exit(0);

}

else

{

age = newAge;

weight = newWeight;

}

}

 

public PetRecord(String initialName)

{

name = initialName;

age = 0;

weight = 0;

}

 

public void setName(String newName)

{

name = newName;

}

 

public PetRecord(int initialAge)

{

name = "No name yet.";

weight = 0;

if (initialAge < 0)

{

System.out.println("Error: Negative age.");

System.exit(0);

}

else

age = initialAge;

}

 

public void setAge(int newAge)

{

if (newAge < 0)

{

System.out.println("Error: Negative age.");

System.exit(0);

}

else

age = newAge;

}

 

public PetRecord(double initialWeight)

{

name = "No name yet";

age = 0;

if (initialWeight < 0)

{

System.out.println("Error: Negative weight.");

System.exit(0);

}

else

weight = initialWeight;

}

 

public void setWeight(double newWeight)

{

if (newWeight < 0)

{

System.out.println("Error: Negative weight.");

System.exit(0);

}

else

weight = newWeight;

}

 

public PetRecord( )

{

name = "No name yet.";

age = 0;

weight = 0;

}

 

public String getName( )

{

return name;

}

 

public int getAge( )

{

return age;

}

 

public double getWeight( )

{

return weight;

}

}

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9885550

Have any Question?


Related Questions in Computer Engineering

If we take infinite samples of size n 49 from a population

If we take infinite samples of size n = 49 from a population with a distribution with high kurtosis and standard deviation 7, select the best answer below. * The sampling distribution of the sample means will have a stan ...

Referring to the in class rectangleclass examplelt

Referring to the in class RectangleClass example: class RectangleMain{ > static void main(String[] args)> use to test You will Create a Class named and RtTriangleMain { > args)> to test your The will: 1)Establish Two pub ...

Select a company with which you are at least somewhat

Select a company with which you are at least somewhat familiar. Explain how this particular company could benefit from a data warehousing and data mining initiative. What value do you see in data mining in the context of ...

Explain the difference between penetration tests and

Explain the difference between penetration tests and security tests. Emphasize that this book will explain things from a security testing perspective.

Question assignment instructions - 1000 words and at least

Question: Assignment Instructions: - 1000+ words and at least three references other than text - no polemics or personal attacks and avoid the rote repetition of platitudes or dogma - State your hypothesis and then attem ...

One of the assays your laboratory carries out requires a 2n

One of the assays your laboratory carries out requires a 2N HCl. You have a stock bottle of concentrated HCl with a specific gravity of 1.18 and purity of 36%. What volume of the concentrated HCl is required to make 250m ...

Wat are three 3 major categories of cyber terrorism and

What are three (3) major categories of cyber terrorism and / or information warfare. Among the chosen categories, determine the one (1) that should be the top priority for the federal government to address.

Question recall the on the spot courier service introduced

Question : Recall the On the Spot courier service introduced in Unit 1. The details of the package pickup and delivery process are described here. When Bill got an order, at first, only on his phone, he recorded when he ...

A sample of 40 songs from a students itunes playlist showed

A sample of 40 songs from a student's iTunes playlist showed a mean length of 3.542 minutes with a standard deviation of 0.311 minute. Construct a 95% confidence interval for the population standard deviation.  (Round yo ...

You are on a system in which the finger program has been

You are on a system in which the finger program has been disabled and you want a quicky finger type program and you decide that greping/etc/passwd would be sufficient. However the system that you are on uses nis+ and so ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As