Problem with updating array

Problem 1. Why I entered 3 seat number the program only update 1 seat number.
Problem 2. how to the occupancy rate with decimal point let's say 1/24*100 suppose is 4.2% but the result give is 4.

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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  #include <iostream>
#include <iomanip>
using namespace std;
void getdata1(char &row, int &col);
void UpdatedSuperior(int SCLASS[4][6],char row, int col);
int main()
{	
	int col,SCLASS[4][6]={0};
	char row;
	getdata1(row,col);
	UpdatedSuperior(SCLASS,row,col);
	system("pause");
}
void getdata1(char &row, int &col)
{		
		int i=0,seat_require=0;
		cout<<"How many seat required: ";
		cin>>seat_require;
		for(i;i<seat_require;i++){
		cout<<"Please select your seat: ";
		cin>>row>>col;
		row = static_cast<char>(toupper(row));
		}
		cout<<endl;
}

void UpdatedSuperior(int SCLASS[4][6],char row, int col)
{
	unsigned char a1 = static_cast<char>(218);
	unsigned char a2 = static_cast<char>(179);
	unsigned char a3 = static_cast<char>(196);
	unsigned char a4 = static_cast<char>(191);
	unsigned char a5 = static_cast<char>(194);
	unsigned char a6 = static_cast<char>(197);
	unsigned char a7 = static_cast<char>(195);
	unsigned char a8 = static_cast<char>(180);
	unsigned char a9 = static_cast<char>(192);
	unsigned char a10 = static_cast<char>(193);
	unsigned char a11 = static_cast<char>(217);
	int sum[4]={0},seat[4]={0},seat1=0,sum1=0;
	double seatrate=0;
	char ascii='A';

		cout<<"  Seat Occupancy"<<a3<<"Superior Class\n"<<endl;
		for(int num=1;num<7;num++)//display top number line
		{
			cout<<"   "<<"0"<<num; 
		}
			cout<<"             "<<"Seats Available"<<endl;
			cout<<endl;
			cout<<"  "<<a1;
		for(int top=0;top<5;top++)//display top straight line cover
		{
			cout<<a3<<a3<<a3<<a3<<a5;}
			cout<<a3<<a3<<a3<<a3<<a4;
			cout<<"          "<<"---------------"<<endl;

		SCLASS[static_cast<int>(row)-65] [col-1]=1;

		for(int i=0;i<4;i++){
				cout<<ascii++<<" "<<a2;

		for(int j=0;j<6;j++){

				cout<<" "<<SCLASS[i][j]<<"  "<<a2;
				sum[i]+=SCLASS[i][j];
				sum1+=SCLASS[i][j];		
			}
				cout<<"                "<<6-sum[i];

		if(i==3)
			goto stop;
		cout<<endl;	
		cout<<"  "<<a7;
		
		if(i==0){
		for(int i=0;i<5;i++){
				cout<<a3<<a3<<a3<<a3<<a6;}
				cout<<a3<<a3<<a3<<a3<<a8<<endl;
				}
		if(i==1){
			for(int i=0;i<5;i++){
				cout<<a3<<a3<<a3<<a3<<a10;}
				cout<<a3<<a3<<a3<<a3<<a8<<endl;
				cout<<"  "<<a2<<"           aisles            "<<a2<<endl;
				cout<<"  "<<a7;
		
				for(int j=0;j<5;j++){
					cout<<a3<<a3<<a3<<a3<<a5;}
				cout<<a3<<a3<<a3<<a3<<a8<<endl;
				}
		if(i==2){
		for(int j=0;j<5;j++){
			cout<<a3<<a3<<a3<<a3<<a6;
		}
		cout<<a3<<a3<<a3<<a3<<a8<<endl;}
		
	}	
		stop:
		{
			cout<<endl;
			cout<<"  "<<a9;
			for(int j=0;j<5;j++)
				cout<<a3<<a3<<a3<<a3<<a10;
				cout<<a3<<a3<<a3<<a3<<a11<<endl;
				seatrate=(100*sum1/24);
				cout<<endl;
				cout<<" Occupancy rate: "<<seatrate<<"%"<<"      "<<"Total Seats Available: "<<24-sum1<<endl;

		}

}
seatrate=(100*sum1/24);

Integer arithmetic.
The result of 100*sum1/24 will be an int, from then on it doesn't matter if you store it in a double.

Solution: at least one of the elements in that expression must be of type double.

1
2
3
seatrate = (100.0 * sum1 / 24); // or
seatrate = (100 * static_cast<double> (sum1) / 24); // or
seatrate = (100 * sum1 / 24.0);

Problem 1. Why I entered 3 seat number the program only update 1 seat number.


Because you're only passing back one row and one column in the arguments to getdata1:

void getdata1(char &row, int &col)

row stores a single char, and col stores a single char.

On each iteration of the loop, you overwrite the contents of row and char with the most recent value entered by the user.
thx for your help Catfish4. MikeyBoy is there any solution or hint to overcome this problem ?
MikeyBoy is there any solution or hint to overcome this problem ?
Sure... store your values in some kind of container (e.g. a std::vector), and pass those back as the arguments to the function, instead of single integers.
issit possible using array as a container? since i hvnt learn vector yet.
You could use an array, yes. But, honestly, I'd advise you to take a bit of time to learn how to use vectors. They're much safer and more convenient to use. The sooner you get used to them and get into the habit of using them, instead of arrays, the better off you'll be :)
Topic archived. No new replies allowed.