You are on page 1of 2

#include<iostream>

using namespace std;


const float km=0.6;
class bike
{
private:
float distance;
float cost;
public:
void setdistance(float x)
{
distance=x;
}
void setcost(float x)
{
cost=x;
}
float getdistance()
{
return distance;
}
float getcost()
{
return cost;
}
};
void read(bike &a);
void compare(bike &a,bike &b);
int main()
{
bike ching,chong;
read(ching);
read(chong);
compare(ching,chong);
}
void read(bike &a)
{
float x,y;
cin>>x;
a.setdistance(x);
cout<<endl;
cin>>y;
a.setcost(y);
cout<<endl;
}
void compare(bike &a,bike &b)
{
float bikea,bikeb;
bikea=a.getdistance()*km;
bikeb=b.getdistance()*km;
bikea=a.getcost()/bikea;
bikeb=b.getcost()/bikeb;
if(bikea<bikeb)
{
cout<<"ching rocks\n";
cout<<bikea;
}
else

{
cout<<"chong rocks\n";
cout<<bikeb;
}
}

You might also like