import javax.swing.JOptionPane;

public class Finance
{
	public static void main(String[]args)
	{
		boolean Access = false;
		String studentName = JOptionPane.showInputDialog(null, "Enter in your name: ");
		//String current = JOptionPane.showInputDialog(null, "Enter your password: ");
		//double currentBalance = Double.parseDouble(current);
	
		Account newAccount = new Account(studentName); //Gains access to Account class
		
		
		JOptionPane.showMessageDialog(null, newAccount.toString());
	}
}

class Account
{		
	//Declared Variables
	String accountName;
	private boolean error = false;
	
	//Constructor
	Account()
	{
	}
	Account(String Name)
	{		
		accountName = Name;
	}	
	public String getAccount()
	{
		return accountName;
	}	
	boolean falseAccount()
	{
		if(accountName == "keenan")
		{
			error = true;
			return true;			
		}
		else
		{
			error = false;
			return false;
		}
	}	
	
	public String toString()
	{
		if(falseAccount() == true)
		{
			return "\nAccess Granted. Welcome " + accountName;
		}
		else
		{
			return "\nAccess Denied. " + accountName + " is not on the list";
		}
	}
}

It prints out the opposite of what is needed, and also is this a clean way to write code still? I'm seeing many new ways of writing now.

at line 39 use .equals() in comparing strings like so

if( accountName.equals("keenan") )

Edited 4 Years Ago by zeroliken: n/a

Sigh... The the little things we make mistakes on..
Thank you, zeroliken.

This question has already been answered. Start a new discussion instead.