Charge Account Validator Modification
May 12, 2014
I had to write a charge account validator program that compared the number you entered to a list of numbers using the array method. Now I have to modify the program to do the same thing but from a .txt file instead. I understand it is saying that AccountNumbers.txt does not exist, but I am positive that it does.
Here is my error message:
run:
Exception in thread "main" java.io.FileNotFoundException: AccountNumber.txt (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.util.Scanner.<init>(Scanner.java:656)
at validatormodtest.ValidatorMod.<init>(ValidatorMod.java:24)
at validatormodtest.ValidatorModTest.main(ValidatorModTest.java:24)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Here is my code:
ValidatorModTest.java
package validatormodtest;
import java.util.Scanner;
import java.io.*;
public class ValidatorModTest {
[Code] ...
Attached File(s)
AccountNumbers.txt (159bytes)
View Replies
ADVERTISEMENT
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
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
Apr 3, 2015
I'm fairly new to java, and is just building small programs to get the feel for the language. How I can improve this code.
import java.util.Set;
import java.util.HashSet;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
enum DateValidator {
DDMMYYYY(0, 2, 4),
MMDDYYYY(2, 0, 4),
YYYYMMDD(6, 4, 0);
[Code] ....
View Replies
View Related
Mar 27, 2014
My code is like this,
for(Iterator iterator = list.iterator(); iterator.hasNext();) {
String string = iterator.next().toString();
list.add(string + "Hello");
iterator.remove();
}
Its a simple program. I've list with some names as values like,
Ram, Sham, Bham, Bhim, Suraj.
Now, I want to add "Hello" to each name by running above code. While iterating, first time I get Ram, I want to add "Hello" to Ram and add to list as "Ram Hello" also I want to remove original Value i.e "Ram". When I run above code it is giving Concurrent Modification Exception. How to do this?
View Replies
View Related
Apr 7, 2014
I'm writing an IRC server in Java, however when a client tries to connect I get a ConcurrentModificationException trying to add them to an ArrayList. My code is Here: [URL]
I don't understand why I am getting a ConcurrentModificationException or what one is.
View Replies
View Related
Aug 18, 2014
I am having trouble with a jTable that I am using. I have set the listeners of the cells to save the information of the entire table every time they are modified, but run into the problem that the last modified cell does will not reflect its most recent value. The value will display visually, but not show up when I try to read from the cell. I have tried wrapping the saveProcGuide() call in swing's invokelater, but to no avail. I have marked the area where the problem becomes evident (values returned do not match those present in the visible table object). Below is the offending code:
// This is where I set up the listeners
private void addProcGuideWithValues() {
procTableModel.addRow(new Object[]{"", ""});
// document listener to be fed into editor/renderers for cells...
DocumentListener docuListener = new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
saveProcGuide();
[Code] .....
View Replies
View Related
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
Apr 13, 2014
I need to make a program that uses an object to calculate balance
import java.util.Date;
public class Account {
/** Setup Default Variables */
private int id = 0;
private double balance = 0;
private double annualInterestRate = 0;
[Code] ....
View Replies
View Related
Feb 25, 2015
This is my assignment "Add two radio buttons so that the user can select the gender (male or female). Also extend your Account class so that it contains the gender information as well. When the user presses "Submit", your program should read the entered data and create an Account object that captures all the data in your interface." How would I add RadioButton to this?
This is my code so far
/**
* Orchestration class for Account
*/
public class AccountDemo {
public static int numOfAccount = 3;
public static void main(String [] args) {
Account Accountholder1,Accountholder2,Accountholder3;
[Code] ....
View Replies
View Related
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
Feb 26, 2015
Add two radio buttons so that the user can select the gender (male or female). Also extend your Account class so that it contains the gender information as well. When the user presses “Submit”, your program should read the entered data and create an Account object that captures all the data in your interface. This is my code, what would I need to add in order to make a RadioButton?
/**
* Orchestration class for Account
*/
public class AccountDemo {
public static int numOfAccount = 3;
public static void main(String [] args) {
Account Accountholder1,Accountholder2,Accountholder3;
[Code] ....
View Replies
View Related
May 11, 2014
This program asks the user for their starting balance, number of deposits, and number of withdrawals for a month
Now, if the number of withdrawals goes over 4, it has to include a service charge of 1.00 for every withdrawal that was more than 4 (This works fine so far)
The problem I am having is this:
The subclass part of this program is supposed to determine whether an account is below 25. If it is, it should make the account inactive, until the account is 25 or more. The subclass will have a method that will override the super's setWithdrawal mehtod to make sure that no withdrawals will be made until that balance is 25 or more.
Then the setDeposit method in the subclass will also override the super's setDeposit method and make sure that the account is not inactive before any deposits are made. If the account was determined to be inactive at that time and the deposits that were added make it jump to 25 or more, than the account should be changed to active and then be allowed to call the super's method to set the deposit.
So...the issue I am having is the subclass trying to determine whether the balance is under 25 before it calls the super's version of that method where it will allow the user to take money out and when making deposits where it will determine if the account was inactive first before make it active while the deposits raise to 25 or above.
Here is my super class:
// This is an abstract class that will be used for its child class BankAccount
public abstract class BankAccount {
private double balance; // To hold the account balance for the month
private int numDeposit; // To hold the number of deposits for the month
protected int numWithdrawal; // To hold the number of withdrawals for the month
private double annualIR; // To hold the annual interest rate for the month
protected double monthlyServCharge; // To hold any service charge for the month
private double monthlyInterest;
[Code] .....
View Replies
View Related
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
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
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
Feb 6, 2015
I need to check the existence of email accounts before sending them mails to avoid going to a blacklist for sending to non real accounts.
I was thinking on (SSL)Sockets and smtp commands but I cant get it to work properly I am shooting in the dark here...
I have a JAVA application that sends mail to the people that buy certain things but the information quality is bad, so I must check if the mail exists before sending the mail....
View Replies
View Related
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
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
View Related
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
Apr 7, 2014
I'm doing this project in JSP.net, with html. and in one of the web pages, what I'm doing is that, a person is transferring an amount to someone else, and if the transfer amount is more than the account balance, then he cannot transfer. else, save details in a table.
Here's the code I've used
<%
String t1=request.getParameter("text1");
String t2=request.getParameter("text2");
java.util.Date date1 = new java.util.Date();
SimpleDateFormat ft = new SimpleDateFormat ("dd/MM/yyyy");
int tamt = Integer.parseInt(t2);
int bamt = 0;
[Code] .....
But when i enter the fields and click the submit button in the form, to save it in the table, i get the error:
"org.apache.jasper.JasperException: java.lang.NumberFormatException: null"
(I've attached a screen shot of the error) : NumberFormatException.bmp (750.98K)
What does this mean? how do i find the line in the code that has the error?
View Replies
View Related
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
Mar 31, 2014
I want to write an app that declares a class Person(String name, int age), and an Account class, Account(int code, double balance).But, additionally, every Person has at most 3 accounts, and each account has a Peron associated with it.
my code so far...
public class Person {
private String name;
private int age;
private Account[] accounts;
private int numOfAccounts;
public Person(String name,int age){
this.name=name;
[code]....
My problem is:When I make data input for a person, and additionally I want to read data for the account(s) that this rerson has, what code should I write to create a new Account object as account[numOfAccounts].And, what is the code to assign an owner to a new created Account object?
There exists a relationship between the two classes, but I cannot find the way to implement this relation....
View Replies
View Related
Oct 5, 2014
I'm having some difficulty with my bank account project. I'm supposed to create a menu where the user can create a new account, withdraw, deposit, view their balance, and exit. There's issues with the account creation.
Here's my necessitated class below: BankAccount, TestBankAccount, SavingsAccount, CurrentAccount, and Bank
/*---------------------------------------------------
Plagiarism Statement
I certify that this assignment is my own work and that I have not copied in part or whole or otherwise plagiarized the work of other students and/or persons.
----------------------------------------------------------*/
package BankAccount;
import java.util.Date;
import java.util.Random;
//Project 3
public class BankAccount {
protected static int accountID;
[code]....
View Replies
View Related