Create a Rati mo

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

c++ question

 

pleas copy n paste ur working code here

 

1. Create a Rational Number class.
a) data members: numerator and denominator
b) implement member accessors and mutators
c) implement a non-member output function which displays the number
as a fraction such as 5/7
d) instantiate and print the Rational Number 5/7
e) make sure that the solution is properly encapsulated
Transcribed Image Text:1. Create a Rational Number class. a) data members: numerator and denominator b) implement member accessors and mutators c) implement a non-member output function which displays the number as a fraction such as 5/7 d) instantiate and print the Rational Number 5/7 e) make sure that the solution is properly encapsulated
Expert Solution
Here is my code-

ANS- Source code-

 #include<iostream> 
// #include<conio.h> 
using namespace std;

 class findRational
 { 
        private: 
        int num,den; 
        public: 
               void set(int n,int d) 
            { 
                 num=n; 
                den=d; 
            } 
              void put() 
           { 
                cout<<"Rational Number as:"; 
                cout<<num<<"/"<<den; 
           } 
              void find(findRational num1, findRational num2) 
          { 
              num=num1.num*num2.den+num2.num*num1.den; 
              den=num1.den*num2.den; 
         } 
 };
            int main() 
        { 
               
               findRational ob1 ,ob2,ob3; 
               ob1.set(5,7); 
               ob2.set(1,7); 
               ob3.find(ob1,ob2); 
               ob3.put(); 
              return 0;
}

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY