Results 1 to 3 of 3
- 05-11-2011, 05:20 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 15
- Rep Power
- 0
Another Illegal Start of Expression
Hello, I know you're probably sick of the same question being asked, and I'm sick of having to ask but here goes....I keep getting this error message <illegal start of expression> under each instance of the word "Private". I've tried making sure my braces match up, ";" are in place, tried moving main method to after variables, and tried adding the word "static" to each instance of private, but still nothing. Here is the entire code for your review.Please help!
Java Code:class AddressBookApp2 { // main method begins program execution public static void main(String[] args) { private String donorName; // Donor's name private String donorAddr; // Donor's address private String donorCity; // City where donor lives private String donorState;// State where donor lives private int donorZipCode; // Zipcode of owner's address private int numDonat; // Number of donations private int amtDonat; // Dollar amount of donations private double total; // Total amount of donations this year int nameCounter = 1; // Number of names to be entered //create scanner to obtain input from command window java.util.Scanner input = new java.util.Scanner (System.in); // processing phase for (nameCounter = 1;nameCounter <= 5;nameCounter++) { System.out.print ("Enter the donor's name:"); //prompt name = input.nextLine(); // read donor's name from user input System.out.print ("Enter donor's address:"); //prompt address = input.nextLine(); // read address from user input System.out.print ("Enter donor's city:"); //prompt city = input.nextLine(); // read city from user input System.out.print ("Enter donor's state:"); // prompt state = input.nextLine(); // read state from user input System.out.print ("Enter donor's zipcode:"); //prompt zipcode = input.nextInt(); // read zipcode from user input System.out.print ("Enter the number of donations this year:"); numDonat= input.nextInt(); // read number of donations while (amtDonat <= -1){ System.out.print ("Number must be positive. Re-enter:"); } System.out.print ("Enter dollar amount of donations:"); amtDonat= input.nextInt(); // read donation amount while (numDonat<= -1){ System.out.print ("Amount must be positive. Re-enter:") } total = amtDonat*numDonat; System.out.print ("The donor, whose name is"+ donorName); System.out.print ("and resides at"+ donorAddr); System.out.print ("in the city of"+ donorCity); System.out.print ("in the state of"+ donorState); System.out.print ("with a zipcode of"+ donorZipCode); System.out.print ("has donated $"+ Total); System.out.println ("this year!"); } //end for } // end main method } // end class AddressBookApp2
Last edited by miss_peaches; 05-11-2011 at 05:44 PM.
- 05-11-2011, 05:29 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 785
- Rep Power
- 12
local variables can not have an access modifier!
private String donorName; --> String donorName;
But
name = input.nextLine(); // read donor's name from user input
and so on....where do you have declared name,address and so on...??
- 05-11-2011, 05:41 PM #3
Member
- Join Date
- Apr 2011
- Posts
- 15
- Rep Power
- 0
Similar Threads
-
illegal start of expression
By minusten in forum New To JavaReplies: 1Last Post: 05-03-2011, 05:46 AM -
Illegal Start of Expression
By Tyre in forum New To JavaReplies: 20Last Post: 04-15-2011, 03:50 PM -
Need help with illegal start of expression
By WhopperMan in forum New To JavaReplies: 4Last Post: 10-10-2010, 03:58 AM -
Illegal Start of expression
By Macca07 in forum New To JavaReplies: 3Last Post: 11-23-2009, 09:43 AM -
Illegal start of expression
By Basit56 in forum New To JavaReplies: 2Last Post: 08-18-2009, 10:12 AM
Bookmarks