Page 1 of 2 12 LastLast
Results 1 to 20 of 22
  1. #1
    joel7 is offline Member
    Join Date
    Nov 2012
    Posts
    22
    Rep Power
    0

    Default error message when compile

    Java Code:
    1
    2  import java.util.Scanner;
    3  public class Testing {
    4
    5    public static void main(String[] args){
    6   	Scanner input = new Scanner(System.in);
    7    	
    8    	String bkId = null;
    9		String bkTitle = null;
    10		String bkPublisher = null;
    11		String bkAuthor = null;
    12		
    13		String mgId = null;
    14		String mgTitle = null;
    15		String mgPublisher = null;
    16		String mgDate1 = null;
    17		
    18		String npId = null;
    19		String npTitle = null;
    20		String npPublisher = null;
    21		String npDate2 = null;
    22		
    23		int chooseMenu,booksAdd,displayItem;
    24    	
    25    	System.out.println("<><><><><>Welcome to KDU UC Library Management System<><><><><>");
    26    	System.out.println("\n1.Add Books \n2.Display Books \n3.Search Books");
    27    	chooseMenu = input.nextInt();
    28    	
    29    	switch(chooseMenu){
    30    		case 1:
    31    			System.out.println("\n1.Add Books \n2.Add Megazine \n3.Add Newspaper");
    32    			booksAdd = input.nextInt();
    33    			
    34    	    switch(booksAdd){
    35    		case 1:
    36    			Book[] addBooks = new Book[20];
    37    			
    38    	    for(int a=0; a<10; a++){
    39    	    	addBooks[a] = new Book();	
    40	     	}
    41	     	
    42	     	for(int a=0; a<10; a++){
    43
    44    		System.out.println("Enter ID:");
    45    		bkId = input.nextLine();
    46
    47    		for(int b=0;b<addBooks.length;b++){
    48				while(addBooks[b].id.equals(bkId)){
    49					System.out.println("Duplicate ID");
    50					System.out.println("Enter ID for books "+(a+1) + ":");
    51					bkId = input.nextLine();
    52				}
    53			}
    54
    55  		System.out.println("Enter Title:");
    56    		bkTitle = input.nextLine();
    57
    58    		System.out.println("Enter Publisher:");
    59    		bkPublisher = input.nextLine();
    60
    61    		System.out.println("Enter Author:");
    62    		bkAuthor = input.nextLine();
    63
    64    		addBooks[a] = new Book(bkId,bkTitle,bkPublisher,bkAuthor);
    65    		
    66    	}
    67    	    case 2:
    68    		Megazine[] addMegazine = new Megazine[20];
    69    		
    70    			for(int c=0; c<10; c++){
    71			addMegazine[c] = new Megazine();
    72		}
    73
    74    	for(int c=0; c<10; c++){
    75
    76    		System.out.println("Enter ID:");
    77    		mgId = input.nextLine();
    78
    79    		for(int d=0;d<addMegazine.length;d++){
    80				while(addMegazine[d].id.equals(mgId)){
    81					System.out.println("Duplicate ID");
    82					System.out.println("Enter ID for megazine "+(c+1) + ":");
    83					mgId = input.nextLine();
    84				}
    85			}
    86
    87  		System.out.println("Enter Title:");
    89    		mgTitle = input.nextLine();
    90
    91    		System.out.println("Enter Publisher:");
    92    		mgPublisher = input.nextLine();
    93
    94    		System.out.println("Enter Date:");
    95    		mgDate1 = input.nextLine();
    96
    97    		addMegazine[c] = new Megazine(mgId,mgTitle,mgPublisher,mgDate1);
    98    		
    99    	}
    100         	case 3:
    101    		Newspaper[] addNews = new Newspaper[20];
    102    		
    103    		for(int e=0; e<10; e++){
    104			addNews[e] = new Newspaper();
    105		}
    106
    107    	for(int e=0; e<10; e++){
    108
    109    		System.out.println("Enter ID:");
    110    		npId = input.nextLine();
    111
    112    		for(int f=0;f<addNews.length;f++){
    113				while(addNews[f].id.equals(npId)){
    114					System.out.println("Duplicate ID");
    115					System.out.println("Enter ID for newspaper "+(e+1) + ":");
    116					npId = input.nextLine();
    117				}
    118			}
    119
    120    		System.out.println("Enter Title:");
    121    		npTitle = input.nextLine();
    122
    123    		System.out.println("Enter Publisher:");
    124    		npPublisher = input.nextLine();
    125
    126    		System.out.println("Enter Date:");
    127    		npDate2 = input.nextLine();
    128
    129    		addNews[e] = new Newspaper(npId,npTitle,npPublisher,npDate2);
    130
    131    	}
    132    	default:
    133    		System.out.println("Invalid");
    134    		break;
    135    	}
    136    	case 2:
    137    		System.out.println("\n1.Display Book\n2.Display Megazine\n3.Display Newspaper");
    138    		displayItem = input.nextInt();
    139    		
    140    		switch(displayItem){
    141    			case 1:
    142    				for(int b=0;b<addBooks.length;b++){
    143              	        System.out.println("\nBook Details" + (1+b) + "Book ID: " + addBooks[b].getId() + "\nBook Title: " addBooks[b].getTitle() +
    144              		                       "\nBook Publisher: " + addBooks[b].getPublisher() + "\nBook Author: " + addBooks[b].getAuthor());
    145            }
    146    	    break;
    147    	    case 2:
    148    	    	 for(int mg=0;mg<addMegazine.length;mg++){
    149	                 System.out.println("\nMegazine Details" + (1+mg) + "Megazine ID: " + addMegazine[mg].getId() + "\nMegazine Title: " addMegazine[mg].getTitle() +
    150	            	                    "\nMegazine Publisher: " + addMegazine[mg].getPublisher() + "\nMegazine Date: " + addMegazine[mg].getDate1());		
    151    	}
    152    	break;
    153    	case 3:
    154    		for(int np=0;np<addNews.length;np++){
    155             	System.out.println("\nNewspaper Details" + (1+np) + "Newspaper ID: " + addNews[np].getId() + "\nNewspaper Title: " addNews[np].getTitle() +
    156             		               "\nNewspaper Publisher: " + addNews[np].getPublisher() + "\nNewspaper Date: " + addNews[np].getDate2());
    157            }
    158            break;
    159            default:
    160            	System.out.println("Invalid");
    161            	break;
    162     }
    163     default:
    164     	System.out.println("Invalid");
    165     	break;
    166   }
    167 }
    168  }
    check and see.......
    ps.asap




    check n

  2. #2
    joel7 is offline Member
    Join Date
    Nov 2012
    Posts
    22
    Rep Power
    0

    Default Re: error message when compile

    error message wen compile

    D:\Testing.java:142: error: ')' expected
    System.out.println("\nBook Details" + (1+b) + "Book ID: " + addBooks[b].getId() + "\nBook Title: " addBooks[b].getTitle() +
    ^
    D:\Testing.java:142: error: illegal start of expression
    System.out.println("\nBook Details" + (1+b) + "Book ID: " + addBooks[b].getId() + "\nBook Title: " addBooks[b].getTitle() +
    ^
    D:\Testing.java:142: error: ';' expected
    System.out.println("\nBook Details" + (1+b) + "Book ID: " + addBooks[b].getId() + "\nBook Title: " addBooks[b].getTitle() +
    ^
    D:\Testing.java:143: error: not a statement
    "\nBook Publisher: " + addBooks[b].getPublisher() + "\nBook Author: " + addBooks[b].getAuthor());
    ^
    D:\Testing.java:143: error: ';' expected
    "\nBook Publisher: " + addBooks[b].getPublisher() + "\nBook Author: " + addBooks[b].getAuthor());
    ^
    D:\Testing.java:148: error: ')' expected
    System.out.println("\nMegazine Details" + (1+mg) + "Megazine ID: " + addMegazine[mg].getId() + "\nMegazine Title: " addMegazine[mg].getTitle() +
    ^
    D:\Testing.java:148: error: illegal start of expression
    System.out.println("\nMegazine Details" + (1+mg) + "Megazine ID: " + addMegazine[mg].getId() + "\nMegazine Title: " addMegazine[mg].getTitle() +
    ^
    D:\Testing.java:148: error: ';' expected
    System.out.println("\nMegazine Details" + (1+mg) + "Megazine ID: " + addMegazine[mg].getId() + "\nMegazine Title: " addMegazine[mg].getTitle() +
    ^
    D:\Testing.java:149: error: not a statement
    "\nMegazine Publisher: " + addMegazine[mg].getPublisher() + "\nMegazine Date: " + addMegazine[mg].getDate1());
    ^
    D:\Testing.java:149: error: ';' expected
    "\nMegazine Publisher: " + addMegazine[mg].getPublisher() + "\nMegazine Date: " + addMegazine[mg].getDate1());
    ^
    D:\Testing.java:154: error: ')' expected
    System.out.println("\nNewspaper Details" + (1+np) + "Newspaper ID: " + addNews[np].getId() + "\nNewspaper Title: " addNews[np].getTitle() +
    ^
    D:\Testing.java:154: error: illegal start of expression
    System.out.println("\nNewspaper Details" + (1+np) + "Newspaper ID: " + addNews[np].getId() + "\nNewspaper Title: " addNews[np].getTitle() +
    ^
    D:\Testing.java:154: error: ';' expected
    System.out.println("\nNewspaper Details" + (1+np) + "Newspaper ID: " + addNews[np].getId() + "\nNewspaper Title: " addNews[np].getTitle() +
    ^
    D:\Testing.java:155: error: not a statement
    "\nNewspaper Publisher: " + addNews[np].getPublisher() + "\nNewspaper Date: " + addNews[np].getDate2());
    ^
    D:\Testing.java:155: error: ';' expected
    "\nNewspaper Publisher: " + addNews[np].getPublisher() + "\nNewspaper Date: " + addNews[np].getDate2());
    ^

  3. #3
    Darkzombies is offline Senior Member
    Join Date
    Nov 2012
    Posts
    105
    Rep Power
    0

    Default Re: error message when compile

    You were supposed to remove the numbers as well... but I guess this is better. Try to be more descriptive.

  4. #4
    joel7 is offline Member
    Join Date
    Nov 2012
    Posts
    22
    Rep Power
    0

    Default Re: error message when compile

    ok darkzombies
    do u no what the wrong wit my code?????

    p.s
    asap

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,352
    Blog Entries
    7
    Rep Power
    20

    Default Re: error message when compile

    Quote Originally Posted by joel7 View Post
    p.s
    asap
    Please don't do that.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    Darkzombies is offline Senior Member
    Join Date
    Nov 2012
    Posts
    105
    Rep Power
    0

    Default Re: error message when compile

    Your code kind of gets cut off, but by the error messages, I'm guessing your missing some ends. Try doing some simple syntax checking around your code.

  7. #7
    joel7 is offline Member
    Join Date
    Nov 2012
    Posts
    22
    Rep Power
    0

    Default Re: error message when compile

    josAH

    den wat to do ????
    guide me

  8. #8
    joel7 is offline Member
    Join Date
    Nov 2012
    Posts
    22
    Rep Power
    0

    Default Re: error message when compile

    darkzombie

    can u check n correct the syntax error

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: error message when compile

    Please spell words in full This is a programming forum, not SMS chat.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  10. #10
    joel7 is offline Member
    Join Date
    Nov 2012
    Posts
    22
    Rep Power
    0

    Default Re: error message when compile

    ok sorry darrylburke

  11. #11
    joel7 is offline Member
    Join Date
    Nov 2012
    Posts
    22
    Rep Power
    0

    Default Re: error message when compile

    check my code anyone and what the wrong ??????

  12. #12
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,352
    Blog Entries
    7
    Rep Power
    20

    Default Re: error message when compile

    Quote Originally Posted by joel7 View Post
    josAH

    den wat to do ????
    guide me
    den? wat? You should learn to spell first and only then you should check what the compiler is complaining about (your expression lacks a '+' sign and it confuses the compiler). And don't try to hurry is; I for one have better things to do than check syntax errors that can be solved easily by the poster him/herself if only he/she reads ...

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  13. #13
    joel7 is offline Member
    Join Date
    Nov 2012
    Posts
    22
    Rep Power
    0

    Default Re: error message when compile

    can you correct my compiler and solve the problem..

    josAH

  14. #14
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,352
    Blog Entries
    7
    Rep Power
    20

    Default Re: error message when compile

    Quote Originally Posted by joel7 View Post
    can you correct my compiler and solve the problem..
    There is no need to correct your compiler; it issued that diagnostic message correctly: your expression lacks a '+' sign (as I wrote before already).

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  15. #15
    joel7 is offline Member
    Join Date
    Nov 2012
    Posts
    22
    Rep Power
    0

    Default Re: error message when compile

    that mean i need to add '+' or remove '+'

  16. #16
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default Re: error message when compile

    Look at line 142.
    Chek you have added a '+' between each bit of the String you are concatenating.
    You are missing one.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  17. #17
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default Re: error message when compile

    Oh for...*thrrrrp*
    Serves me right for leaving the window open so long...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  18. #18
    joel7 is offline Member
    Join Date
    Nov 2012
    Posts
    22
    Rep Power
    0

    Default Re: error message when compile

    ok corrected......where is other error.....
    now i have only 5 error.

  19. #19
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,352
    Blog Entries
    7
    Rep Power
    20

    Default Re: error message when compile

    Quote Originally Posted by joel7 View Post
    ok corrected......where is other error.....
    now i have only 5 error.
    What other error? I don't have my crystal ball with me ... You should be as clear and explicit as possible if you want decent help. We can't see what you're seeing on your screen nor are we compiling your buggy code.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  20. #20
    joel7 is offline Member
    Join Date
    Nov 2012
    Posts
    22
    Rep Power
    0

    Default Re: error message when compile

    any one no what the problem of my code
    and i can identify

Page 1 of 2 12 LastLast

Similar Threads

  1. Compile error :(
    By Astralogic in forum New To Java
    Replies: 10
    Last Post: 07-22-2013, 02:26 PM
  2. i get this error during compile
    By Bibin in forum New To Java
    Replies: 1
    Last Post: 12-24-2011, 08:43 AM
  3. compile error
    By angryredantz in forum New To Java
    Replies: 1
    Last Post: 01-23-2009, 10:44 PM
  4. Compile Error - Please Help!!
    By AJ2009 in forum New To Java
    Replies: 10
    Last Post: 01-04-2009, 03:59 PM
  5. compile error
    By dirtycash in forum New To Java
    Replies: 6
    Last Post: 12-12-2007, 06:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •