Question

NEED C++ HELP. PLEASE FOLLOW DIRECTIONS CAREFULLY:

Use a 1 dimensional array object to create a 2 dimensional table object. Then modify to create a triangular table.

Example:

Program Output Reviewl Ele Edt yew Navigate Source Refgctor Bun Debug brofile Team Toolsindow Help ObjectArray - Netleans IDE 8.2 Projects × Fie® Service8 Classes Output x Batteshipvi -e Compare Constructs CPP PHP Javascpt prectsArays FuncionsPThe Row Array size 8 printed 4 per Line CPP Constructs 99 40 60 35 a10 90 55 10 le aSript PHP Get Post 回Ble ISON·Cookies The table size is [row,col][6,8] 21 99 88 83 39 43 34 26 21 44 74 55 75 74 19 64 90 85 20 78 31 48 61 53 23 75 50 59 44 97 30 54 79 42 10 62 85 65 78 71 48 11 75 20 27 28 99 25 Revicn Header Fles Resource Files Source Files 香Triangle.cpp Test Fles Important Files The triangular table size is [row, row] = [6,6] 困11 Reviem3.CIS 17t.Template 33 91 59 9 69 48 68 73 54 82 62 87 31 58 88 75 19 98 RUN SUCCESSFUL (total time: 83ms) 265572 825 9828 5488 11948

Objective -> create an array of dynamic objects of RowAray inside Table. See below for RowAray.h, Table.h, Then create a triangular table like the example above.

Fill each cell with random 2 digit integers. The Example Table above has 8 columns of RowAray objects each filled with 6 rows of random 2 digit numbers.

Then create a triangular table using the concept of the original table.

*Create .cpp files for RowAray.h, Table,h, and Triangle.h*.

RowAray.h:

Table.h:

Triangle.h:

Lastly, here is the main.cpp file:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment..

RowAray.h

#ifndef ROWARAY_H

#define ROWARAY_H

#include<cstdlib>

class RowAray{

private:

int size;

int *rowData;

public:

RowAray(int size){

this->size = size;

rowData = new int[size];

for(int i=0; i<size; i++){

rowData[i] = (rand()%90)+10;

}

}

~RowAray(){

delete rowData;

}

int getSize(){

return size;

}

int getData(int i){

return rowData[i];

}

};

#endif

Table.h

#ifndef TABLE_H

#define TABLE_H

#include "RowAray.h"

class Table{

private:

int szRow;

int szCol;

RowAray **records;

public:

Table(int row, int col){

this->szRow = row;

this->szCol = col;

records = new RowAray*[row];

for(int i=0; i<row; i++)

records[i] = new RowAray(col);

}

~Table(){

delete [] records;

}

int getSzRow(){

return szRow;

}

int getSzCol(){

return szCol;

}

int getData(int r, int c){

return records[r]->getData(c);

}

};

#endif

Triangle.h

#ifndef TRIANGLE_H

#define TRIANGLE_H

#include "RowAray.h"

class Triangle{

private:

int szRow;

RowAray **records;

public:

Triangle(int row){

this->szRow = row;

records = new RowAray*[row];

for(int i=0; i<row; i++)

records[i] = new RowAray(row);

}

~Triangle(){

delete[] records;

}

int getSzRow(){

return szRow;

}

int getData(int r, int c){

return records[r]->getData(c);

}

};

#endif

main.cpp

#include<cstdlib>

#include<ctime>

#include<iostream>

using namespace std;

#include "Table.h"

#include "Triangle.h"

void prntRow(RowAray *, int);

void prntTab(Table *);

void prntTri(Triangle *);

int main(int argc, char **argv){

srand(static_cast<unsigned int>(time(0)));

int rows=6, cols = 8, perLine = cols/2;

RowAray row(cols);

cout<<"The Row Array size = "<<row.getSize()<<" printed "<<perLine<<" per Line";

prntRow(&row, perLine);

Table tab(rows, cols);

cout<<"The table size is [row, col] = ["<<rows<<", "<<cols<<"]";

prntTab(&tab);

Triangle tri(rows);

cout<<"The triangular table size is [row, row] = ["<<rows<<", "<<rows<<"]";

prntTri(&tri);

return 0;

}

void prntRow(RowAray *a, int perLine){

cout<<endl;

for(int i=0; i<a->getSize(); i++){

cout<<a->getData(i)<<" ";

if(i%perLine == (perLine-1))

cout<<endl;

}

cout<<endl;

}

void prntTab(Table *a){

cout<<endl;

for(int row=0; row<a->getSzRow(); row++){

for(int col=0; col<a->getSzCol(); col++){

cout<<a->getData(row, col)<<" ";

}

cout<<endl;

}

cout<<endl;

}

