Questions: 11 448

Answers by our Experts: 10 707

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!

Search & Filtering

Consider the abstract class declaration:


class aPolygon

{

protected:

long double * sides, // There are N sides with different lengths

* angles; // There are N angles with different sizes

long int no_of_sides; // The number of sides, N, of this polygon


public: aPolygon(long int _sides = 1);

/* It sets no_of_sides = _sides.*/


virtual void input () = 0; // input the derived polygon

virtual void display () = 0; // display the derived polygon


~aPolygon() {}

};


Write a complete C++ class implementation of the following derived class, aSquare, with the class interface::


class aSquare : public aPolygon

{

public:

aSquare(); /* It creates a square as a unit square */


~aSquare() {}


virtual void input(); /* It inputs the data for the square */


virtual void display(); /* It displays the square: angles, sides, perimeter and area */


long double perimeter(); /* It computes the perimeter of the square */


long double area(); /* It computes the area of the square: */

}; 


Consider the following program on the link;

https://drive.google.com/file/d/1EELCBZ58M-uxdMDZR8faLLQ45h9jLArE/view?usp=sharing


Now, consider the derived class interface, aTriplet, defined as


template <template T1, class T2, class T3>

class aTriplet : public aPair <T1, T2>

{

private:

T3 obj3; // The 3rd component of the triplet. obj1 and obj2 are inherited from aPair


public: // The get and set data functions


T3 get_obj3(); /* Returns obj3 to any calling environment*/


void set_obj3(T3 value); /* Sets the value of obj3 to value */

// The constructor -- polymorphic


aTriplet(T1 value1 = 0, T2 value2 = 0, T3 value3 = 0);

// It constructs a triple as three components: (value1, value2, value3).


~aTriplet() {} void input(); // It allows the user to enter the three components,


void display();

};


Now, write a complete C++ class implementation of the following constructor and member functions:

a) aTriplet(T1 value1 = 0, T2 value2 = 0, T3 value3 = 0);

b) void input();

c) void display();


Writea c++program that would ask the user to enter their personal information: last name,first name, middle name, birthday, age, gender and permanent address


Create a program that will compute the salary of an employee. Salary is computed as hours worked times rate per hour. Rate is based on the inputted employee code. Consider the following:

Employee Code Rate per hour

1 100.00

2 200.00

3 350.00

4 500.00



Write a C++ program that asks the user to enter a number N .After that, print N lines using asterisk (*) in a


triangle shape as shown below;


Sample Input:


Enter number of lines to print: 6

Write a class rectangle and store the length and width of the rectangle. Write a member function called increment that will increment to length and width. Also write the function to find the area of a rectangle and then write the accessor function that will display the length, width and area of the rectangle. Demonstrate the use of the object in the main function.

class rectangle

{

private:

int length, width, area;

public:

}


Write a program to determine whether a year entered through the keyboard is a leap year or not. Also determine whether the year is your year of birth, starting your school, start or end of matriculation (or O-levels etc), start or end of Intermediate education (FSC, A-levels, ICOM, ICS etc) or year of starting your education in COMSATS University?


Create a C++ program that will prompt the user for a line of text. This line of text must be written to a text file called info.txt

Once the line of text has been written, display a text on the screen alerting the user that information has been written to a file successfully.


#include <iostream>


#include <string>


using namespace std;




int main() {


string last, first, middle;


int age;


string birthday;


string gender;


string address;




cout << "Enter you lastname: ";


cin >> last;




cout << "Enter you firstname: ";


cin >> first;




cout << "Enter you middlename: ";


cin >> middle;




cout << "Enter your birthday: ";


cin >> ws;


getline(cin, birthday);




cout << "Enter your age: ";


cin >> age;




cout << "Enter your gender: ";


cin >> gender;




cout << "Enter your permanent address: ";


cin >> ws;


getline(cin, address);




cout << "Hello " << first << " " << middle << " " << last << endl;


cout << "Your birthday is " << birthday


<< " and now you are " << age << " years old." << endl;


cout << "You are " << gender << endl;


cout << "and you live at " << address << endl;




return 0;


With explanation

Exercise 1.1 : Base and ASCII representation of character representation Print the decimal, octal and hexadecimal value of all characters between the start ad stop characters entered by a user. for example, if the user enters an ’A’ and ’H’, the program should print all the characters between ’A’ and ’H’ and their respective values in the different bases (decimal, octal, and hexadecimal) as follows ASCII Representation of D is 68 in Decimal 104 in Octal and 44 in Hexadecimal ASCII Representation of E is 69 in Decimal 105 in Octal and 45 in Hexadecimal ASCII Representation of F is 70 in Decimal 106 in Octal and 46 in Hexadecimal ASCII Representation of G is 71 in Decimal 107 in Octal and 47 in Hexadecimal ASCII Representation of H is 72 in Decimal 110 in Octal and 48 in Hexadecimal ASCII Representation of I is 73 in Decimal 111 in Octal and 49 in Hexadecimal ASCII Representation of J is 74 in Decimal 112 in Octal and 4A in Hex


LATEST TUTORIALS
APPROVED BY CLIENTS