Need help with C++ program please help!

Need help with C++ program please help!?
I'm having problems with this program, if you run it more than one time the hst total is way wrong! Can someone please help me? The ISBN numbers to test with are 11110, 12221, 13332, 24443, 25554.
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include <iostream>
#include <process.h>
#include <iomanip>
#include <conio.h>
#include <string>
#include <stdio.h>
#include <ctype.h>
#include <windows.h>

using namespace std;

void gotoxy(int x, int y)
{
COORD coord;
coord.X = x; //column coordinate
coord.Y = y; //row coordinate
SetConsoleCursorPosition(GetStdHandle(… coord);
}

void clrscr(int x, int y)
{
COORD coordScreen = { x, y };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '),
dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes,
dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
}

int main()
{
int i, qty, y;
float retail[5] = {155.95, 116.75, 126.50, 125.75, 138.99}, total, pretotal,
tax, aftertotal;
string book_title[5] = {"Binary Kibbles and Bits", "Underwater Googles", "Vitamin C++",
"Surf and Turf the Web", "Java-lin: Olympic Favourite"},
isbn[5] = {"11110", "12221", "13332", "24443", "25554"},
isbn_num = "0";

bool valid=true;
char runagain='y';


while(runagain=='y')
{
clrscr(0,0);
runagain='y';
total=0;
pretaxtotal=0;
aftertotal=0;
qty=0;
tax=.13;
y=3;

valid=true;

gotoxy(5,2);
cout << "ISBN";

gotoxy(12,2);
cout << "Title";

gotoxy(40,2);
cout << "Price";

gotoxy(50,2);
cout << "Qty";

gotoxy(57,2);
cout << "Total";

cout << fixed;
cout.precision(2);

do
{
isbn_num="0";

gotoxy(5,y);
cin >> isbn_num;

for(i=0;i<5;i++)
{
if(isbn_num==isbn[i])
{

gotoxy(12,y);
cout << book_title[i];

gotoxy(40,y);
cout << "$"<<retail[i]<<"";

gotoxy(50,y);
cin >> qty;

total=retail[i]*qty;

pretaxtotal=pretotal+total;

gotoxy(57,y);

cout << "$"<<total<<"";
y++;
i=0;

runagain = getch();
if(runagain=='t')
{
valid=false;
break;
}

valid=true;
break;
}
}
if(i==5)
{

clrscr(5,y);
gotoxy(12,y);
cout << "Invalid ISBN";

continue;
}

if(y>7)
{
valid=false;
break;
}


while(valid==true)
{
tax=hst*pretaxtotal;

aftertotal=tax+prepretaxtotal;

gotoxy(40,y+5);
cout << "PreTax Total";

gotoxy(57,y+5);
cout << "$"<<pretaxtotal<<endl;

gotoxy(40,y+6);
cout << "Hst(13%)";

gotoxy(57,y+6);
cout <<"$"<< hst<<endl;


gotoxy(40,y+7);
cout << "After Tax Total";

gotoxy(57,y+7);
cout << "$"<<aftertotal<<endl;

gotoxy(5,y+10);
cout << "Would you like to enter another purchase? (y/n) ";
cin >> runagain;

}

return(0);
}
Please indent your code.
¿Could you provide a minimal example? (without all that interface things)
Topic archived. No new replies allowed.