void prntTri(Triangle *a){

cout<<endl;

for(int row =0; row<a->getSzRow(); row++){

for(int col=0; col<=row; col++){

cout<<a->getData(row, col)<<" ";

}

cout<<endl;

}

cout<<endl;

}

nagarajuanagaraju-Vostro-3550:~/Desktop/CHEGG/September/09092018$ gt+ main.cpp nagarajuanagaraju-Vostro-3550:~/Desktop/CHEGG/

Add a comment
Know the answer?
Add Answer to:
NEED C++ HELP. PLEASE FOLLOW DIRECTIONS CAREFULLY: Use a 1 dimensional array object to create a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please Use C++ Language. Thank you. Please I need the actual code. Donot post psudocode!! ​And...

    Please Use C++ Language. Thank you. Please I need the actual code. Donot post psudocode!! ​And also I have codes but just donot work so make sure that it works. Requested files: CrosswordGenerator.cpp, CrosswordGenerator.h, CrosswordGenerator_test.cpp CrosswordGenerator - Write a program that helps to generate a crossword puzzle by organizing words that share letters.   For this assignment, you will write a program that forms the basis of a crossword puzzle generator. In order to create a crossword puzzle you need to...

  • Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D...

    Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D array of integers which is 10x10. 2. Prints out the contents of the 2D array after assigning the data to make sure correct data was assigned. 3. Figures out and prints out the square root of the sum of ALL the elements in the 2D array. 4. Figures out and prints out the average of ALL THE ELEMENTS in the 2D array. 5. Figures...

  • C# 1. Given two lengths between 0 and 9, create an rowLength by colLength matrix with...

    C# 1. Given two lengths between 0 and 9, create an rowLength by colLength matrix with each element representing its column and row value, starting from 1. So the element at the first column and the first row will be 11. If either length is out of the range, simply return a null. For exmaple, if colLength = 5 and rowLength = 4, you will see: 11 12 13 14 15 21 22 23 24 25 31 32 33 34...

  • I need help in C++ assignment. please add statements and i am Xcode complier user. Requested...

    I need help in C++ assignment. please add statements and i am Xcode complier user. Requested files: CountDecades.cpp (Download) Maximum upload file size: 96 KiB Write a C++ program named CountDecades.cpp. In this program you will have two integer arrays. One named inputArray of size 20 containing the values: 83, 2, 23, 11, 97, 23, 41, 67, 16, 25, 1 , 4, 75, 92, 52, 6, 44, 81, 8, 64 in the order specified, and an empty integer array of...

  • Please program in C++ and document the code as you go so I can understand what...

    Please program in C++ and document the code as you go so I can understand what you did for example ///This code does~ Your help is super appreciated. Ill make sure to like and review to however the best answer needs. Overview You will revisit the program that you wrote for Assignment 2 and add functionality that you developed in Assignment 3. Some additional functionality will be added to better the reporting of the students’ scores. There will be 11...

  • Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What...

    Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What This Assignment Is About? Classes (methods and attributes) • Objects Arrays of Primitive Values Arrays of Objects Recursion for and if Statements Selection Sort    Use the following Guidelines: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use upper case for constants. • Use title case (first letter is upper case) for classes. Use lower case with uppercase...

  • The task involves writing a C++ program that determines the prime numbers between 1 and 100....

    The task involves writing a C++ program that determines the prime numbers between 1 and 100. The steps you should follow to identify the prime numbers are the following. 1. The number 1 is not a prime number, so it should be scratched. 2. Starting from the first prime number, which is 2, you scratch all the numbers that are the multiple of 2. You should not scratch out 2 itself. 3. The next number in the sequence after the...

  • Copy the following java codes and compile //// HighArray.java //// HighArrayApp.java Study carefully the design and...

    Copy the following java codes and compile //// HighArray.java //// HighArrayApp.java Study carefully the design and implementation HighArray class and note the attributes and its methods.    Create findAll method which uses linear search algorithm to return all number of occurrences of specified element. /** * find an element from array and returns all number of occurrences of the specified element, returns 0 if the element does not exit. * * @param foundElement   Element to be found */ int findAll(int...

  • I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I...

    I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...

  • PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create...

    PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create the schema, and package. 2. Create users x1 and x2 who are the participants in the auction. They will need acces to the package. 3. Bid on the same item and record your observations. Verify all scenarios. Upload the files with the missing code and a detailed sample run. AUCTION OWNER.TXT SQL> conn / as sysdba Connected. SQL> drop user xyz cascade; User dropped....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT