Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a class named Billionaire which will be used to represent an entry on Forbes list of the richest individuals in technology. The class should

Define a class named Billionaire which will be used to represent an entry on Forbes list of the richest individuals in technology. The class should define attributes for the first name and last name, net worth (in billions), how they made their wealth (company name, product name or type), country of citizenship and the persons current ranking on the list. The following methods are needed. Please review the included Lab2Client.cpp file for specific method names.

  • A default class constructor. No actions are needed for this constructor.
  • A class constructor that accepts a single string parameter containing the class attribute values separated by a comma. The constructor must parse the parameter string into individual data items in order to set the class attributes.
  • Accessor methods for the class attributes.
  • Mutator methods for the rank and net worth class attributes. All other attributes are immutable.
  • A utility method to display the class attribute values using cout in a readable format.

A client with a completed main function is provided. The main function should not be modified. You must update the client by creating and implementing the various functions described below.

  • readFile Loads the parameter array with Billionaire objects. The data for each Billionaire is read from the given data file which is in CSV format (comma delimited - 1 line per record with fields separated by a comma.) The function should read each line from the file, pass the line read to the Billionaire class constructor and store the resulting object in the parameter array. The second parameter represents the maximum number of Billionaire objects that can be stored.
  • displayAll - Displays a list of the Billionaires stored in the array.
  • getRange Determines the smallest wealth value and the largest wealth value within the array. These values are returned to the caller via reference parameters.
  • getWealthiest Returns the Billionaire within the array with the greatest wealth.
  • getUS Returns a count of the number of individuals in the array with United States citizenship.

Hints: Start small and build on working code. Implement ONE function at a time, leaving the remaining code in the main commented out. Thoroughly test the function. Once you are satisfied with the result, move on to the next function.

In the overloaded constructor of the Billionaire class, consider using a stringstream object. The third parameter of the getline function provides an option to specify a delimiter, allowing the getline function to extract one field at a time from the stringstream object.

getline(iss,resultString,','); // iss is a istringstream object

Only strings are read from a string stream. For integer and floating point values, the data must be converted after reading.

Alternatively, the parameter string can be parsed using various methods of the string class. String class methods that you may find useful in parsing the data include find, erase, and substr.

Dont forget to include needed libraries! You may specify the std namespace either in the using clause or using scope resolution.

Full Javadoc documentation comments are required for all public members in the Billionaire.h file. A makefile is also provided.

Example run:image text in transcribed

The Top 30 Wealthiest Technology People: 13 Paul Allen $20.5B Microsoft investments United States 9 Steve Ballmer $32.9B Microsoft United States 2 Jeff Bezos $81.7B Amazon.com United States 6 Sergey Brin $42.7B Google United States 10 Michael Dell $22.4B Dell computers United States 16 William Ding $16.1B online games China 4 Larry Ellison $59.3B software United States 1 Bill Gates $84.5B Microsoft United States 30 James Goodnight $ 8.9B software United States 23 Terry Gou $10.2B electronics Taiwan 24 Dietmar Hopp $10.2B software Germany 8 Ma Huateng $36.7B internet media China 28 Jan Koum $ 9.6B WhatsApp United States 14 Lee Kun-Hee $18.3B Samsung South Korea 17 Robin Li $15.8B internet search China 7 Jack Ma $37.4B e-commerce China 19 Dustin Moskovitz $13.3B Facebook United States Elon Musk $20.7B Tesla Motors United States 18 Shiv Nadar $13.5B software services India 29 Pierre Omidyar $ 9.3B eBay United States 5 Larry Page $43.9B Google United States Hasso Plattner $12.6B software Germany 15 Azim Premji $18.2B software services India 25 Liu Qiangdong $10.1B e-commerce China 26 Zhou Qunfei $10.0B smartphone screens Hong Kong 27 Eduardo Saverin $ 9.7B Facebook Brazil 22 Eric Schmidt $12.4B Google United States ll Masayoshi Son $22.4B internet and telecom Japan 21 Zhang Zhidong $12.5B internet media China 3 Mark Zuckerberg $69.6B Facebook United States 12 20 The wealth of the billionaires range from $8.98 to $84.5B The wealthiest technology person is 1 Bill Gates $84.5B Microsoft There are 15 US billionaires in the top 30! United States

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions

Question

Question Who can establish a Keogh retirement plan?

Answered: 1 week ago