Answer to Question #185911 in C++ for samina

Question #185911

: Define a class called token number that incorporates a token’s number (could be the last 3 digits of your arid number) and its location. Number each token object as it is created. Use two variables of the angle class to represent the token’s latitude and longitude. A member function of the token class should get a position from the user and store it in the object; another should report the serial number and position. Design a main() program that creates three token, asks the user to input the position of each, and then displays each token’s number and position.



1
Expert's answer
2021-04-26T18:46:31-0400
#include <iostream>
using namespace std;


//define token number class
class TokenNumber {


    //define data members
    private:
        int token_num;
        float token_lattitude;
        float token_longitude;
   
    //methods
    public:
        void getData(int tNum, float tLat, float tLon) {
            token_num=tNum;
            token_lattitude=tLat;
            token_longitude=tLon;
        }


        double getLocation() {
            return token_lattitude + token_longitude;
        }


};




int main() {


    //create three  objects of class token number
    TokenNumber t1;
    TokenNumber t2;
    TokenNumber t3;
   
    t1.getData(546, 40.8, 39.2);
    t2.getData(349, 37.4, 22.6);
    t3.getData(234, 43.8, 56.3);




    cout << "position of token 1 :  " << t1.getLocation() << endl;
    cout << "position of token 2 :  " << t2.getLocation() << endl;
    cout << "position of token 3 :  " << t3.getLocation()<< endl;


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS