TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
James major
NA
6
4.4k
help with a bank program
Mar 25 2012 2:35 AM
i had this for homework but i have since turned it in. now this is program that allows for a person to enter in an amount that they are going to deposit and then click on the deposit button. what happens then is that the amount is shown at the bottom. how the problem i ran into and this is both on the checking and the savings side is that i was unable to subtract amounts. while i have turned in this assignment cause this was given as a challenge i still want to get this working properly. now i took the checking and savings classes and saved them as dll's. here are the codes that you will need to make this work. this is just for me to learn and understand where i am making my mistakes. the more i learn the better i will be.
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using checkingAccount;
namespace BankAccount
{
public partial class Form1 : Form
{
double depCheck;
double witCheck;
double checkingBalance;
double currentBalance;
double checkAmount;
double takeAmount;
double depSavings;
double witSavings;
double savingsBalance;
double savingsAmount;
public Form1()
{
InitializeComponent();
}
private void chkDepost_Click(object sender, EventArgs e)
{
checkAmount = Convert.ToInt32(chkDeposit.Text);
depCheck = checkingAccount.checkingAccount.depositChecking(checkingBalance, checkAmount);
currentBalance = currentBalance + depCheck;
chkBalance.Text = Convert.ToString(currentBalance);
}
private void chkWithdraw_Click(object sender, EventArgs e)
{
takeAmount = Convert.ToInt32(chkWithdrawn.Text);
witCheck = checkingAccount.checkingAccount.withdrawlChecking(checkingBalance, takeAmount);
currentBalance = currentBalance - witCheck;
chkBalance.Text = Convert.ToString(currentBalance);
}
private void balDeposit_Click(object sender, EventArgs e)
{
takeAmount = Convert.ToInt32(savDeposit.Text);
depSavings = savingsAccount.Class1.depositSavings(savingsBalance, takeAmount);
currentBalance = currentBalance + depSavings;
savBalance.Text = Convert.ToString(currentBalance);
}
private void savWithdraw_Click(object sender, EventArgs e)
{
takeAmount = Convert.ToInt32(saveWithdraw.Text);
witSavings = savingsAccount.Class1.withdrawlSavings(savingsBalance, takeAmount);
currentBalance = currentBalance - witSavings;
savBalance.Text = Convert.ToString(currentBalance);
}
}
}
program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using BankAccount;
namespace banking_account
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
CheckingAccount.cs (this is one of the dll's)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace checkingAccount
{
public class checkingAccount
{
public static double depositChecking(double currentBalance, double customerDeposit)
{
return currentBalance + customerDeposit;
}
public static double withdrawlChecking(double currentBalance, double customerDeposit)
{
return currentBalance - customerDeposit;
}
}
}
SavingsAccount.cs (this is the second dll)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace savingsAccount
{
public class Class1
{
public static double depositSavings(double currentBalance, double customerDeposit)
{
return currentBalance + customerDeposit;
}
public static double withdrawlSavings(double currentBalance, double customerDeposit)
{
return currentBalance - customerDeposit;
}
}
}
Reply
Answers (
3
)
C# and C++
dropdownlist problem