Bank Account Program - Processing User Input

Oct 28, 2014

So the assignment is as follows. Develop a new class called BankAccount. A bank account has the owner's name and balance. Be sure to include a constructor that allows the client to supply the owner's name and initial balance. A bank account needs - accessors for the name and balance, mutators for making deposits and withdrawals. I have the following code :

import java.util.Scanner;
public class BankAccount{
public static void main(String [] args){
Scanner reader = new Scanner(System.in);
double name;
double balance;
double deposit;
double withdrawl;

[Code] ....

I am having trouble with my if statements. I don't know how to link the number 1 & 2 keys to deposit and withdrawal actions. Plus I am supposed to have a while loop yet don't know how to implement this so that the while loop will ask the user if they would like to make another transaction after either depositing or withdrawing.

View Replies


ADVERTISEMENT

Create Account Object And Allow User To Input Account ID

Nov 10, 2014

How to write a driver program, this my code I have :

import java.util.Date;
public class myAccount {
public static void main(String[] args) {
//create an instance object of class Stock
Account myAccount = new Account(012233445566, 20000.00, 0.045);

[Code] ......

View Replies View Related

GUI Bank Account Sorter

Apr 26, 2015

I have an assignment in which I have to:

1. Create a bank file with at least 10 records that include an id#, balance, and last name
2. Create another file that will read these records and then create an array of Bank Account objects
3. Create checkboxes that allow the user to select how they want the data sorted
4. List the total number of accounts at the bottom of the GUI

I've created the file no problem that actually writes the ten records. I was able to have the files be read sequentially with System.out.println(), but I can't figure out how to convert these into an array of Bank Account objects and have them show up in a scroll pane. I tried using string builder and array builder, but I couldn't figure out how to turn them into components. I then tried making an Account class to have them be sorted with comparators, but I had the same problem of actually getting them into the scroll pane. Also, as soon as I added in those methods for the GUI, the while loop wouldn't display the array information in system.out.println. Here is my code for the GUI that doesn't display anything with println ...

import java.nio.file.*;
import java.io.*;
import java.nio.file.attribute.*;
import static java.nio.file.StandardOpenOption.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

[Code] .....

View Replies View Related

Bank Account With Abstraction

May 25, 2014

I'm working on this weeks assignment and I've gotten stuck on passing information from one class to another. We are working with abstract classes this week, and the BankAccount class is the Abstract class that is extended by the CheckingAccount and the SavingsAccount classes. The Bank class is where the user inputs his/her information to process the commands. How can I work this to where the instructions are passed from the main in the Bank class to the different Account classes to actually perform the instructions?

BankAccount:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package bankaccount;
abstract class BankAccount {
private final BankAccount acctID;
private int acctBalance = 0;
public BankAccount checking;
public BankAccount savings;

[Code] ....

I can attach a PDF of the instructions if that will provide additional insight to this. I'm sure I'll ask additional questions as we go, but I'm trying to get this to work right and figure out what I'm doing wrong.

View Replies View Related

Bank Account - Printing Out Transactions

Apr 21, 2014

public class BankAccount
{
String name;
int accountID;
double balance;
}
public void setAcct ( String nam, double acctID)

[Code] ....

1. Create a class called BankAccount
a. It will be a generic simple type of BankAccount

2. BankAccount will contain variables to store:
a. the owner/owners of the account
b. an account id
c. it may contain other basic information (up to you)

3. BankAccount will contain methods that will allow you to:
a. Set the account owners information
b. Deposit money
c. Withdraw money
d. Set balances
e. Print out transactions (think more like an atm each time an action is taken it gets printed)

4. BankAccount will contain its own main()
a. At least 2 BankAccount objects will be created and ALL of their methods called .

What to do for the print out transactions

View Replies View Related

Adding AccountID To Bank Account Object

Jul 11, 2014

When I try to print out the account Id for each account object, the id is always 1. But it should be 1,2,3,4,5....all the way to the number of the account generated.My question is am I missing something in the constructor or in the main method?? I am new to programming.The main method create an array of account objects and generate random balances into each account object.

import java.util.Scanner;
public class Bank {
public static void main(String[] args) {
Scanner userInput=new Scanner(System.in);
System.out.print("Enter the number of accounts to generate: ");
int numOfAccount=userInput.nextInt();

[code]....

View Replies View Related

Bank Account With Methods / Inheritance And Overloading

Apr 23, 2014

What I have done wrong

public class BankAccount
{
String name;
int accountID;
double balance;
public void setAccount( String username, int ID, Boolean isJoint)

[Code] ....

View Replies View Related

Bank Account - Balance Must Be A Floating Point Number

Sep 21, 2014

Develop the class “Account” to be used by a bank. The Account class should have a single instance variable “balance”. Remember that balance must be a floating point number. The required methods for the Account class are shown below.

The Account class “debit” method should return a Boolean and should not allow an overdraft. If a withdraw greater than the current balance is attempted, the function should immediately return “false” and do nothing else.

Develop a test class to thoroughly test all aspects of the Account class. DO NOT change the class name or instance variable name given or the required method names as detailed below.

Account
1 constructor with no parameters (default balance to 0)
1 constructor with a balance parameter
setBalance method
getBalance method
credit method
debit method

I have the test class done, I won't need to put that in till later. My main problem is I'm not sure how I'm going to be able to get debit and setBalance to work together with each other.

public class Account
{
protected double balance;
// Constructor to initialize balance
public Account( double amount ) {
balance = amount;

[Code] ....

You can see I'm stressed out by not reading over my code. I already have the "Debit" in use, just have to change it. Which I did.

View Replies View Related

Bank Account Simulation - ResultsModel Cannot Resolve To A Type

Mar 12, 2015

I have serious errors. I am trying to design a Bank Account Simulation. My various codes are as below.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.io.*;
public class Display2 extends JFrame //implements ActionListener

[Code] ....

ERROR: ResultsModel cannot be resolved to a type

View Replies View Related

Java Program That Will Ask A User To Input Grades Until User Inputs Sentinel Value

Apr 9, 2014

Write a java program that will ask a user to input grades until the user inputs the sentinel value -1. The program should test each input to determine whether 0<=grade<=100. If the grade entered is within this range, the program should print "Grade accepted;" if not, the program should print "Invalid input".

View Replies View Related

Program That Takes User Odd Number And Print Prime Numbers Lower Than User Input

Nov 4, 2014

I have been struggling with this program for weeks. This program is supposed to take a user's inputted odd number and then print out all prime numbers lower than that number.

public class PrimeNumber
{
Scanner scan = new Scanner(System.in);
int userNum;
String neg;

public void getUserNum()

[code]...

View Replies View Related

Bank Program For Java - Reading From TXT File?

Oct 7, 2014

I am trying to make a bank program that reads to .txt files, one that has the right format and one that has the wrong format. This is part of my problem I do not know how to do this. I also do not know why my code works if I input "account" rather than "account.txt" which is supposed to be the right thing.

Let me present my code that I have so far:

// File: BankAccount.java
import java.util.Scanner;
import java.io.IOException;
public class BankAccount
{
private int accountNumber;
private double balance;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: How To Do GUI Input Processing After Firing Off SwingWorker

Oct 8, 2014

I am writing a program that solves sudoku puzzles. It has a Swing GUI with a "solve" button. I have written an actionListener class with an actionPerformed method that is invoked when the user presses this button. It is the following:

public void actionPerformed(ActionEvent event) {
try {
worker = new SudokuSolveWorker();
worker.addPropertyChangeListener(this);
worker.execute();
SolveFrame sf = new SolveFrame();
} catch (Exception exc) {
System.out.println(exc.getMessage());
exc.printStackTrace();
}
}

The code creates a worker, a new instance of SudokuSolveWorker. The worker.execute() statement causes the doInBackground() method of this class to be called. This solves the Sudoku. A property change listener "picks up" the result:

public void propertyChange(PropertyChangeEvent event) {
try {
System.out.println("" + javax.swing.SwingUtilities.isEventDispatchThread());
SudokuModel solvedModel = (SudokuModel) worker.get();
} catch (Exception exc) {
System.out.println(exc.getMessage());
exc.printStackTrace();
}
}

As I wrote, this works without freezing up the user interface in the sense that the program seems unstable. However, the user interface does not respond to "commands" (mouse clicks) anymore until the worker thread has finished.

In the first code fragment I create an instance of SolveFrame which is an extension of a JFrame. It is a simple frame with a "cancel" button. It is drawn on the screen, even though it is called after the worker.execute() statement. I'd like the user to be able to click this "cancel" button, after which the solving of the sudoku puzzle should be stopped. However, since the program does not respond to mouse clicks anymore, the "cancel" button cannot be pressed.

View Replies View Related

Program Skipping Over User Input

May 19, 2014

So i'm just toying around with making a simple inventory system, and when i'm trying to get the user's input (first the ID number, then the item name, then the item price) it will take the ID number, output asking for the name (but not take any input for it) and then ask for the item's price. I'm really not sure why it's never happened to me before when getting user input.

This is the input part of my code:

public void getInfoAdd() {
int id;
String name;
double price;
System.out.print("Enter ID: ");
id = sc.nextInt();
System.out.print("Enter item name:");
name = sc.nextLine();
System.out.print("Enter desired price: ");
price = sc.nextInt();
addItem(id, name, price);
}

And this is what it outputs:

Quote
Enter ID: 2
Enter item name:Enter desired price: 40
Successfully added: 2 $40.0

View Replies View Related

Writing A Program To Take Input From User?

Oct 23, 2014

Writing a program to take input from user. This input must be done with numbers only. If the input is a string I would like the program to loop and ask for input again.

double depositCheckingAmount;
do
{
System.out.println("Please insert amount to deposit into checking.");

[Code]....

As you can see my attempt is to use the ! expresssion incase the input does not equal a double. Is there another method I should be using?

View Replies View Related

JSP :: How Bank Sites Throw User To Session Expire Page By Clicking On Browser Refresh / Back Buttons

Jun 20, 2012

I got one task from my manager, regarding browser back button, refresh button. He asks me the web application has to work like Banks site... means if I refresh or click on Back button(Browser's) then it has to throw the user out of session, I checked lot in internet. But I found like only disabling back button of disabling F5 keys like that. But he’s not accepting that.

How to approach for this? Can we throw the user out of session when he clicks on browser back button or refresh button. I think its possible . But i don't know how to implement.

View Replies View Related

How To Get Index Of Array Based On User Inputted Account Number

Sep 25, 2014

In my account driver I am trying to get the user inputted account number to get the account by account number. In my code

System.out.println("Which Account number: "); int account = scan.nextInt();
ac.get(account-1);

This works if my accounts are numbered incrementally starting with one, I want it to match the inputted account number

System.out.println("Account number: "); int num = scan.nextInt();

I am thinking a for loop is probably needed. Here is my code:

public class AccountDriver {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
ArrayList<Account> ac = new ArrayList<>();
boolean more=true;
boolean again=false;

[code]....

View Replies View Related

How To Exit A Java Program If User Input Nothing

Apr 17, 2014

How do i exit a java program is the user input is nothing "",This is my code

Java Code:

import java.util.Scanner;
public class MyQueue<T> implements Queue<T> {
private T[] ringbuffer;
static int capacity = 0;
int mysize = 0;

[code]....

View Replies View Related

Create A Program That Keeps Track Of Information Input By User

Sep 17, 2014

I am new to Java an have to Create a program that keeps track of the following information input by the user: First Name, Last Name, Phone Number, and Age. Now - let's store this in a multidimensional array that will hold 10 of these contacts. So our multidimensional array will need to be 10 rows and 4 columns.You should be able to add and remove contacts in the array.

View Replies View Related

Write A Program That Reads From User Several Lines Of Input

Mar 24, 2014

a. Assume that we have a list of employees' names of a company and their ages. Write a program that reads from the user several lines of input. Each line includes an employee's name and his/her age (as an integer). The program should calculate and print the following:

- The average age of all employees (rounded to 2 decimal places).
- The oldest employee and his/her age.

Hints:

You could assume that the user will insert valid data and at least one employee.
You could assume that the oldest employee is only one person.
User could stop the program via entering the word "end" as an employee's name.

Sample Input and Output: In each line, insert an employee's name and his/her age To halt the program, insert "end" as an employee's name

Adam 30
Tom 41
Ted 45
Karl 30
end

The average age of all employees is 36.50.The oldest employee is Hisham whose age is 45

View Replies View Related

Program For Class To Request User Input For Base Salary

Feb 24, 2014

I had to write a program for class to request user input for base salary, number of years worked, and total sales. Then use the data to find out the employee's paycheck when including a bonus. I have a few issues with the code, as I have one bug, then it won't calculate anything. what I'm missing?

package chapterone;
import java.util.Scanner;
public class Examplelab {
static Scanner console = new Scanner(System.in);
public static void main(String[] args){
double baseSalary;
double noOfServiceYears;
double totalSales;

[Code]....

View Replies View Related

Allow User To Input One Or More Integers And Store Them In Vector For Manipulation Later On In Program

Oct 1, 2014

I'm playing with vectors for the first time... What I'm trying to do is to allow a user to input one or more integers and store them in a vector for manipulation later on in the program... Here's the portion of the program I'm working with:

Java Code:

package com.itse2317;
import java.util.*;
public class VectorTest
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);

[code]...

My question is this: Is there any way to move from inputting integers to printing them, without entering a non-integer (for example, hitting enter)? I looked at the API for the Vector class, and either I'm not thinking about the problem the right way to be able to find an answer, or it's just not there.

View Replies View Related

Quiz Program - Removing Enter Key Space After User Input

Oct 20, 2014

I am writing a short quiz program, and when the user inputs their answer they hit the enter key (the are int). But the last question on my quiz is asking the user to they want to repeat the quiz, but when I run the program, it won't allow me to input any information. I can briefly remember my lecturer saying something about entering in a code after each int the user inputs but I can't remember what it was.

Here is a snippet of my code:

//Question 3
do{
System.out.println("Question 3- What Hollywood actor did Mila Kunis have a baby with recently?");
System.out.println( question3 + ".Ashton Kutcher 2.Bradly Cooper 3.Leonardo Dicaperio h.Get a hint");
answer3 = stdIn.nextInt();
if(answer3 != question3)

[Code] ....

View Replies View Related

Account Class - Account Cannot Be Resolved To A Type

Apr 8, 2014

How to fix the error with the line:

Account account1 = new account(1122, 20000.00);

import java.util.Date;
public class AccountClass {
class Account {
private int id;
private double balance;
private double annualInterestRate;

[Code] ....

I forgot to mention, the error says "account cannot be resolved to a type"

View Replies View Related

Averaging Grades Program - Take Input From User Until They Enter Negative Number

Feb 2, 2015

Ok so I have my program working for the most part. In this program I am supposed to take input from the user until they enter a negative number and that works, the problem is that it doesn't work if I enter a negative number on the first prompt. For example if I enter a 100 it would prompt me again and if I enter a negative number it would quit and give me the average, but if I enter a negative number the first time I am prompted the program just gives me an error. How do I fix that?

import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
public class Application {
public static void main(String [] args){
Scanner input = new Scanner(System.in);
List<Integer> grades;

[Code] ....

View Replies View Related

Retrieving User Input String From Keyboard - Program Errors (try / Catch)

Sep 23, 2014

I need to design, implement, and test a program to input and analyze a name. The program begins by retrieving a user input string from the keyboard. This string is intended to be the user's name. These are the errors we have to search analyze the user input for: No blanks between names firstName and lastName, Non-alphabetic characters in names, Less than two characters in first name, and Less than two characters in last name. Each of these errors must be thrown. All exceptions must be derived from a programmer-defined class called NameException. Each exception should use a detailed message to differentiate among the file types of errors.

This is the format of my NameException class, is the format itself correct? I will fill in the details of each exception I am just wondering if that is how I should set it up.

public class NameException extends Exception {
private String firstName, lastName;
public NoBlanksException(String firstName,String lastName) {
}
public NonAlphabeticalCharactersException(String firstName, String lastName) {

[Code] .....

I was told not to try and catch thrown errors in the main method, would I just create another method in the Driver class to take care of that then?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved