Can someone please help me with this? I have been struggling with this for days now, and for some reason, my instructor's help is not working for me. I am not sure if it is because he is from Germany and I am taking courses on-line, or if it is because I am totally confused - or a combination of both. I am supposed to end up being able to do the following: Ask the user how many prices he/she wants to enter, then read each price one by one, then compute the sum of all prices times 3 and their average, and then print two amounts. This is my first program using classes. I apologize if this is located somewhere on the forums; I didn't see it and I really did look. This is also my very first post, so I apologize if I didn't do it exactly right.
#include <iostream>
using namespace std;
class TMoney {
public:
TMoney() {int dollars=0; int cents=0; int amount=0;};
int int_get_dollars() {return amount/100;};
int int_get_cents() {return amount % 100;};
void set(int dollars, int cents);
void Print();
void Read();
bool greater(TMoney b) {return (b.amount>amount);};
bool equals (TMoney b) {return (b.amount==amount);};
void add(TMoney b) {amount += b.amount;};
void times (int i){amount*=i;};
void divide_by (int i){amount/=i;};
private:
int dollars;
int cents;
int amount;
};
void TMoney::set(int dollars, int cents){
if (dollars<0)
amount=-1*(dollars*100 + cents);
else
amount=dollars*100+cents;
}
void TMoney::Print(){
if (dollars<=0) {
cout<<"-$"<<dollars<<"."<<cents<<endl;
}
else if (dollars>0){
cout<<"$"<<dollars<<"."<<cents<<endl;
}
}
void TMoney::Read(){
char sign, dec;
int dollars, cents;
cin>>sign>>dollars>>dec>>cents;
set(dollars, cents);
}
void main(void){
TMoney t;
int i, N;
cout<<"How many prices would you like to enter?";
cin>>N;
cout<<"Enter your prices:";
for (i=0;i<N;i++){
t.Read();
}
}