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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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