Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please i need someone to help me with thses analyzation assignment below:, thank

ID: 3856980 • Letter: P

Question

Please i need someone to help me with thses analyzation assignment below:, thank you

Analyzation Requirements: perform a detailed analysis of the differences and similarities between M1 and M2 provided below.  

a. M1 (made of secondclass, firstclass and header.h below)

secondclass

#include "stdafx.h"

#include "header.h"

using namespace std;

void secondClass::printData() {

   std::cout << " Enter userName";

   string username = getUserName(); //calling base class method --> to read input from user

   std::cout<<" Entered Username : "<<username <<" : "<<endl;

}

void secondClass::Convert(int inch){

   int feet, inches;

   inches = inch % 12;

   feet = inch / 12;

std::cout << " The height in feet is" << feet << "" << inches << " " " << endl;

}

int main()

{

   int htInches;

   secondClass sc;//class reference

   std::cout << " Enter height in iches";

   std::cin >> htInches;

   sc.Convert(htInches);

   std::cout << " ";

   sc.printData();//to read input and display

   return 0;

}

firstclass

include "stdafx.h"

#include "header.h"

string firstClass::getUserName() {

   string line;

   std::cin >> line;//reading input from user

   return line;

}

Header.h

include "stdafx.h"

#include <string>

#include <iostream>

using namespace std;

class firstClass{

public:

   string getUserName();

   void printData();

};

class secondClass: public firstClass{

public:

   void printData();

   void Convert(int inch);

};

b. M5

#include <iostream>

#include <conio.h>

#include <string>

using namespace std;

class Conversions

{

public:

       void convertFt_And_In_To_Cm(double &ft, double &in);

       //Function converts the given feet(ft) and inches(in) into centimeters(cm)

       //Calls printCm

       void printCm(double &ft, double &in, double &cm);

       //Function is called by the convertFt_And_In_To_Cm(double &ft, double &in) function

       // and will display the input ft and in, as well as the converted cm value

       void convertLbs_To_Kg(double &lbs);

       //Function converts the given pounds(lbs) into kilograms(kg)

       //Calls printKg

       void printKg(double &lbs, double &kg);

       //Function is called by the convertLbs_To_Kg(double &lbs) function

       // and will display the input lbs, as well as the converted kg value

       Conversions();

       //Default constructor.. class has no member variables so none are declared

       ~Conversions();

       //Destructor

};

class Name

{

public:

       string getName();

       //Function returns the first name of the individual

       void setName(string firstName);

       //Function sets the first name value to firstName.

       // if no parameters are given.. the name defaults to a null string

       void Print();

       //Function prints the user's name to the screen

       Name(string);

       //Alternate constructor, sets first name

       // if no parameters are given for a variable, the variable defaults to a null string

       Name();

       //Default constructor, sets first name to a null string

       ~Name();

       //

private:

       string firstName;

       //holds the value of the first name

};

class derivedName : public Name

{

public:

       string getName();

       //Function returns the first and last name of the individual

       void setName(string firstName, string lastName);

       //Function sets the first and last name value to firstName and lastName respectively.

       // if no parameters are given.. the names defaults to null strings

       void Print();

       //Function prints the user's name to the screen

       derivedName(string firstName, string lastName);

       //Alternate constructor, sets first and last name

       // if no parameters are given for a variable, the respective variable defaults to a null string

       derivedName();

       //Default constructor, sets first and last name

       // each name variable defaults to null strings

       ~derivedName();

       //

private:

       string lastName;

       //holds the value of the last name

};

bool displayMenu();

bool getMenuChoice(bool&);

derivedName yourName;

int main()

{

       string fname, lname, wholeName;

       cout << " Please enter your first and last name: ";

       cin >> fname >> lname;

       yourName.setName(fname, lname);

       wholeName = yourName.getName();

       cout << "*" << wholeName << "*" << endl;

       yourName.Print();

       while(displayMenu());

       return 0;

}

bool displayMenu()

