Illegal start of expression errors

I have illegal start of exception error with all of my method could so

Page 1 of 1

1 Replies - 696 Views - Last Post: 04 November 2009 - 12:08 AM Rate Topic: -----

#1 JOEJOE11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-November 09

Illegal start of expression errors

Post icon  Posted 04 November 2009 - 12:01 AM

import java.util.*;
public class CalculatorInterface
{
public static void main (String[] args)
{
Scanner console=new Scanner (System.in);

Client[ ] clients=new Client[0];
int noclients;
int selection;
int selection2;
String Whichclient;
String Filename;

noclients=0;
selection=0;
selection2=0;

System.out.println("Please enter the operation that you wish to perform");
System.out.println("to add a client enter 1");
System.out.println("to delete a client enter 2");
System.out.println("to display a specific client enter 3");
System.out.println("to display all clients enter 4");
System.out.println("to open a client enter 5");
System.out.println("to save a client enter 6");
System.out.println("to exit the program enter 7");
selection=console.nextInt();


while (selection != 1 && selection != 2 && selection != 3 && selection != 4 && selection != 5 && selection != 6 && selection !=7)
{
System.out.println ("Please reenter the operation that you wish to perform");
System.out.println ("to add a client enter 1");
System.out.println("to delete a client enter 2");
System.out.println("to display a specific client enter 3");
System.out.println("to display all clients enter 4");
System.out.println("to open a client from a file enter 5");
System.out.println("to save a client to a file enter 6");
System.out.println("to exit the program enter 7");
selection=console.nextInt();
}

while(selection != 7)
{

if (selection==1)
{
String Name;
double medicare;
double grosssalary;
double netsalary ;
int residentialstatus;
double weeklyexpenses;

medicare=0;
netsalary=0;

System.out.println("Enter Clients Name:");
Name=console.next();
System.out.println("Enter Clients gross salary:");
grosssalary=console.nextDouble();
System.out.println("Enter Clients residential status if the client is a resident enter 1 if not enter 0:");
residentialstatus=console.nextInt();
System.out.println("Enter Clients weekly expenses:");
weeklyexpenses=console.nextDouble();
addclient(Name,medicare,grosssalary,netsalary,residentialstatus,weeklyexpenses);
}

else
if (selection==2)
{
String clienttodelete;
System.out.print(" Please enter the name of the client that you wish to delete");
deleteclient(clienttodelete);
}





else
if (selection==3)
{
System.out.print("please enter the name of the client that you wish to display:");
Whichclient=concole.next;
displayclient(Whichclient);




System.out.println("what do you want to do now?");
System.out.println("to add an account to this client enter 1");
System.out.println("to delete an account enter 2");
System.out.println("to display a specific account enter 3");
System.out.println("to return to the previous menu enter 4:");
selection2=console.nextInt();
while (selection2 != 4)
{

if (selection2==1)
{
double amount;
double rate;
int numberofweeks;

System.out.println("Enter the amount of money that you want to invest per week:");
amount=console.nextDouble();
System.out.println("Enter the interest rate of the investment:");
rate=console.nextDouble();
System.out.println("Enter the number of weeks that you wish to invest money for:");
numberofweeks=console.nextInt();
Client.addaccount(amount,rate,numberofweeks);
}

if (selection2==2)
{
int accounttodelete;
System.out.println("Enter the number of the account that you want to delete:");
accounttodelete=console.nextInt;
Client.deleteaccount(accounttodelete);
}

if (selection2==3)
{
displayaccount();
}

}

}




else
if (selection==4)
{
displayallclients();
}


else
if (selection==5)
{
System.out.print("please enter the name of the file that you wish to open:");
Filename=console.next;
openfile(filename);
}


else
if (selection==6)

{
writefile();
}

}

public void writefile()
{
String Nameofclient;
String File;
int counter;
counter=0;
int residentialstatus;
double grosssalary;
double expenses;
int counter1;
int noaccounts;
double rate;
int weeks;
double amount;


System.out.println("Please enter the name of the Client that you wish to write to a file:");
Nameofclient=console.next;
System.out.println("Please enter the name and type of the file that you wish to write your client to:");
File=console.next;

FileWriter writeclient = new Filewriter (""+File);
PrintWriter writefile = new PrintWriter (writeclient );

while(clients[counter].!Name.equals Nameofclient)
{
counter++;
}

residentialstatus=clients[counter].getresidentialstatus();
grosssalary=clients[counter].getgrosssalary();
expenses=clients[counter].getweeklyexpenses();
noaccounts=clients[counter].getnoaccounts();

grosssalary=grosssalary/52;

writefile.println("Name equals" +Nameofclient);
writefile.println("gross salary equals"+grosssalary);
writefile.println("weekly expenses are"+expenses);
if (residentialstatus == 1)
{
writefile.println("The client is a resident");
}

else
if (residentialstatus != 1)
{
writefile.println("The client is not a resident");
}

while (counter1<noaccounts)
{
rate=Client.getrate(counter1);
noweeks=Client.getnumberofweeks(counter1);
amount=Client.getamount(counter1);
counter1++;
writefile.println("account "+counter1);
writefile.println("rate equals "+rate);
writefile.println("number of weeks money was invested for equals "+noweeks);
writefile.println("amount of money invest per week equals"+amount);
}
}


public void openfile (String Filename)
{
Scanner fileopen = new Scanner(new FileReader(""Filename));
String Skip;
String Firstname;
String Lastname;
double salary;
char residency;
double expenses;
String Checkaccount;
double rate;
int weeks;
double amount;



Skip=fileopen.next();
Firstname=fileopen.next();
Lastname=fileopen.next();
salary=fileopen.nextDouble();
residency=fileopen.nextChar();
expenses=fileopen.nextDouble();
System.out.print(""+Firstname+" "+Lastname"'s");
System.out.println("salary is"+salary);
System.out.println("their weekly expenses are"+expenses);
if(residency==y)
{
System.out.println("they are a resident");
}

else
if (residency != y)
{
System.out.println("They are a resident");
}
while
Checkaccount=fileopen.next();
if (Checkaccount.equals("account"))
{
Skip=fileopen.next();
Skip=fileopen.next();
rate=fileopen.nextDouble();
weeks=fileopen.nextInt();
amount=fileopen.nextDouble();
System.out.println("Account1");
System.out.println("rate equals"+rate);
System.out.println("weeks money invested for equals"+weeks);
System.out.println("amount of money invested equals"+amount);

Checkaccount=fileopen.next();
if (Checkaccount.equals("account"))
{
Skip=fileopen.next();
Skip=fileopen.next();
rate=fileopen.nextDouble();
weeks=fileopen.nextInt();
amount=fileopen.nextDouble();
System.out.println("Account2");
System.out.println("rate equals"+rate);
System.out.println("weeks money invested for equals"+weeks);
System.out.println("amount of money invested equals"+amount);

Checkaccount=fileopen.next();


if (Checkaccount.equals("account"))
{
Skip=fileopen.next();
Skip=fileopen.next();
rate=fileopen.nextDouble();
weeks=fileopen.nextInt();
amount=fileopen.nextDouble();
System.out.println("Account3");
System.out.println("rate equals"+rate);
System.out.println("weeks money invested for equals"+weeks);
System.out.println("amount of money invested equals"+amount);

}
}
}
}


public void addclient (int noaccounts, String Name, double medicare, double grosssalary, double netsalary, int residentialstatus,double weeklyexpenses)
{
int counter;
int newnoclients;
newnoclients=noclients + 1;
counter=0;

client [] arraycopy = new client [newnoclients];

while (counter<noclients)
{
arraycopy[counter]=clients[counter];
counter++;
}

arraycopy[noclients]=new Client(rate,numberofweeks,amountperweek);
clients=arraycopy;
noclients++;

}


public void displayclient(String Clienttodisplay)
{

String Name;
int residentialstatus;
double grossalary;
double netsalary;
double tax;
double medicare;
double weeklyexpenses;
double rate;
int noweeks;
double amount;
double totalreturn;
double taxweek;
double medicareweek;
int counter1;
int counter;
int noaccounts;
counter1=0;
counter=0;

while(clients[counter1].!Name.equals clienttodisplay)
{
counter1++;
}


residentialstatus=Clients[counter1].getresidentialstatus();
grosssalary=Clients[counter1].getgrosssalary();
netsalary=Clients[counter1].getnetsalary();
tax=Clients[counter1].calctax();
medicare=Clients[counter1].calcmedicarelevy();
taxweek=tax/52;
medicareweek=medicare/52;


System.out.print(""+Name+" ");
if (residentialstatus==1);
{
System.out.println("is a resident");
}

else
if(residentialstatus != 1)
{
System.out.println("is not a resident");
}
System.out.println("Their gross salary per week is"+grosssalary);
System.out.println("Their net salary per week is" +netsalary);
System.out.println("Their tax per week is" +taxweek);
System.out.println("Their medicare per week is" +medcareweek);
System.out.println("Their expenses per week are"+weeklyexpenses);

noaccounts=clients[counter1].getnoaccounts();

while (counter<noaccounts)
{
rate=Clients[counter1].getrate(counter);
noweeks=Clients[counter1].getnumberofweeks(counter);
amount=Clients[counter1].getamount(counter);
totalreturn=Accounts[counter].totalreturn();

System.out.println("for "+Name+"'s account "+counter);
System.out.println("The interest rate is "+rate);
System.out.println("The number of weeks that the money is invested for is "+numberofweeks);
System.out.println("The amount of money invested per week is " +amount);
System.out.println("and the total return for this investment is "+totalreturn);
counter++;
}



}



public void deleteclient(int clienttodelete)
{

if(clienttodelete<=noclients)
{
int counter1
counter1=0
int counter;
counter=0;
int copyto;
copyto=0;
int length;
length=noclients-1;
Client[] arraycopy=new Client [length];

while(clients[counter1].Name != clienttodelete)
{
counter1++;
}
while (counter<=length)
{
if (counter != counter1)
{
arraycopy[copyto]=Clients[counter];
copyto++;
}
counter++;
}
clients=arraycopy;
}
}


public void displayaccount()
{
int whichaccount;
String Name;
int residentialstatus;
double grossalary;
double netsalary;
double tax;
double medicare;
double weeklyexpenses;
double rate;
int noweeks;
double amount;
double totalreturn;
double taxweek;
double medicareweek;

System.out.print("please enter the account that you wish to display:");
whichaccount=console.nextInt;
if(whichaccount > 0 && whichaccount <=3)
{
whichaccount=whichaccount-1;
residentialstatus=Client.getresidentialstatus;
grosssalary=Client.getgrosssalary;
netsalary=Client.getnetsalary;
tax=Client.calctax();
medicare=Client.calcmedicarelevy;
rate=Client.getrate(whichaccount);
noweeks=Client.getnumberofweeks(whichaccount);
amount=Client.getamount(whichaccount);
totalreturn=Accounts[whichaccount].totalreturn;
taxweek=tax/52;
medicareweek=medicare/52;

System.out.print(""+Name+" ");
if (residentialstatus=1);
{
System.out.println("is a resident");
}

else
if(residentialstatus != 1)
{
System.out.println("is not a resident");
}
System.out.println("Their gross salary per week is"+grosssalary);
System.out.println("Their net salary per week is" +netsalary);
System.out.println("Their tax per week is" +taxweek);
System.out.println("Their medicare per week is" +medcareweek);
System.out.println("Their expenses per week are"+weeklyexpenses);
System.out.println("for "+Name+"'s account "+whichaccount);
System.out.println("The interest rate is "+rate);
System.out.println("The number of weeks that the money is invested for is "+numberofweeks);
System.out.println("The amount of money invested per week is " +amount);
System.out.println("and the total return for this investment is "+totalreturn);

}
}


public void displayall()
{
int counter1
int counter;
String Name;
double medicare;
double grosssalary;
double netsalary;
int residentialstatus;
double weeklyexpenses;
double tax;
double rate;
int numberofweeks;
double amount;
double totalreturn;
int noaccounts;
int noaccounts;

counter=0;
counter1=0;
counter2=1

if (noclients <= 0)
{
System.out.print("No Clients");
}

else
while(counter<noclients)
{
Name=clients[counter].getname();
medicare=clients[counter].calcmedicare();
grossssalary=clients[counter].getgrosssalary();
netsalary=clients[counter].calcnetsalary();
residentialstatus=clients[counter].getresidentialstatus();
weeklyexpenses=clients[counter].getweeklyexpenses();
tax=clients[counter].calctax();


System.out.print(""+Name+"'s")
System.out.println("medicare is"+medicare);
System.out.println("their grosssalary is"+grosssalary);
System.out.println("their netsalary is"+netsalary);
System.out.println("their weekly expenses are"+weeklyexpenses);
System.out.println("and their tax is"+tax);

noaccounts=clients[counter].getnoaccounts;

while(counter1< noaccounts)
{

rate=clients[counter].getrate(counter1);
numberofweeks=clients[counter].getnumberofweeks(counter1);
amount=clients[counter].getamount(counter1);
totalreturn=clients[counter].Accounts[counter1].totalreturn();

System.out.println("Account"+counter2);
System.out.println("The interest rate is "+rate);
System.out.println("number of weeks the money is invested for is "+numberofweeks);
System.out.println("the amount invested per week is "+amount);
System.out.println("and the total return for the investment will be "+totalreturn);
counter1++;
counter2++;

}
counter++;
counter1=0;
counter2=0;
}
}





}
}

Is This A Good Question/Topic? 0
  • +

Replies To: Illegal start of expression errors

#2 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Illegal start of expression errors

Posted 04 November 2009 - 12:08 AM

:code:

Double check all of your brackets and indent for easier reading.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1