VERY IMPORTANT Help needed with C++ project

I have a c++ test coming and i need an answer as quick as possible. Thanks in advance.

Task: Code Assignment
Provide the definitions for the following class declaration and then write a program that demonstrates usage of each member function using the test data of 10 for width and 8 for
height. Remember to put your main program, class header and class source into separate files.
Only provide code for the methods specified in the class declaration. Note that the displayRectangle() method should output an appropriate ‘box’, its dimensions, area and perimeter to the screen.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Rectangle
{
public:
    Rectangle(int height, int width);
    ~Rectangle(void);

private:
 int height;
 int width;

public:

 double getLength(void);
 double getWidth(void);
 double calculateArea(void);
 double calculatePerimeter(void);

 void displayRectangle(void);
};


I also have to use some sort of histogram code to represent the rectangle as a 'box' of *s or other suitable characters.
Last edited on
Please, share to us what you have this far of following: main program and class declaration. Seems you only shared (accidentally?) header file.
Last edited on

eraggo (144) Feb 11, 2013 at 4:52am
Please, share to us what you have this far of following: main program and class declaration. Seems you only shared (accidentally?) header file.


These are the other things given to us. Please if you can do anything help me because the test is very important.

This program uses a structure to hold data about a rectangle. Fill in missing code segments.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <iomanip>
using namespace std;


// array_struct uses a structure to hold data about a rectangle 

// FILL IN CODE TO define a structure named rectangle which has 
// members length, width, area, and perimeter all of which are floats

int main()
{
    // Fill IN CODE to declare a rectangle variable named box

    cout << "Enter the length of a rectangle: ";
	
	// FILL IN CODE to read in the length member of box

	cout << "Enter the width of a rectangle: ";
	
	// FILL IN CODE to read in the width member of box

	cout << endl << endl;

	// FILL IN CODE to compute the area member of box
	// FILL IN CODE to compute the perimeter member of box

	cout << fixed << showpoint << setprecision(2);
	

    // FILL IN CODE to output the area with an appropriate message
	// FILL IN CODE to output the perimeter with an appropriate message


	return 0;
}


This program demonstrates partially initialized structure variables. Fill in missing code segments. You will need to be able to initialize the first three structure members of two structure variables while leaving the last two members un-initialized. You will also be required to add read statements involving one of the structure members.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <string>
using namespace std;

// init_struct demonstrates partially initialized structure variables

struct taxPayer
{
	string name;
	long int socialSecNum;
	float taxRate;
	float income;
	float taxes;
};

int main()
{
	// Fill in code to initialize a structure variable named citizen1 so that
	// the first three members are initilized.  Assume the name is Tim 
	// McGuiness,the social security number is 255871234, and the tax rate is .35

	// Fill in code to initialize a structure variable named citizen2 so that 
	// the first three members are initialized.  Assume the name is John Kane,
	// the social security number is 278990582, and the tax rate is .29
	
	cout << fixed << showpoint << setprecision(2);

	// calculate taxes due for citizen1

	// Fill in code to prompt the user to enter this year's income for the citizen1
	// Fill in code to read in this income to the appropriate structure member

	// Fill in code to determine this year's taxes for citizen1

	
	cout << "Name: " << citizen1.name << endl;
	cout << "Social Security Number: " << citizen1.socialSecNum << endl;
	
	cout << "Taxes due for this year: $" << citizen1.taxes << endl << endl;

	// calculate taxes due for citizen2

	// FILL IN CODE to prompt the user to enter this year's income for citizen2
	// FILL IN CODE to read in this income to the appropriate structure member

	// FILL IN CODE to determine this year's taxes for citizen2



	cout << "Name: " << citizen2.name << endl;
	cout << "Social Security Number: " << citizen2.socialSecNum << endl;

	cout << "Taxes due for this year: $" << citizen2.taxes << endl << endl;

	return 0;
}


Like the first two labs, you are asked to fill in missing code involving a structure declaration. However, in this lab you are also required to define an array of structures. In addition, you must add a looping statement at the end of the program. In the second exercise, you are asked to address an indexing issue regarding arrays (i.e., if we have a list indexed by 1,2,3, . . . then we have to compensate for the fact that the array holding this information must start with 0). Of course, this is something that has been addressed repeatedly in earlier lessons. However, it is useful for you to recall this point several times throughout the course.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <iomanip>

using namespace std;


// array_struct demonstrates how to use an array of structures

// Fill in code to define a structure called taxPayer that has three 
// members:  taxRate, income, and taxes -- each of type float


int main()
{
   // Fill in code to declare an array named citizen which holds
   // 5 taxPayers structures

	cout << fixed << showpoint << setprecision(2);

	cout << "Please enter the annual income and tax rate for 5 tax payers: ";
	cout << endl << endl << endl;

	for(int count = 0;count < 5;count++)
	{

		cout << "Enter this year's income for tax payer " << (count + 1);
		cout << ": ";
		
		// Fill in code to read in the income to the appropriate place

		cout << "Enter the tax rate for tax payer # " << (count + 1);
		cout << ": ";
		
		// Fill in code to read in the tax rate to the appropriate place

		// Fill in code to compute the taxes for the citizen and store it
		// in the appropriate place

	   
		cout << endl;
	}

	cout << "Taxes due for this year: " << endl << endl;

	// Fill in code for the first line of a loop that will output the 
	// tax information
	{
		cout << "Tax Payer # " << (index + 1) << ": " << "$ "
			 << citizen[index].taxes << endl;
	}

	return 0;
}


Like the first three labs, you are asked to fill in missing code involving structure declarations. The first is a structure named dimensions that contains two members of type float. The second is a structure named rectangle that contains two float members and a third member of type dimensions. In other words, you should nest a dimensions structure inside of a rectangle structure. In the second exercise, you are asked to modify the program so that the rectangle structure has structure variables for both of its members. The third exercise requires structure variables to be passed as arguments to a pair of functions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <iomanip>

using namespace std;


// nestedRect_struct uses a structure to hold data about a rectangle 
// It calculates the area and perimeter of a box 

// Fill in code to define a structure named dimensions that
// contains 2 float members, length and width

// Fill in code to define a structure named rectangle that contains
// 3 members, area, perimeter, and sizes.  area and perimeter should be
// floats, whereas sizes should be a dimensions structure variable

int main()
{
   // Fill in code to declare a rectangle structure variable named box.
	
   cout << "Enter the length of a rectangle: ";
   
   // Fill in code to read in the length to the appropriate location

   cout << "Enter the width of a rectangle: ";

   // Fill in code to read in the width to the appropriate location 

   cout << endl << endl;

   // Fill in code to compute the area and store it in the appropriate
   // location
   // Fill in code to compute the perimeter and store it in the 
   // appropriate location

   cout << fixed << showpoint << setprecision(2);
   cout << "The area of the rectangle is " << box.attributes.area << endl; 
   cout << "The perimeter of the recangle is " <<  box.attributes.perimeter
        << endl;

   return 0;
}




OK. Let's start from the post #1:
- Can we see actual implementation of that Rectangle class? implementation is part where you have for example Rectangle::Rectangle(int height, int width) {.....}
- What kind of main function you have wrote so far? Can we see it?

Then post #3:
1
2
// FILL IN CODE TO define a structure named rectangle which has 
// members length, width, area, and perimeter all of which are floats 

Can we see what you have done to all these parts? Parts that have been written to you by teacher/coach does not help you to improve.

We do not give actual code so you can pass the test. If you don't know how to do things in programming, how you would pass the test that is so important? :)
Topic archived. No new replies allowed.