1. Engineering
2. Computer Science
3. questions 3 what is the purpose of the setdata method...

# Question: questions 3 what is the purpose of the setdata method...

###### Question details

QUESTIONS:

3. What is the purpose of the setData method? -

4. What is the purpose of the getIncreasedPrice method?

5. What is the purpose of the code on Lines 36 and 37?

6. What statement is missing from Line 69?

7. Line 74 should display the increased price. What code is missing from that line?

8. Enter the missing statement and code from Steps 6 and 7. Save and then run the program. Enter ABX-12 as the computer ID, 2500 as the price, and 0.1 as the increase rate. The program displays the message “The new price of computer ABX-12 is $2750.00.” Now, enter PYZ-43 as the computer ID, 1900 as the price, and 10 as the increase rate. The program displays the message “The new price of computer PYZ-43 is$2090.00.”

9. Test the program using different computer IDs, prices, and rates. When you are finished testing the program, enter the letter x as the computer ID.

//Lab4 displays an increased price

#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

//declaration section
class Item
{
public:
Item();
void setData(string, double);
double getIncreasedPrice(double);
private:
string id;
double price;
};

//implementation section
Item::Item()
{
id = "";
price = 0.0;
}   //end of default constructor

void Item::setData(string idNum, double p)
{
id = idNum;
price = p;
} //end of setData method

double Item::getIncreasedPrice(double rate)
{
if (rate > 1.0)
rate /= 100;
//end if
return price + price * rate;
} //end of getIncreasedPrice method

int main()
{
//instantiate an Item object
Item computer;

//declare variables
string computerId = "";
double computerPrice = 0.0;
double incRate = 0.0;

cout << fixed << setprecision(2);

//get computer ID
cout << "Computer ID (X to end): ";
getline(cin, computerId);
while (computerId != "X" && computerId != "x")
{
//get price and increase rate
cout << "Enter the price: ";
cin >> computerPrice;
cin.ignore(100, '\n');
cout << "Increase rate in decimal form : ";
cin >> incRate;
cin.ignore(100, '\n');

//assign the ID and price

//display the increased price
cout << "The new price of computer "
<< computerId << " is \$"

<< endl;

//get computer ID
cout << endl << "Computer ID (X to end): ";
getline(cin, computerId);
}   //end while
return 0;
}   //end of main function