Display the average height and name of the tallest person

Assignment Help C/C++ Programming
Reference no: EM13939940

A person has a name and a height in centimeters. Implement a dataset to process a collection of Person objects. Display the average height and the name of the tallest person.

Use the following class in your solution:
/**
This class represents a person's name and height
*/
public class Person
{
private String name;
private double height;

/**
Constructs a Person object
@param aName the name of the person
@param aHeight the height of the person
*/
public Person(String aName, double aHeight)
{
name = aName;
height = aHeight;
}

/**
Gets the name of the person
@return name the person's name
*/
public String getName()
{
return name;
}

/**
Gets the height of the person
@return height the person's height
*/
public double getHeight()
{
return height;
}
}

Use the following class as your tester class:
/**
This program tests the measuring of Person objects.
*/
public class PersonTester
{
public static void main(String[] args)
{
. . .

DataSet data = . . .

data.add(new Person("Joe", 183));
data.add(new Person("Chrissy", 158));
data.add(new Person("Bobby", 175));

double avg = . . .
Person max = . . .

System.out.println("Average height: " + avg);
System.out.println("Expected: 172");
System.out.println("Name of tallest person: " + max.getName());
System.out.println("Expected: Joe");
}
}

DO NOT MODIFY THE FOLLOWING:

/**
Computes the average of a set of data values.
*/
public class DataSet
{
private double sum;
private Object maximum;
private int count;
private Measurer measurer;

/**
Constructs an empty data set with a given measurer.
@param aMeasurer the measurer that is used to measure data values
*/
public DataSet(Measurer aMeasurer)
{
sum = 0;
count = 0;
maximum = null;
measurer = aMeasurer;
}

/**
Adds a data value to the data set.
@param x a data value
*/
public void add(Object x)
{
sum = sum + measurer.measure(x);
if (count == 0
|| measurer.measure(maximum) < measurer.measure(x))
maximum = x;
count++;
}

/**
Gets the average of the added data.
@return the average or 0 if no data has been added
*/
public double getAverage()
{
if (count == 0) return 0;
else return sum / count;
}

/**
Gets the largest of the added data.
@return the maximum or 0 if no data has been added
*/
public Object getMaximum()
{
return maximum;
}
}

DO NOT MODIFY THE FOLLOWING
/**
Describes any class whose objects can measure other objects.
*/
public interface Measurer
{
/**
Computes the measure of an object.
@param anObject the object to be measured
@return the measure
*/
double measure(Object anObject);
}

DO NOT MODIFY THE FOLLOWING
/**
This class represents a person's name and height
*/
public class Person
{
private String name;
private double height;

/**
Constructs a Person object
@param aName the name of the person
@param aHeight the height of the person
*/
public Person(String aName, double aHeight)
{
name = aName;
height = aHeight;
}

/**
Gets the name of the person
@return name the person's name
*/
public String getName()
{
return name;
}

/**
Gets the height of the person
@return height the person's height
*/
public double getHeight()
{
return height;
}

Reference no: EM13939940

Questions Cloud

Compute cost of goods transferred out and the cost of ewip : Prepare a physical flow schedule. Prepare a schedule of equivalent units. Compute the cost per equivalent unit. Compute the cost of goods transferred out and the cost of EWIP.
Facilitate the successful implementation of diversity policy : How can managers facilitate the successful implementation of diversity policy?
Calculate the channel capacity : Calculate the channel capacity and what is the minimum transmission time to required transfer all characters over the channel without error?
What was the attention to details : Ideas and links for obtaining a recent (less than 6 months old) article from the popular press (newspaper or magazine) and a peer reviewed journal article on the same or similar topic are included. Advice on how to clearly summarize each article i..
Display the average height and name of the tallest person : A person has a name and a height in centimeters. Implement a dataset to process a collection of Person objects. Display the average height and the name of the tallest person.
Issue of preferred stock : Holdup Bank has an issue of preferred stock with a $4.95 stated dividend that just sold for $86 per share. What is the bank’s cost of preferred stock?
General funds are blocked by the argentine government : General Eletric's funds are blocked by the Argentine government. GE still wants to continue its operations in the country. Under the circumstance, GE should
Draw the shear force diagram : a) Draw the shear force diagram and indicate the position of maximum bending moment.
Essay - ethical implications of a social psychology study : In this assignment, you will write an essay about the research methods and ethical implications of a social psychology study. You will get information about the study from one of the entries in the SPARQ "Solutions Catalog"

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Lab-1the goal of this lab is to better familiarize you with

lab-1the goal of this lab is to better familiarize you with polymorphism and the factory design pattern two key

  Develop software to perform advanced geometric calculation.

You have been hired by an engineering company to develop software to perform advanced geometric calculation. Your new boss asked you to develop an application that allows engineers to calculate the surface area and the volume of a sphere.

  Produce a top-level design for your program

You are required to code the program using the C++ Programming Language. Your program should be properly laid out and should be modular, making sure that software engineering aspects of modularity and reusability as fully considered.

  Program that would display a letter to a friend

Writing a c++ program that would display a letter to a friend? It should have a proper format like name, friends name, address.....etc

  Create a new animal that flys with a jetpack

Create a new animal that flys with a jetpack. This will require a new fly behavior and a new class. This new animal eats kale.

  The manager of a football stadium

The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets-box, sideline, premium and general admission. The data is stored in a file, tickets.txt, in the fol..

  Dynamic array of a string that takes in names

Can you please show me an example of a C++ Class that has a dynamic array of a string that takes in names by user input??

  Implements the postfix evaluation algorithm

Write a program that implements the postfix evaluation algorithm that is on your course module.your program should enable users to enter the postfix expression and output the result of evaluation to screen.

  Prepare a program in c++ using the class as defined

Prepare a program in C++ using the class as defined below - Then write the main program in another file that will read in some numbers and test out whether your functions all work.

  Programming with control structures

Develop a Python program which will calculate the sum of an integer series, as described below. The program wil repeatedly prompt he user to enter a command (a character string).

  Show how this priority queue is affected by adding string

To tell if one element in ZooGraph has relation X to another element, you look for a path between them. Show whether the following statements are true, using the picture or adjacency matrix.

  Write a program that allows a user to enter 12 double values

Write a program that allows a user to enter 12 double values representing store sales for each month of one year. After all 12 values are entered,

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