If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Help With Code

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-14-04, 18:16
cmille11 cmille11 is offline
Registered User
 
Join Date: Nov 2004
Posts: 2
Help With Code

#include "stdafx.h"
using namespace std;

// declaration section:
class GroceryItem
{
private:
int stkNum;
double price;
int quantity;
double totalValue;
public:
void displayGroceryItem();
void setStkNum(int Num);
void setPrice();
void setQuantity();
void setTotalValue();
};
//implementation section:
void GroceryItem::setStkNum(int Num)
{
cout<<"Enter the stock number 7777. ";
cin>>Num;
if(Num == 7777)
stkNum = Num;
else
cout<<"Please reenter a valid stock number of 7777. ";
}
void GroceryItem::setQuantity()
{
quantity = 2;
}
void GroceryItem::setPrice()
{
price = 1.00;
}
void GroceryItem::setTotalValue()
{
totalValue = price * quantity;
}
void GroceryItem::displayGroceryItem()
{
cout<<"Grocery Item number #"<<stkNum<<", with a price of $"<<price<<" and a quantity of "<<quantity<<endl;
cout<<"Has a total value of $"<<totalValue<<endl;
}

void main()
{
GroceryItem aGroceryItem;
aGroceryItem.setStkNum(7777);
aGroceryItem.setPrice();
aGroceryItem.setQuantity();
aGroceryItem.setTotalValue();
aGroceryItem.displayGroceryItem();
getch();
}
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On