Help with array processing!

Program functionality:
1.) Design a rudimentary spread sheet.
2.) Provide provision for the entry of a formula, i.e. cell#?? = value, cell#?? = operation, cell#?? = value, and cell#?? = answer.
3.) Basic arithmetic operations (+,-,*,/)

I have the grid display completed. How do I go about coding for the selection of a cell and then display the value within that cell. I've been playing around with switch statements but i havent quite figured it out.

Any and all help is greatly appreciated.

Here is my code for the design of the grid.

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
void _tmain(int argc, _TCHAR* argv[])
{
char RowList,ColList;
int g,h,i,j,k;
float operand1;
float CellGrid[ROW][COL];

cout << fixed;
cout << setprecision(3);

for(g=0;g<ROW;g++)
{
for(h=0;h<COL;h++)
{
CellGrid[g][h] = (0)*(0);
}
}

for(i=0,RowList='A';i<ROW;i++,RowList++)
{
cout << " " << RowList << " ";
}
cout << endl;
cout << setfill('_') << setw(77) << '_';
cout << endl;
for(j=0,ColList='0';j<ROW;j++,ColList++)
{
cout << endl << ColList << "| ";
for(k=0;k<COL;k++)
{
cout << setfill(' ') << setw(8) << CellGrid[j][k] << setw(7) << " | ";
}
cout << endl << setfill('_') << setw(77) << '_';
cout << endl;
}
cout << endl << endl;
}
closed account (L1T0RXSz)
Hi,
I'm sorry but I have a question to ask: Is this the full program? Here's what my compiler said:

hi.cpp:1: type specifier omitted for parameter
hi.cpp:1: parse error before `*'
hi.cpp: In function `void _tmain (...)':
hi.cpp:6: `ROW' undeclared (first use this function)
hi.cpp:6: (Each undeclared identifier is reported only once for each
function it appears in.)
hi.cpp:6: `COL' undeclared (first use this function)
hi.cpp:8: `cout' undeclared (first use this function)
hi.cpp:8: `fixed' undeclared (first use this function)
hi.cpp:9: `setprecision' undeclared (first use this function)
hi.cpp:15: `CellGrid' undeclared (first use this function)
hi.cpp:23: `endl' undeclared (first use this function)
hi.cpp:24: `setfill' undeclared (first use this function)
hi.cpp:24: `setw' undeclared (first use this function)

Can you please write out the program?

Thanx,
Akash
this is just the code that generates the grid. sorry about that here is the full code with libraries included.

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
 #include "stdafx.h"
#include <iostream>

#include <cctype>
#include <iomanip>
#include <string>
using namespace std;
#define ROW 5
#define COL 5

int CellPick(float value);

void _tmain(int argc, _TCHAR* argv[])
{
	char RowList,ColList;
	int g,h,i,j,k;
	float operand1;
	float CellGrid[ROW][COL];
	
	cout << fixed;
	cout << setprecision(3);

	for(g=0;g<ROW;g++)
	{
		for(h=0;h<COL;h++)
		{
			CellGrid[g][h] = (0)*(0);
		}
	}

	for(i=0,RowList='A';i<ROW;i++,RowList++) 
	{
		cout << "       " << RowList << "        ";
	}
	cout << endl;
	cout << setfill('_') << setw(77) << '_';
	cout << endl;
	for(j=0,ColList='0';j<ROW;j++,ColList++)
	{
		cout << endl << ColList << "| ";
		for(k=0;k<COL;k++)
		{
			cout << setfill(' ') << setw(8) << CellGrid[j][k] << setw(7) << " | ";
		}
		cout << endl << setfill('_') << setw(77) << '_';
		cout << endl;
	}
	cout << endl << endl;

//________________________________________//
This is my switch statement idea.
//________________________________________//
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
57
string cellName

switch(cellName[0] & cellName[1])
{
case 'A0': array[0][0] = value;
			break;
case 'A1': array[0][1] = value;
			break;
case 'A2': array[0][2] = value;
			break;
case 'A3': array[0][3] = value;
			break;	
case 'A4': array[0][4] = value;
			break;
case 'B0': array[1][0] = value;
			break;
case 'B1': array[1][1] = value;
			break;
case 'B2': array[1][2] = value;
			break;
case 'B3': array[1][3] = value;
			break;
case 'B4': array[1][4] = value;
			break;
case 'C0': array[2][0] = value;
			break;
case 'C1': array[2][1] = value;
			break;
case 'C2': array[2][2] = value;
			break;
case 'C3': array[2][3] = value;
			break;
case 'C4': array[2][4] = value;
			break;
case 'D0': array[3][0] = value;
			break;
case 'D1': array[3][1] = value;
			break;
case 'D2': array[3][2] = value;
			break;
case 'D3': array[3][3] = value;
			break;
case 'D4': array[3][4] = value;
			break;
case 'E0': array[4][0] = value;
			break;
case 'E1': array[4][1] = value;
			break;
case 'E2': array[4][2] = value;
			break;
case 'E3': array[4][3] = value;
			break;
case 'E4': array[4][4] = value;
			break;
}
return 0;
}

Last edited on
Topic archived. No new replies allowed.