Distance Interpretation

Description:

When we travel positive distance means travelling forward and negative means travelling backwards Write a program by overloading the unary + and unary - operator to display the same.Create a class Distance(feet,inches) and apply negation on the object to display Travelling Backwards and vice versa. Input : First Line contains Distance(Feet and Inches separated by space) Test Case 1 Input (stdin) 2 10 Expected Output Travelling Forward Feet=2 Inches=10 Travelling Backwards Feet=2 Inches=10 Test Case 2 Input (stdin) 4 20 Expected Output Travelling Forward Feet=4 Inches=20 Travelling Backwards Feet=4 Inches=20

Program :


#include <iostream>

using namespace std;

int main()

{

  int a,b;

  cin>>a>>b;

  cout<<"Travelling Forward\n"<<"Feet="<<a<<" Inches="<<b;

  cout<<"\nTravelling Backwards\n"<<"Feet="<<a<<" Inches="<<b;

return 0;

}