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

    Default help me with this error message

    the error message i found:
    C:\Users\0104381\Desktop\Testing.java:142: error: ')' expected
    System.out.println("\nBook Details" + (1+b) + "Book ID: " + addBooks[b].getId() + "\nBook Title: " addBooks[b].getTitle() +
    ^
    C:\Users\0104381\Desktop\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() +
    ^
    C:\Users\0104381\Desktop\Testing.java:142: error: ';' expected
    System.out.println("\nBook Details" + (1+b) + "Book ID: " + addBooks[b].getId() + "\nBook Title: " addBooks[b].getTitle() +
    ^
    C:\Users\0104381\Desktop\Testing.java:143: error: not a statement
    "\nBook Publisher: " + addBooks[b].getPublisher() + "\nBook Author: " + addBooks[b].getAuthor());
    ^
    C:\Users\0104381\Desktop\Testing.java:143: error: ';' expected
    "\nBook Publisher: " + addBooks[b].getPublisher() + "\nBook Author: " + addBooks[b].getAuthor());
    ^
    C:\Users\0104381\Desktop\Testing.java:148: error: ')' expected
    System.out.println("\nMegazine Details" + (1+mg) + "Megazine ID: " + addMegazine[mg].getId() + "\nMegazine Title: " addMegazine[mg].getTitle() +
    ^
    C:\Users\0104381\Desktop\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() +
    ^
    C:\Users\0104381\Desktop\Testing.java:148: error: ';' expected
    System.out.println("\nMegazine Details" + (1+mg) + "Megazine ID: " + addMegazine[mg].getId() + "\nMegazine Title: " addMegazine[mg].getTitle() +
    ^
    C:\Users\0104381\Desktop\Testing.java:149: error: not a statement
    "\nMegazine Publisher: " + addMegazine[mg].getPublisher() + "\nMegazine Date: " + addMegazine[mg].getDate1());
    ^
    C:\Users\0104381\Desktop\Testing.java:149: error: ';' expected
    "\nMegazine Publisher: " + addMegazine[mg].getPublisher() + "\nMegazine Date: " + addMegazine[mg].getDate1());
    ^
    C:\Users\0104381\Desktop\Testing.java:154: error: ')' expected
    System.out.println("\nNewspaper Details" + (1+np) + "Newspaper ID: " + addNews[np].getId() + "\nNewspaper Title: " addNews[np].getTitle() +
    ^
    C:\Users\0104381\Desktop\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() +
    ^
    C:\Users\0104381\Desktop\Testing.java:154: error: ';' expected
    System.out.println("\nNewspaper Details" + (1+np) + "Newspaper ID: " + addNews[np].getId() + "\nNewspaper Title: " addNews[np].getTitle() +
    ^
    C:\Users\0104381\Desktop\Testing.java:155: error: not a statement
    "\nNewspaper Publisher: " + addNews[np].getPublisher() + "\nNewspaper Date: " + addNews[np].getDate2());
    ^
    C:\Users\0104381\Desktop\Testing.java:155: error: ';' expected
    "\nNewspaper Publisher: " + addNews[np].getPublisher() + "\nNewspaper Date: " + addNews[np].getDate2());
    ^
    15 errors



    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() + "\nMegazineTitle: "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 }



    ps.asap

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

    Default Re: help me with this error message

    You were told about the code tags in your last thread: Exception in thread "main" java.lang.NullPointerException

    I'm closing this thread. Feel free to start another, with properly formatted code that isn't cluttered with line numbers. Before you do, please go through the Forum Rules -- particularly the third paragraph.

    db

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

Similar Threads

  1. Error Message
    By Bimz in forum New To Java
    Replies: 2
    Last Post: 09-11-2011, 01:01 PM
  2. 'else' without 'if' error message
    By jim01 in forum New To Java
    Replies: 6
    Last Post: 04-22-2011, 09:10 PM
  3. Error Message ..
    By Hamodi18 in forum New To Java
    Replies: 15
    Last Post: 07-11-2010, 03:31 AM
  4. error message on jsp
    By sandor in forum Web Frameworks
    Replies: 1
    Last Post: 04-11-2007, 02:10 AM

Posting Permissions

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