#include <iostream>
#include<cstdlib>
#include<fstream>
using namespace std;
int Qclothes,Qshoes,Qtoiletries,Qgadget,temp;
class MySuitcase
{
public:
int quantity; //declaration of data members
char colour;
double weight;
char sizeA; //size for clothes s,m,l,xl
int size2; //size for shoes (4-10)
int i,j;
MySuitcase() //constructor with no argument
{
char white,s;
quantity=0;
weight = 0;
colour=white;
sizeA=s;
size2=4;
}
double total_weight(double v,double w,double x,double y,double z)
{
double total_weight;
total_weight=v+w+x+y+z; //function to calculate the total weight of items
return total_weight;
}
};
void printArray(int arr[], int size) {
for ( int p = 0; p < size; p++ ) {
cout << arr[p] << ' ';
}
cout << endl;
}
void swap_item(int MySuitcase[],int &i, int &j)
{ int temp = 0;
temp = MySuitcase[i] ;
MySuitcase[i] = MySuitcase[j];
MySuitcase[j] = temp;
}
int main() //main function
{
MySuitcase[4]= {Qtoiletries,Qclothes,Qshoes,Qgadget};
int a,b,c,d,press; //quantity
double v,w,x,y,z,t;
int printArray;//weight
cout<<"Please enter the things you want to bring in suitcase:" <<endl;
cout<<"\n";
cout<<"=========Toiletries========="<<endl; //object 1
cout<<"Quantity of your toiletries: "<<"\t"; //properties
cin>>a;
cout<<"Your quantity:"<<"\t"<<a<<endl;
cout<<"\n";
cout<<"What is the weight of your toiletries(in kg):"<<"\t";
cin>>v;
cout<<"Your weight:"<<"\t"<<v<<"kg"<<endl;
cout<<"\n";
cout<<"=======Formal clothes=======:"<<endl; //object 2
cout<<"Quantity of your formal clothes: "<<"\t"; //properties
cin>>b;
cout<<"\n";
cout<<"What is the weight of your formal clothes(in kg) :"<<"\t";
cin>>w;
cout<<"Your weight:"<<"\t"<<w<<"kg"<<endl;
cout<<"\n";
cout<<"=======Gadgets======="<<endl; //object 3
cout<<"How many gadget you bring: "<<"\t"; //properties
cin>>c;
cout<<"Your gadget quantity is:"<<"\t"<<c<<endl;
cout<<"\n";
cout<<"What is your gadget weight(in kg):"<<"\t";
cin>>x;
cout<<"Your weight:"<<"\t"<<x<<"kg"<<endl;
cout<<"\n";
cout<<"========Shoes========="<<endl; //object 4
cout<<"Quantity of your shoes: "<<"\t"; //properties
cin>>d;
cout<<"Your quantity:"<<"\t"<<d<<endl;
cout<<"\n";
cout<<"What is the weight of your shoes (in kg):"<<"\t";
cin>>y;
cout<<"Your weight:"<<"\t"<<y<<"kg"<<endl;
cout<<"\n";
cout<<"Your total weight in your suitcase is:"<<"\t"<<MySuitcase().total_weight(v, w, x, y, z)<<"kg"<<endl;
//total weight of all items
cout<<"\n";
if(MySuitcase().total_weight(v, w, x, y, z)<=30) //if-else statement(selection structure)
{ //to state whether user have exceed 30kg or not
cout<<"You have not exceed the maximum limit of your suitcase"<<endl;
}
else
{
cout<<"Your suitcase have exceeded the maximum weight!"<<endl;
}
cout << " Please input the things that you want to swap: ";
cout << "The original array is:\t";
printArray(arr, 4);
swap_item(arr, 0, 1);
cout << "The swapped array is:\t";
printArray(arr, 4);
system("PAUSE");
return 0;
}