The objective of this problem is to introduce a simple Object-Oriented Programming (OOP) problem and ensure that students understand the concept of OOP. In this case, it’s tested with the understanding of object.
Given a group of people with different heights and weights, determine the shortest and tallest people in the group, and calculate their body mass index(BMI).
The formula for BMI is
BMI = weight(in kg)/height(in meters)^2
The first line of the input contains an integer N (2 <= N <= 100) denoting the number of people in the group. The next N lines contain the information (name, height in centimeters, and weight in kilograms) of the people in the group.
Output the name of the shortest and tallest people in the group, assuming that there is only one shortest person and one tallest person in the group.
Suppose A is the shortest and B is the tallest person in the group, the output will be:
A is the shortest with BMI equals to C.
B is the tallest with BMI equals to D.
Output the BMI value correct to 2 decimal places.
Please refer to sample output for more details.
Diamond 178 55
Jarod 160 80
Douglas 180 60
Rod 151 48
Rod is the shortest with BMI equals to 21.05.
Douglas is the tallest with BMI equals to 18.52.
--------------------------------------------------- i can easily solve this using structures but have difficulty doing it using classes and objects. my attempt at a solution is below. im trying to create new student objects based on the number entered by the user using an array of pointers named "list". i tried creating an array of student objects "list2" and to initialise them i coded list2[i](name,height, weight); inside the for loop and both these methods didnt work out. appreciate all the help for this problem.
On Line 43 you're trying to use a constructor with no arguments without declaring or defining it. Then you try to save the result of that to 'list' but you don't tell the compiler where in 'list' you want it to be saved. Line 47 shows a lot of confusion so I'll make this quick suggestion: Comment out\delete Line 43, then replace Line 47 with this:
list[i] = new student(name, height, weight);
There's your free-bee for the day.
What are you trying to do at Lines 48 and 52?
By the way, it's a bit annoying to have to filter out the numbers from your post so try to avoid that in the future.