|
-
February 28th, 2011, 07:37 PM
#1
C# Program ??
I need help looping this program as well as storing and updating the "new balance" of the acct. after transactions have been made.
This is what I have so far:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class Bank //name of class
{
public void A()//selection
{
Console.WriteLine("\nWhat would you like to do: \n \nDeposit - Press 1\n \nWithdrawl - Press 2\n \nShow Balance - Press 3");
Console.WriteLine("\nPlease Enter A Number");
}
public void B()//deposit
{
double z = 1000;
double b;
double c;
Console.WriteLine("\nYour balance is {0:C}", z);
Console.WriteLine("\nEnter deposit amount");
b = Convert.ToDouble(Console.ReadLine());
c = z + b;
Console.WriteLine("\nYour new balance is {0:C}", c);
}
public void C()//withdrawl
{
double z = 1000;
double b;
double c;
Console.WriteLine("\nYour balance is {0:C}", z);
Console.WriteLine("\nEnter withdrawl amount");
b = Convert.ToDouble(Console.ReadLine());
c = z - b;
Console.WriteLine("\nYour new balance is {0:C}", c);
}
public void D()//show bal.
{
double z = 1000;
Console.WriteLine("\nYour balance is {0:C}", z);
}
}
class Program
{
static void Main(string[] args)
{
int a = 9999;
int x;
int s;//user selection
int g;
Bank myBank = new Bank();//creating the object
Console.WriteLine(a);
Console.WriteLine("\nWelcome to Boatman's Bank! Please enter your 4 digit PIN #");
x = Convert.ToInt16(Console.ReadLine());
if (x != a)
{
Console.WriteLine("Incorrect Pin..Please enter your 4 digit PIN #");
x = Convert.ToInt32(Console.ReadLine());
if (x != a)
{
Console.WriteLine("Incorrect Pin..Please enter your 4 digit PIN #");
x = Convert.ToInt32(Console.ReadLine());
if (x != a)
{
Console.WriteLine("Third Incorrect Pin..Access DENIED!");
Console.ReadLine();
}
else
{
myBank.A();
s = Convert.ToInt32(Console.ReadLine());
switch (s)
{
case 1:
myBank.B();
Console.ReadLine();
break;
case 2:
myBank.C();
Console.ReadLine();
break;
case 3:
myBank.D();
Console.ReadLine();
break;
}
}
}
else
{
myBank.A();
s = Convert.ToInt32(Console.ReadLine());
switch (s)
{
case 1:
myBank.B();
Console.ReadLine();
break;
case 2:
myBank.C();
Console.ReadLine();
break;
case 3:
myBank.D();
Console.ReadLine();
break;
}
}
}
else
{
myBank.A();
s = Convert.ToInt32(Console.ReadLine());
switch (s)
{
case 1:
myBank.B();
Console.ReadLine();
break;
case 2:
myBank.C();
Console.ReadLine();
break;
case 3:
myBank.D();
Console.ReadLine();
break;
}
}
Console.WriteLine("\nIf you would like to make another transaction: Press 0");
Console.WriteLine("\nIf you're done banking: Press 5");
g = Convert.ToInt16(Console.ReadLine());
while (g != 5)
{
myBank.A();
s = Convert.ToInt32(Console.ReadLine());
switch (s)
{
case 1:
myBank.B();
Console.ReadLine();
break;
case 2:
myBank.C();
Console.ReadLine();
break;
case 3:
myBank.D();
Console.ReadLine();
break;
}
Console.WriteLine("\nIf you would like to make another transaction: Press 0");
Console.WriteLine("\nIf you're done banking: Press 5");
g = Convert.ToInt16(Console.ReadLine());
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|