for (int floor = 1; floor <= max_floors; floor++)
gotoxy(25,1 + floor);
cout << "Number of rooms on floor " << floor << ":" << endl;
cin >> number__floor;
// Gathers number of occupied rooms.
gotoxy(25,2 + floor);
cout << "Number of occupied rooms: ";
cin >> occupied_rooms;
}
I am using gotoxy to try and format my input statements for this loop. I took out some code to make it easier on the eyes but i can't seem to figure it out without something overwriting another.
This is the desired display i am trying to achieve:
1 2 3 4 5 6 7 8 9 10
Number of rooms on floor 1:
Number of occupied rooms:
Number of rooms on floor 2:
Number of occupied rooms:
Number of rooms on floor 3:
Number of occupied rooms:
and so on..
Appreciate any input on this issue i am having.
Thanks.
ALSO: Please note that i do have a function created for gotoxy .
I haven't worked with arrays at all, but gotoxy will go to that specific coordinate on the window and in my case, print the first character of the cout on the specified coordinate.
Oh, so then your problem looks like when you print the first set of data, the data is moved so many coordinates and the second set of data won't be accurate?
Yes that's exactly it, i have tried playing with the coordinates in different ways but i can't seem to get it to be right on. I doubt its a hard fix,i am just overlooking something.
I can't really give you an anwers using GotoXY because Ive never used it.
Is all the data printed on the screen?
I would probobly just use arrays. They are very easy (or at least thats what I think), once you figure out how they work.
Do you know what a matrix is in math? Arrays are extremely similar, they just hold data like text or charactars, and not always numbers.
1 2 3 4 5 6 7 8 9 10 11 12
//I think of arrays as matricies.
//like this:
int x[5] //this makes an array called "x" that holds 5 integers.
//basically it can hold 5 numbers like this:
x[1]=1;
x[2]=2;
x[3]=3;
x[4]=4;
x[5]=5;
//so now the array equals {1,2,3,4,5}
The array might start at zero and end at 5 or 4. I don't remember.
Do you know what a matrix is in math? Arrays are extremely similar, they just hold data like text or charactars, and not always numbers.
A matrix in math doesn't always hold numbers either. And saying arrays are similar to matrices is quite a stretch considering arrays don't support a single matrix operation.
Although otherwise I 'll have to agree - it's not quite clear to me why you even use gotoxy to begin with.
@hanst99
Yeah, I never thought of it that way. I never tried using arrays for matrix style math, I thought of them as as matrix looking tables that held data.