Can someone look at this code and tell me why I can not
read in the input characters.
//Invoice.hpp file
#include <iostream>
#include <string.h>
using namespace std;
class Invoice
{
public:
Invoice(char
[40],int& ,double& ,double& ); //constructor
~Invoice(); //destructor
//public accessors
int GetQuantity()const;
void SetQuantity(int&);
int GetItemName()const;
void SetItemName(char[40] );
int GetItemPrice()const;
void SetItemPrice(double& );
int GetTotal()const;
void SetTotal(double&);
private:
int *itsQuantity;
char itsItemName[40];
double *itsItemPrice;
double *itsTotal;
};
//Invoice.cpp file
#include "Invoice.hpp"
Invoice::Invoice(char cItem[40],int &iQuantity,double
&dItemPrice,double &dTotal)
{
itsQuantity = &iQuantity;
itsItemName[40] = cItem[40];
itsItemPrice = &dItemPrice;
itsTotal = &dTotal;
return;
}
Invoice::~Invoice()
{
return;
}
int Invoice::GetQuantity()const
{
return *itsQuantity;
}
void Invoice::SetQuantity(int &inPutQuantity)
{
itsQuantity = &inPutQuantity;
return;
}
int Invoice:: GetItemName()const
{
return itsItemName[40];
}
void Invoice::SetItemName(char cInPutItem[40] )
{
itsItemName[40] = cInPutItem[40];
return;
}
int Invoice::GetItemPrice()const
{
return *itsItemPrice;
}
void Invoice::SetItemPrice(double &dInputPrice)
{
itsItemPrice = &dInputPrice;
return;
}
int Invoice::GetTotal()const
{
return *itsTotal;
}
void Invoice::SetTotal(double &dInputTotal)
{
itsTotal = &dInputTotal;
return;
}
int main()
{
//input variables
int iNewQuantity;
char cNewItemName[40];
double dItemPrice;
double dNewTotal;
//invoice object
Invoice SalesInvoice
(cNewItemName,iNewQuantity,dItemPrice,dNewTotal);
// The user enters the Item Name he or she is
buying
cout <<"\nEnter your Item Name " ;
cin.getline(cNewItemName,40);
SalesInvoice.SetItemName(cNewItemName);
// The user enters the Item Quantity he or she is
buying
cout <<"Enter the quantity of items : " ;
cin >> iNewQuantity;
SalesInvoice.SetQuantity(iNewQuantity);
// The user enters the Item price he or she is
buying
cout <<"Enter Item Price: ";
cin >> dItemPrice ;
SalesInvoice.SetItemPrice(dItemPrice);
// The user enters the item total he or she is
buying
cout <<"Enter your total: ";
cin >> dNewTotal;
SalesInvoice.SetTotal(dNewTotal);
// before printing to the screen clear it
// system("cls");
//preview of the item name before it is set
cout <<"\nItem Name is "<< cNewItemName <<endl;
//output to the screen
cout << "\nItem Name: " <<
SalesInvoice.GetItemName() <<endl;
cout << "Item Quantity: "<<
SalesInvoice.GetQuantity() <<endl;
cout << "Item Price: $" <<
SalesInvoice.GetItemPrice() <<endl;
cout << "Total Item Price: $" <<
SalesInvoice.GetTotal() << endl;
return 0;
} 1 1027
Joe, this is a VB.Net newsgroup, you're not going to get any problems with
this code resolved here.
Regards
Hexathioorthooxalate
"Joe" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl... Can someone look at this code and tell me why I can not read in the input characters.
//Invoice.hpp file
#include <iostream> #include <string.h> using namespace std;
class Invoice { public: Invoice(char [40],int& ,double& ,double& ); //constructor ~Invoice(); //destructor
//public accessors int GetQuantity()const; void SetQuantity(int&); int GetItemName()const; void SetItemName(char[40] ); int GetItemPrice()const; void SetItemPrice(double& ); int GetTotal()const; void SetTotal(double&); private: int *itsQuantity; char itsItemName[40]; double *itsItemPrice; double *itsTotal;
};
//Invoice.cpp file #include "Invoice.hpp"
Invoice::Invoice(char cItem[40],int &iQuantity,double &dItemPrice,double &dTotal) {
itsQuantity = &iQuantity; itsItemName[40] = cItem[40]; itsItemPrice = &dItemPrice; itsTotal = &dTotal;
return; } Invoice::~Invoice() {
return; } int Invoice::GetQuantity()const { return *itsQuantity; } void Invoice::SetQuantity(int &inPutQuantity) { itsQuantity = &inPutQuantity;
return; } int Invoice:: GetItemName()const { return itsItemName[40];
}
void Invoice::SetItemName(char cInPutItem[40] ) { itsItemName[40] = cInPutItem[40];
return; }
int Invoice::GetItemPrice()const { return *itsItemPrice; }
void Invoice::SetItemPrice(double &dInputPrice) { itsItemPrice = &dInputPrice;
return; }
int Invoice::GetTotal()const { return *itsTotal;
}
void Invoice::SetTotal(double &dInputTotal) { itsTotal = &dInputTotal;
return; }
int main() { //input variables int iNewQuantity; char cNewItemName[40]; double dItemPrice; double dNewTotal; //invoice object Invoice SalesInvoice (cNewItemName,iNewQuantity,dItemPrice,dNewTotal);
// The user enters the Item Name he or she is buying cout <<"\nEnter your Item Name " ; cin.getline(cNewItemName,40); SalesInvoice.SetItemName(cNewItemName);
// The user enters the Item Quantity he or she is buying cout <<"Enter the quantity of items : " ; cin >> iNewQuantity; SalesInvoice.SetQuantity(iNewQuantity);
// The user enters the Item price he or she is buying cout <<"Enter Item Price: "; cin >> dItemPrice ; SalesInvoice.SetItemPrice(dItemPrice);
// The user enters the item total he or she is buying cout <<"Enter your total: "; cin >> dNewTotal; SalesInvoice.SetTotal(dNewTotal);
// before printing to the screen clear it // system("cls");
//preview of the item name before it is set cout <<"\nItem Name is "<< cNewItemName <<endl;
//output to the screen cout << "\nItem Name: " << SalesInvoice.GetItemName() <<endl; cout << "Item Quantity: "<< SalesInvoice.GetQuantity() <<endl; cout << "Item Price: $" << SalesInvoice.GetItemPrice() <<endl; cout << "Total Item Price: $" << SalesInvoice.GetTotal() << endl;
return 0; }
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matt Chaplain |
last post by:
Hi there.
I'm writing a program that uses the Telnet protocol over TCP/IP
sockets. Of course, that has no bearing here, so I'll rephrase that
in Standard C++ :)
In essense, I'm trying to...
|
by: Gus Tabares |
last post by:
Hello,
I'm having trouble reading in a character. Here is a snippet of code:
int num;
char character;
printf("Enter a number: ");
scanf("%d", &num);
printf("You entered %d.\n", num);
|
by: Thomas Sourmail |
last post by:
Hi,
I hope I am missing something simple, but.. here is my problem:
I need my program to check the last column of a file, as in :
a b c d target ref
0 0 0 0 1 a
1 0 0 0 1.5 b
2 0 0 0 2 c
|
by: Kay |
last post by:
1) If i want to read data from a txt file,
eg John; 23; a
Mary; 16; i
How can I read the above data stopping reading b4 each semi-colon and
save it in three different variables ?
2) If I...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen....
|
by: Engineerik |
last post by:
using vb.net 2003, I am reading an ascii text file which is shared with a
legacy DOS program. The characters "«" (ascii code 171) and "¬" (ascii code
172) are used in the file. The DOS app...
|
by: Chris Yan |
last post by:
Hi All
I have an excel sheet with Chinese characters in them.
I'm using the OLEBE 4.0 Jet Driver in C# Microsoft Visual Studio 2005
to read from the Excel sheet and then enter into mySQL...
|
by: aljaber |
last post by:
hi,
i am facing a problem with my program output
here is the program
/*********************************************\
* CD Database *
* ...
|
by: efrenba |
last post by:
Hi,
I came from delphi world and now I'm doing my first steps in C++. I'm
using C++builder because its ide is like delphi although I'm trying to
avoid the vcl.
I need to insert new features...
|
by: utab |
last post by:
Dear all,
I have to interface some C code in C++, but I had a problem with sscanf
function, it has been some time I have not used C and I could not figure
out my problem. Simple code is below, I...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |