Im using visual c++ 6.0
for example if i put the credit limit at 500 and the amount spent at 200 i get asdfasdf123123!@+800 for an answerCode:#include <iostream.h> #include <conio.h> #include <string.h> class customer { private: char cardname[20]; float creditlimit; float amountspent; float amountleft; calculate(); public: void input(); void output(); }; void customer::input() { cout<<"Please enter the card name: "; cin>>cardname; cout<<"Please enter the credit limit: "; cin>>creditlimit; cout<<"Please enter the amount spent: "; cin>>amountspent; } customer::calculate() { amountleft = creditlimit - amountspent; } void customer::output() { cout<<"Thank you "<<cardname<<" you have "<<amountleft<<" left."; } void main() { customer c1; c1.input(); c1.output(); getch(); }
any ideas?




Reply With Quote