Please help me
Mar 14, 2012 at 8:19pm UTC
I am a little new to this programming stuff, so take it easy on me.
I am trying to learn simple arrays, and functions so i made a dumb program up that is like a debit machine for 5 people :P
i keep getting this error though:
1>------ Rebuild All started: Project: debit, Configuration: Debug Win32 ------
1>Build started 14/03/2012 4:17:46 PM.
1>_PrepareForClean:
1> Deleting file "Debug\debit.lastbuildstate".
1>InitializeBuildStatus:
1> Touching "Debug\debit.unsuccessfulbuild".
1>ClCompile:
1> debit.cpp
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>D:\My Documents\Visual Studio 2010\Projects\debit\Debug\debit.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.59
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
________________________________________________________________________________
Here is my program:
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
#include <iostream>
using namespace std;
int pins (int account)
{
int pin_number[] = {1234, 2345, 3456, 4567, 5678};
return pin_number[account - 1];
}
bool check_pin (int pin)
{
int real_pin = pin;
int pin_attempt;
cout << "Please enter your pin: " << endl;
cin >> pin_attempt;
if (pin_attempt == real_pin)
{
return true ;
}
else
{
cout << "FUCK OFF YOU DAMN THEIF" << endl;
}
return 1;
}
double balances (int account)
{
double balance[] = {5000.00, 2000.00, 850.00, 350.00, 5.16};
return balance[account - 1];
}
double withdraw (double & balance, double total)
{
const double PENALTY = 10;
if (balance < total)
{
cout << "Your account has innsuficient funds and a $10 penalty has been deducted." << endl;
balance = balance - PENALTY;
cout << "Your current account balance is now: $" << balance << endl;
return balance;
}
else
{
balance = balance - total;
return balance;
}
}
int main()
{
int account;
for (int j = 0; j > 0; j++)
{
cout << "Please enter your account number: " << endl;
cin >> account;
int pin = pins(account);
bool result = check_pin(pin);
double balance;
if (result)
{
balance = balances(account);
}
double cost;
double total;
const double TAX = 1.15;
cout << "Please enter the cost of the product " << endl;
cin >> cost;
total = cost * TAX;
balance = withdraw(balance, total);
cout << "ACCEPTED! Your purchase has been processed and your current account balance is: $" << balance << ". Thank you for shopping here! Enjoy your day!" << endl << endl << endl;
return 0;
}
}
Thanks for your help and time!
Last edited on Mar 14, 2012 at 10:12pm UTC
Mar 14, 2012 at 8:34pm UTC
I think that the problem is that your project is not a console application. If you are using MS VC++ then you should select new project as a console application.
Mar 14, 2012 at 9:47pm UTC
Yeah that was the original problem! Thanks for your help.
My program now compiles, but there is no output. i simply get the "Press any key to continue" command.
Does anyone have a solution?
Mar 15, 2012 at 12:44am UTC
for (int j = 0; j > 0; j++)
the loop in main never executes.
Topic archived. No new replies allowed.