{

       bool goOrNo = true;

       cout << " ";

       yourName.Print();

       cout << " please select one of the following:" << endl;

       cout << "Convert (F)eet and (I)nches to (C)entimeters (Press f, i, or c)" << endl;

       cout << "Convert (P)ounds to (K)ilograms (Press p or k)" << endl<< endl;

       cout << "Exit the converting program (Press x)" << endl;

       cout << endl;

       while(getMenuChoice(goOrNo));

       return goOrNo;

}

bool getMenuChoice(bool& goOrNo)

{

       Conversions conv;

       double input1, input2;

       //read the menu choice from the user

       if (_kbhit())

       {

              char input = _getch();

              switch(input)

              {

              case 'f':

              case 'i':

              case 'c':

              case 'F':

              case 'I':

              case 'C':

                     cout << "Please enter feet and inches, with a space separating each, and then press enter: ";

                     cin >> input1 >> input2;

                     conv.convertFt_And_In_To_Cm(input1, input2);

                     return false;

                     break;

              case 'p':

              case 'k':

              case 'P':

              case 'K':

                     cout << "Please enter the number of pounds and then press enter: ";

                     cin >> input1;

                     conv.convertLbs_To_Kg(input1);

                     return false;

                     break;

              case 'x':

              case 'X':

                     goOrNo = false;     

                     return false;

                     break;

              }

       }

       return true;

}

//Start of conversion class functions

void Conversions::convertFt_And_In_To_Cm(double &ft, double &in)

{

       double cm = (ft * 30.48) + (in * 2.54);

       printCm(ft, in, cm);

}

void Conversions::printCm(double &ft, double &in, double &cm)

{

       cout << " " << ft << " feet, " << in << " inches, is equivelant to " << cm << " centimeters. ";

}

void Conversions::convertLbs_To_Kg(double &lbs)

{

       double kg = lbs * 0.45359;

       printKg(lbs,kg);

}

void Conversions::printKg(double &lbs, double &kg)

{

       cout << " " << lbs << " pounds, is equivelant to " << kg << " kilograms. ";

}

Conversions::Conversions()

{}

//Default constructor.. class has no member variables so none are declared

Conversions::~Conversions()

{}

//Destructor

//Start of name class functions

string Name::getName()

{

       return firstName;

}

void Name::setName(string firstName)

{

       firstName = firstName;

}

void Name::Print()

{

       cout << firstName;

}

Name::Name(string firstName)

{

       firstName = firstName;

}

Name::Name()

{

       firstName = "";

}

//Default constructor..

Name::~Name()

{}

//Destructor

//Start of derivedName functions

string derivedName::getName()

{

       string temp;

       temp = Name::getName() + " " + lastName;

       return temp;

}

void derivedName::setName(string firstName, string lastName)

{

       Name::setName(firstName);

       lastName = lastName;

}

void derivedName::Print()

{

       Name::Print();

       cout << lastName;

}

derivedName::derivedName(string firstName, string lastName) : Name(firstName)

{

       lastName = lastName;

}

derivedName::derivedName()

{

       lastName = "";

}

//Default constructor..

derivedName::~derivedName()

{}

//Destructor

Explanation / Answer

Answer for the given Question:

Differences Between M1 and M2:
Point 1:
M1 is have only one unit conversion between inch to feet
M2 is have two conversion between Ft to Cm and Kg to LB.

Point 2:
M1 is implemented single inheritance
M2 is also implemented single inheritance and in addition it has the seperate class called Conversions

Point 3:
M1 classes doesn't have the class data parameters where as M2 is having class Data parameters
M1 doesn't have global functions where as M2 is having the globals functions these functions are using to perform unit conversion.

Point 4:
M1 doesn't have any menu based selection where as M2 is having the menu based selection in separate global method.
M1 doesn't have the constructor and destructor where as M2 is having the constructor and destructor.

Point 5:
M1 doesn't read the class data variable inside main function where as M2 is reading the class data members inside main method.