Ask C/C++ Expert


Home >> C/C++

1. Use the following class declarations. Write the complete description of all functions so that the program creates the following I/O

class POINT

{ private: int x, y;

public: /1 constructor to set x,y of each vertex to ZERO

POINT ();

// member to read x and y coordinate of each vertex

void ReadData(char vertex);

// display the ( x, y) of a given vertex

void Display( char vertex);

// friend to compute the distance between vertices p(x,y) and q(x,y)

friend float Distance(POINT p, POINT q);

// Compute and display the perimeter of ABCD

friend void DisplayPerimeter( float AB, float AC, float CD, float BD); //destructor to release all memory used by objects in the program

˜Two();

};

Sample I/O

For rectangle ABCD:

Enter the x and y coordinates of vertex A: 10 7

Enter the x and y coordinates of vertex B: 20 7

Enter the x and y coordinates of vertex C: 10 2

Enter the x and y coordinates of vertex D: 20 2

              A(10.00,7.00)------------------------ B(20.00,7.00)

              C(10.00,2.00)------------------------- D(20.00,2.00)

AB= 10.00

AC=5.00

CD=10.00

BD=5.00

Perimeter =30.00

Hint. Part of the main function should look like this

Int rnain()

{ POINT A, B, C, D; //create 4 objects and initialize their x and y

cout<<"For the rectangle ABCD:\n";

A.ReadData('A');

//draw  the  rectangle

A. Displayr('A'); cout<<"...............................";B.Display('B'); cout«endl;

//compute  the  length  of  each  side

float  AB = Distance (A,B); cout <<"\t AB=" <

//compute and display perimeter

DisplayPerimeter(AB, AC, CD, BD);

//terminate program

return 0;

}

class Two

{

private: int age[5];

public: // read data into array age void ReadData();

// friend to return the average of data in array age of object p friend int FindAverage (TWO p );

//member to find and return the max and min age

void FindMaxMin( int& maxAge, int& minAge); //display ages>age average

Void DisplayAboveAve( int ageAve);

//display the max and min ages

void DisplayMaxMinAge(int maxAge, int minAge);

//release all memory used by objects

~TWO() {}

};

Write all members and friends after the main

a. Write the main to produce the given I/O

3. Given the following class declarations

class THREE

{ private: int a[5];

public: void CopyData(string fname) ; //copy data from file into array a

void SortArray (); //sort the array a of the object activated this member

void DisplayArray();//display the array a of the object activated this member

~THREE();

};

And the following three files. (a) convert the class to a class template to receive the type and the size of array a. Describe all members after class. (b) we want to display the sorted form of each file by (i) coping data from the file into array a, 90 sort array a, 9iii) display the sorted form of array a

Filel.txt

25 50 13 77 9

File2.txt

Mary John Adam Bill Jack

File3.txt

C OR NE



 

Output



This is the sorted form of Filel.txt

9 13 25 50 77

This is the sorted form of File2.txt

Adam..... ........ ........ .........

This is the sorted form of File3.txt C E .....

 

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91312928
  • Price:- $55

Guranteed 36 Hours Delivery, In Price:- $55

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As