#include<iostream>
#include<fstream>
#include<string>
using namespace std;
class Dealer
{protected:
string Name;
public:
Dealer( )
{
Name = "Unknown";
}
string get_name()
{
return Name;
}
void set_data(string name)
{
name = Name;
}
};
class PlayStation
{
int No;
protected:
float price;
public:
PlayStation(){}
PlayStation( string a)
{
cout << "No: ";
cin >> No;
cout << "price: ";
cin >> price;
}
float get_price()
{
return price;
}
void set_price(float p)
{
price = p;
}
};
class Invoice :public Dealer
{
float Total;
public:
PlayStation PlayStations[5] ;
Invoice()
{
for (int i = 0; i < 5; i++)
{
Total += PlayStations[i].get_price();
}
if (Total < 0)
{
Total = 0;
}
}
void ReadPrices()
{
float p;
for (int i = 0; i < 5; i++)
{
cout << "Price: ";
cin >> p;
PlayStations[i].set_price(p);
}
}
float GetTotal()
{
for (int i = 0; i <5; i++)
{
Total += PlayStations[i].get_price();
}
return Total;
}
float GetMax()
{
float max=PlayStations[0].get_price();
for(int i=0;i<2;i++){
if (max<PlayStations[i].get_price())
max<PlayStations[i].get_price();}
return max;
}
void print(){
cout<<"Name:"<<Name<<endl;
}
void print(string name_file)
{
ofstream read;
read.open("Date.txt");
read << "Name: " << get_name()<<endl;
read << "Total: " << Total << endl<<endl;
read.close();
}
};
int main()
{
Invoice n[2] ;
for (int i = 0; i < 2; i++)
{
n[i].ReadPrices();
cout<<"Total :"<<n[i].GetTotal()<<endl;
cout<<"Maximam :"<<n[i].GetMax()<<endl;
n[i].print();
n[i].print("Date.txt");
}
return 0;
}
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
class Dealer
{protected:
string Name;
public:
Dealer( )
{
Name = "Unknown";
}
string get_name()
{
return Name;
}
void set_data(string name)
{
name = Name;
}
};
class PlayStation
{
int No;
protected:
float price;
public:
PlayStation(){}
PlayStation( string a)
{
cout << "No: ";
cin >> No;
cout << "price: ";
cin >> price;
}
float get_price()
{
return price;
}
void set_price(float p)
{
price = p;
}
};
class Invoice :public Dealer
{
float Total;
public:
PlayStation PlayStations[5] ;
Invoice()
{
for (int i = 0; i < 5; i++)
{
Total += PlayStations[i].get_price();
}
if (Total < 0)
{
Total = 0;
}
}
void ReadPrices()
{
float p;
for (int i = 0; i < 5; i++)
{
cout << "Price: ";
cin >> p;
PlayStations[i].set_price(p);
}
}
float GetTotal()
{
for (int i = 0; i <5; i++)
{
Total += PlayStations[i].get_price();
}
return Total;
}
float GetMax()
{
float max=PlayStations[0].get_price();
for(int i=0;i<2;i++){
if (max<PlayStations[i].get_price())
max<PlayStations[i].get_price();}
return max;
}
void print(){
cout<<"Name:"<<Name<<endl;
}
void print(string name_file)
{
ofstream read;
read.open("Date.txt");
read << "Name: " << get_name()<<endl;
read << "Total: " << Total << endl<<endl;
read.close();
}
};
int main()
{
Invoice n[2] ;
for (int i = 0; i < 2; i++)
{
n[i].ReadPrices();
cout<<"Total :"<<n[i].GetTotal()<<endl;
cout<<"Maximam :"<<n[i].GetMax()<<endl;
n[i].print();
n[i].print("Date.txt");
}
return 0;
}