473,467 Members | 1,931 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem Reading Characters

Joe
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;
}
Nov 20 '05 #1
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;
}

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
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...
6
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);
7
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
7
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...
0
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....
2
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...
1
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...
11
by: aljaber | last post by:
hi, i am facing a problem with my program output here is the program /*********************************************\ * CD Database * * ...
6
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...
4
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
1
isladogs
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...
0
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.