2D Array Help :[

Im in dire need of help with a 2D array. here is the proffessors assignment
Digital Calculator
John was so fond of his digital calculator that when the one I had once given him as present broke down,
he was very depressed. So, I promised to develop him a program that would actually efficiently simulate
such a digital calculator on the computer screen. Can you help me develop such a program?
Your task is to develop a program that can efficiently simulate a digital calculator. The program should
be able to receive as input from the standard input stream:
1. Two integer numbers on separate lines
2. An arithmetic operator (i.e. + for addition, - for subtraction, * for multiplication, / for the
integral (Euclidean) division, or % the for the remainder of the integral (Euclidean) division)
3. A character used to draw the numbers on the screen
Draw the arithmetic calculation and the result on the console.
Numbers and operators are displayed as follows. (Note: The dots indicate spaces and are shown for
clarity only. They don’t need to be present in the program’s output.)


.. #..
.##..
.. #..
.. #..
#####

something like that needs to be displayed if the user inputs #

i have made the calculator portion but am having trouble with making an array that recieves the uses input
Last edited on
Post relevant code. We aren't psychics.
Show us what you've done so far first, pots the calculator portion and use code tags - http://www.cplusplus.com/articles/jEywvCM9/
im trying to use an array function like this but that can be used several times, once for each number and character

int main()
{
int z;
cin >> z;
int x;
int y;
int array[5][5]; // Declares an array like a chessboard

for (x = 0; x < 5; x++) {
for (y = 0; y < 5; y++)
array[x][y] = z; // Set each element to a value
}
cout << "Array Indices:\n";
for (x = 0; x < 5; x++) {
for (y = 0; y < 5; y++)
cout << " " << array[x][y] << " ";
cout << "\n";
}
system("pause");
cin.get();
}


also this is the calculator code that i got to work as well


#include <iostream>
#include <string>
#include <cmath>
using namespace std;


int main()
{

double a;
double b;
char operation;


cout << "Enter a first number" << endl;
cin >> a;

cout << "Enter a second number" << endl;
cin >> b;

cout << "Enter an operation you would like to apply: " << endl;
cin >> operation;




switch (operation)
{

case'+':
cout << "The addition of two numbers (" << a << "," << b << "):";
cout << a + b << endl;
break;
case'-':
cout << "The substraction of two numbers (" << a << "," << b << "):";
cout << a - b << endl;
break;
case'*':
cout << "The multiplication of two numbers (" << a << "," << b << "):";
cout << a*b << endl;
break;
case'/':
cout << "The division of two numbers (" << a << "," << b << "):";
if (b == 0)
{
cout << "not valid" << endl;
}
cout << (a / b) << endl;
break;
case'%':
cout << "The remainder of two numbers (" << a << "," << b << "):";
cout << fmod(a, b) << endl; //fmod() used for mod of type double
break;


}



cin.get();
system("pause");
return 0;

}


my issue is figuring out how to first get an individual character to be placed specifically and also combining the two codes
it seems like i would have to store arrays into strings, how would i go about this?
it seems like i would have to store arrays into strings, how would i go about this?


What do you mean? Do you mean store an array of strings?
Topic archived. No new replies allowed.