//flex table opened by JP

Click to See Complete Forum and Search --> : C++ program


eagle1
08-26-2000, 11:38 AM
To anyone who wants to try these simple programs and post them.

1. Make a program that can make a sum of indefinite odd numbers. If you input an even number, you need to indicate that the entry is incorrect and to try again.

2. Simulate an ATM machine. Do menus, use classes, etc. It will make deposits or withdrawals, show balance, newbalance, etc. Everything an ATM machine does.

These programs are easy to do I just want to look at the different approaches of anyone who tries them. Like, for example: The ATM machine can be done by using classes, the switch command or only a bunch of If-Else statements.
Thanks for your time!! and even if you don't post them, try them!

Eagle1 signing off.....

jeana
08-26-2000, 11:55 AM
If it weren't summer, I'd guess that somebody is trying to get us to do their homework. To ward off potential flames, eagle1, you might be best off posting your own attempts at this problem to show us that you have tried and are capable of solving this problem, or give a good reason why you think it might be of general interest to the forum members.

-J

Szech
08-27-2000, 12:00 AM
Well, I've had enough programming for six quarters already, but here's my sketch of the program if I were to code it:

1:
I made this program for my class last quarter! I used assembly functions for the actual computations, and a dynamic array for storing doubles that had sets of eight digits each slot. The assembly add function has sub-functions that: 1) Take one set of eight and adds it to another set. 2) Takes one pair of numbers and adds them. Call the assembly function on each set of eight, and have some method of carrying. I got a B-... !@#$%@#%!!!

2:
Class userList would be a hash table or a AVL tree of class users. It would have functions: findUser( char * name ), displaystats( user t ).

Class user would have a character string for the person's name, a double for the amount of money in the person's account, and perhaps another double for an account number or something. It would have functions: deposit( double amount ), withdraw( double amount), and showBalance(). Withdraw and deposit would have to check that the amount isn't negative, and withdraw would have to check that there is enough money in the account.

eagle1
08-27-2000, 12:07 AM
Whhoooaa.! Hey guys.. I just wanted (like I said) to see the different approaches. I'm a begginer at all of this so I just wanted to keep on learning new ways to do things. Since I want to avoid any possible "flames" I might get, right below I'm going to paste my ATM program. It is in spanish (my primary language). OK , here we go:

//Angel Melendez Guzman
//This program functions as an ATM machine


#include <iostream.h>
int main ()
{


char transaccion, cuenta;
int balancec = 500, balancea = 1000, retiro, deposito;
int i;
cout<<"Oprima 0 para terminar o introduzca su tarjeta y presione 1.\n";
cin>>i;
while(i==1)
{
cout<<"Bienvenidos a la cajera automatica"<<endl;
cout<<" Angel D. Melendez "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<"Presione la tecla apropiada para realizar"<<endl;
cout<<" su transaccion: "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;

cout<<"(B) para ver su balance"<<endl;
cout<<"(D) para depositar"<<endl;
cout<<"(R) para retirar"<<endl;
cout<<" "<<endl;
cout<<" "<<endl;

cin >> transaccion;

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);




switch(transaccion)
{

case 'D':
case 'd': cout<<"Desea depositar a su cuenta de ahorros o cheques?"<<endl;
cout<<"(A) para ver su cuenta de ahorros"<<endl;
cout<<"(C) para ver su cuenta de cheques"<<endl;
cin >> cuenta;
if ((cuenta=='A') | | (cuenta=='a'))
{

cout<<"El balance en su cuenta de ahorros es: " <<balancea<<endl;
cout<<"Cuanto dinero desea depositar?"<<endl;
cin >> deposito;
balancea=balancea + deposito;
cout<<"El nuevo balance en su cuenta de ahorros es de: "<<balancea<<endl;
}
else if ((cuenta=='C') | | (cuenta=='c'))
{

cout<<"El balance en su cuenta de cheques es: "<<balancec<<endl;
cout<<"Cuanto dinero desea depositar?"<<endl;
cin >> deposito;
balancec=balancec + deposito;
cout<<"El nuevo balance en su cuenta de cheques es de: "<<balancec<<endl;
}
break;

case 'R':
case 'r': cout<<"Desea retirar de su cuenta de ahorros o cheques?"<<endl;
cout<<"(A) para ver su cuenta de ahorros"<<endl;
cout<<"(C) para ver su cuenta de cheques"<<endl;
cin >> cuenta;

if ((cuenta=='A') | | (cuenta=='a'))
{

cout<<"El balance en su cuenta de ahorros es: " <<balancea<<endl;
cout<<"Cuanto dinero desea retirar?"<<endl;
cin >> retiro;
if (retiro > balancea)
cout<<"No hay suficientes fondos"<<endl;
else
{
balancea=balancea - retiro;
cout<<"El nuevo balance en su cuenta de ahorros es de: "<<balancea<<endl;
}
}
else
if ((cuenta=='C') | | (cuenta=='c'))
{

cout<<"El balance en su cuenta de cheques es: "<<balancec<<endl;
cout<<"Cuanto dinero desea retirar?"<<endl;
cin >> retiro;
if (retiro > balancec)
cout<<"No hay suficientes fondos"<<endl;
else
{
balancec=balancec - retiro;
cout<<"El nuevo balance en su cuenta de cheques es de: "<<balancec<<endl;
}
}
break;


case 'B':
case 'b':
cout<<"Desea ver el balance en su cuenta de ahorros o de cheques?"<<endl;
cout<<"(A) para ver su cuenta de ahorros"<<endl;
cout<<"(C) para ver su cuenta de cheques"<<endl;
cin >> cuenta;

if ((cuenta=='A') | | (cuenta=='a'))


cout<<"El balance en su cuenta de ahorros es: " <<balancea<<endl;


else if ((cuenta=='C') | | (cuenta=='c'))


cout<<"El balance en su cuenta de cheques es: "<<balancec<<endl;


break;

default:cout<<"Error en la entrada"<<endl;
}

cout<<"Oprima 0 para terminar o presione 1 si desea realizar otra transaccion.\n";
cin>>i;
}


return 0;

}

eagle1
08-27-2000, 08:41 AM
Oppppss..!! It seems Socal move this thread..ok.. soooooooo


go upppp !!!!!
/ \
|
|
|

qball
08-28-2000, 11:07 AM
I would hardly quantify these as simple. Simple is "hello world". For example, code tic-tac-toe. Seems simple but is rather more involved.


Make a program that can make a sum of indefinite odd numbers.


void main()
{
cout<<"infinity";
}

The question is ambiguous. Indefinite odd numbers implies not defined. The more I look at it, the less I understand the question.

For the ATM proggy, where are you storing persistent information, like my balance?