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

  Explain applications of pervasive computing

Which of the applications of pervasive computing do you believe are probable to gain greatest market acceptance over next few years? Why?

  Create the data flow diagrams needed

The Chocolate Delights Candy Company needs to add the following functionality to its cash register: When a customer is checking out, the cash register needs to store the required data pertaining to each item the customer is buying.

  How to convert power to hex

How to Convert 11001010 to the 2nd power to hex

  Disaster recovery planning models

In one page, please Compare and Contrast various Business Continuity & Disaster Recovery Planning models.

  Develop a model that can be described

Develop a model that can be described in yes/no (boolean) terms. Use boolean algebra, truth tables, or logic gates to describe this model. Attach a diagram or drawing to explain your concept.

  Compare and contrast the in terms of cores/microprocessors

Compare and contrast the following, in terms of cores (or microprocessors), random access memory (RAM), disk storage, and networking capabilities.

  Write a program that computes the cost of a long-distance

Write a program that computes the cost of a long-distance call. The cost of the call is determined according to the following rate schedule: a. Any call started between 7:00 A.M. and 9:00 P.M.

  Write a conditional that assigns the boolean value true

Write a conditional that assigns the boolean value true to the variable fever if the variable temperature is greater than 98.6 .So if temperature has the value 99.5,

  Calculations without an arithmetic and logic unit (alu)

Determine whether or not it is not possible for microprocessors to perform calculations without an Arithmetic and Logic Unit (ALU)

  Calculate and display the number of gallons of water

The application should calculate and display the number of gallons of water used and the total charge for the water. The charge is 2.05 per 1000 gallons, or 00205 per gallon. use two independent sub procedures : one to make the calculations and th..

  Problem of determining whether a dfa

Consider the problem of determining whether a DFA and a regular expression are equivalent. Express this problem as a language and show that it is decidable.

  Distinguish web pages or web servers use for task

Suppose the role of the IT consultant to new nonprofit organization, Free Flu, to provides flu shots to the elderly. The organization requires the domain name. Distinguish between any Web pages or Web servers you would use for task.

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