Extremely Simple Problem... Im new. (illegal start of expression)
Taking a java class, and have a online friend who has been tutoring me, who normally answers my questions... But isnt online now... So thought Id give this forum a try for some help maybe... I have no idea what I am doing wrong here...
Code Java:
/**
* Lesson 3
*
* @author
* @version
*/
//Create a class called BankAccount
public class BankAccount
{
// The class should have the following fields:
private int accountNo;
private float balance;
private String firstName, lastName;
// The class should have ONE constructor with two String parameters: first and last
public BankAccount(String first, String last){
balance = 100;
accountNo = 12345;
firstName = first;
lastName = last;
}
// Create a mutator method called deposit...
public void deposit(int depositAmount)
{
if(depositAmount < 0) {
System.out.println("Invalid deposit amount");
}
else {
balance = balance + depositAmount;
}
// Create a mutator method called withdraw...
public void withdraw(int withdrawAmount)
{
if(withdrawAmount < 0) {
System.out.println("Invalid deposit amount");
}
else if (withdrawAmount > balance) {
System.out.println("Insufficient funds to complete withdraw request");
}
else {
balance = balance - withdrawAmount;
}
// Create a mutator method called changeFirst...
public void changeFirst(String first)
{
firstName = first;
System.out.println("First name has been changed to: " + firstName);
}
// Create a mutator method called changeLast...
public void changeLast(String last)
{
lastName = last;
System.out.println("Last name has been changed to: " + lastName);
}
// Create the accessor method showBal...
public void showBal()
{
System.out.println(balance);
}
// Create the accessor method accInfo...
public void accInto()
{
System.out.println("Account No: " + accountNo);
System.out.println("Account Owner: " + firstName + " " + lastName);
System.out.println("Account Balance: " + balance);
}
Re: Extremely Simple Problem... Im new. (illegal start of expression)
Accidental douple post - sorry I removed this while HW was dealing to the other one... Hopefully sorted now.
Re: Extremely Simple Problem... Im new. (illegal start of expression)
Sorry about that, new to the forums, and the first time I didnt see that it said my post had to be approved by a mod, so I thought I just did something wrong and it didnt post... Plus my first one did not use the java code highlight option like I was supposed to.
--- Update ---
God damn brackets. Figured it out.
Re: Extremely Simple Problem... Im new. (illegal start of expression)
Hi Zea, welcome to the forum!
The software *sometimes* holds posts pending approval. It shouldn't keep happening.
I was unable yesterday to actually read the post fully, and so couldn't really help. But I'm glad you've got the brackets sorted out (The usual cause of that error)