Code:
#include "data2.h"
int main()
{
clrscr();
{
if(V.p_bal == 0)
{
cout<<"Please input a starting balance.\n";
cout<<">";
cin>>V.p_bal;
clrscr();
}
else
if(V.p_bal != 0)
{
cout<<"Your previous balance was "<<V.p_bal<<"\n";
cout<<"\nPress Enter to continue...\n";
cin.get();
cin.get();
clrscr();
}
char exit = 'n';
while(exit != 'y')
{
MENU();
switch(V.sel)
{
case 0 :
exit = 'y';
break;
case 1 :
cout<<"Insert a value to be added to "<<V.p_bal<<"\n";
cout<<">";
cin>>V.add;
clrscr();
V.total = V.p_bal + V.add;
cout<<"Your new total is "<<V.total<<"\n";
cout<<"\nPress any key to continue...";
cin.get();
cin.get();
break;
case 2 :
cout<<"Insert a value to be subtracted from "<<V.p_bal<<"\n";
cout<<">";
cin>>V.sub;
clrscr();
V.total = V.p_bal - V.sub;
cout<<"Your new total is "<<V.total<<"\n";
cout<<"\n Press any key to continue...";
cin.get();
cin.get();
break;
}
clrscr();
V.p_bal = V.total;
}
}
V.p_bal = V.total;
}
void MENU()
{
cout<<"\t..[]-MENU-[]..\n";
cout<<"\n(1) Add to "<<V.p_bal<<".\n";
cout<<"(2) Subtract from "<<V.p_bal<<".\n";
cout<<"(0) Exit\n";
cin>>V.sel;
}
void clrscr()
{
COORD coordScreen = { 0, 0 };
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);
}
This is my main file.... if you need me to post the header file then i can.
And i realize some of that stuff isn't needed.... i will clean it up once i have it complete, it looks like that because i was prac dif code.
But any tips would be awsome, i just started learnin this 3 days ago.