Write a driver program with a main method to read in data

Assignment Help Basic Computer Science
Reference no: EM13306229

"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;

}

}

 

Reference no: EM13306229

Questions Cloud

Calculate the minimum required wall thickness t-min : A tubular aluminium bar (G=28GPa) of square cross section with outer dimensions 50mm x 50mm must resist a torque T=300Nm. Calculate the minimum required wall thickness t_min if allowbale shear stress is 20MPa
Discuss and share rich and diverse assortment of reference : Discuss and share the rich and diverse assortment of reference sources for the Bourne Again Shell (BASH).
A modern business organisation : 1. Analyse one or more strategic problems in a modern business organisation and produce a comprehensive report detailing the objectives, methodologies, findings, analysis, and conclusions of the research carried out above. The minimum word length for..
Describe the distribution of grades : Nursing program gives a qualifying exam to students applying for admission. The grades on the exam have a mean score of 80 with a standard deviation of 6. Describe the distribution of grades.
Write a driver program with a main method to read in data : "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.
Find the stream function and velocity potential funtion : A two-dimensional incompressible flow field is defined by the velocity components u=2V(x/L-y/L) and v=-2V(y/L). where V and L are constants. If they exist, Find the stream function and velocity potential funtion
Find what volume of sulfuric acid would need to be added : two 500 ml samples were completely mixed together the first sample contained 0.002 M Na2CO3 while the second contained 0.004 N NaOH. what volume of 0.02 N sulfuric acid would need to be added to neutralize the solution
Determine the final temperature of the iron block : A 3.8-kg block of iron (c=0.11 kcal/kgoC) that has been brought to a temperature of 1,078oC is placed on top of a 2.4-kg block of ice (c=0.5 kcal/kgoC) that has been cooled to -50oC
What are the possible limitations for use : What benefits do cookies provide to an application lifecycle? What are the possible limitations for use?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Representing information by predicate-calculus sentences

Represent this information by predicate-calculus sentences in such a way that you can represent the question Is there a member of the alpine club

  Significant invention which shaped society today

Pondering history of technology development, decide what you think was the most significant invention previous to the 1600s which has shaped society today. Explain your decision.

  What frequency of radio waves corresponds to wavelength

Radio amateurs are allowed to communicate on "10 meter band." What frequency of radio waves corresponds to wavelength of 20m?

  What size of packet will result in the last bit

Given a transmission speed of T bits/second, a packet size of B bytes, a propagation speed of P m/s and a cable length of L meters, what size of packet will result in the last bit being transmitted just as the first bit of the packet arrives at th..

  Under a mle-estimated unigram probability model

Qatar university, the largest university in qatar, aims to become the role model university in qatar and the arab region. it is also the only university in qatar that offers information retrieval courses.

  Tradeoffs involved to improve overall system performance

What are your thoughts on the tradeoffs involved when attempting to improve overall system performance. Provide examples where an increase in the performance of one resource.

  Explain hardware to gather the essential information

Write down a 2-3 page paper explaining the hardware and software utilized to support personal, workgroup, and enterprise computing in the present organization.

  Question about compiler theory

Determine some common compilers available? Based on regular expressions, can all input be validated if it is correct, or not, based on compilation?

  network structure-Management Information system

Which of the following is true of a network structure? The Management Information system (MIS) structure with one main computer system is called a

  Explain animation schemes comprise slide transitions

Some animation schemes comprise slide transitions and some don't. When would the transition be suitable? When would it not be suitable?

  Explain the four stages of the bpm process and summarize

Explain the four stages of the BPM process and summarize the activities in each.

  Creating presentation to law school class on digital crime

You have been asked to present a presentation to law school class on digital crime. After presentation, a student asks why so few people are really prosecuted for computer crime.

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