hi.. i hv few error. pls.

hi.. i hv few error. pls.

hi sir, i have few error. can u pls help me. pls.
im very new in java. ths my Uni assgmnt.

please help me...

import java.io.*;

public class nathan
{

String title[]={"Biography","Computers","Science","Sports","Religion"};
String author[]={"Francis","Roland","Bobby","Keith","Robbert"};
String publisher[]={"USA","USA","Germany","France","Spain"};
Double price[]={19.00,25.50,20.80,19.60,13.80};
int quantity[]={10,40,32,36,41};
boolean done = false;


public void nathan () throws IOException
{

InputStreamReader input = new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(input);

System.out.println("|!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!|");
System.out.println("| Welcome to |");
System.out.println("| Nathan Book Shop |");
System.out.println(" ------------------------------------------- ");
System.out.println("| 1. All Books |");
System.out.println("| 2. Books By Title |");
System.out.println("| 3. Purchase Books |");
System.out.println("| 4. Exit |");
System.out.println("|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|");

System.out.println("");
System.out.print("Enter your choice=>");
String op = br.readLine();
int read = Integer.parseInt(op);

switch(read)
{
case 1:

System.out.println("");
allBooks();
break;

case 2:

System.out.println("");
searchTitle();
break;

case 3:

System.out.println("");
purchase();
break;

case 4:

System.out.println("{{{{THANK YOU}}}}");
System.exit(0);
break;

default:

System.out.print("Wrong Info. Please Enter Again");

}
}


public void searchTitle()throws IOException

{
System.out.print("Enter Title Name::");
String name = br.readLine();
int title = Integer.parseInt(op);

switch(title)
{

case "Biography":

System.out.println("\t Title\t\tAuthor\t\tPublisher\tQuantity\tPrice");
System.out.println("\t =============================================");
System.out.println("");
System.out.println("\t "+title[i]+"\t"+author[i]+"\t\t"+publisher[i]+"\t\t"+quantity[i]+"\t\t"+price[i]);
break;


case "Computers":

System.out.println("\t Title\t\tAuthor\t\tPublisher\tQuantity\tPrice");
System.out.println("\t =============================================");
System.out.println("");
System.out.println("\t "+title[i]+"\t"+author[i]+"\t\t"+publisher[i]+"\t\t"+quantity[i]+"\t\t"+price[i]);
break;

case "Science":

System.out.println("\t Title\t\tAuthor\t\tPublisher\tQuantity\tPrice");
System.out.println("\t =============================================");
System.out.println("");
System.out.println("\t "+title[i]+"\t"+author[i]+"\t\t"+publisher[i]+"\t\t"+quantity[i]+"\t\t"+price[i]);
break;

case "Sports":

System.out.println("\t Title\t\tAuthor\t\tPublisher\tQuantity\tPrice");
System.out.println("\t =============================================");
System.out.println("");
System.out.println("\t "+title[i]+"\t"+author[i]+"\t\t"+publisher[i]+"\t\t"+quantity[i]+"\t\t"+price[i]);
break;


case "Religion":

System.out.println("\t Title\t\tAuthor\t\tPublisher\tQuantity\tPrice");
System.out.println("\t =============================================");
System.out.println("");
System.out.println("\t "+title[i]+"\t"+author[i]+"\t\t"+publisher[i]+"\t\t"+quantity[i]+"\t\t"+price[i]);
break;

default:


System.out.print("DIDT FOUND");
}

}

public void purchase()throws IOException
{

System.out.print("Enter book name:");
String name = br.readLine();
int title = Integer.parseInt(op);

switch ("")
{
case 1:

System.out.println("\torder details are as follows:");
System.out.println("\t============================");
System.out.println("");
System.out.println("\tBook title:"+title[i]);
System.out.println("");
System.out.println("\tAuthor:"+author[i]);
System.out.println("");
System.out.println("\tPublisher:"+publisher[i]);
System.out.println("");
System.out.println("\tUnit Price:"+price[i]);
System.out.println("");
System.out.println("\tQuantity:"+qua1);
System.out.println("");
System.out.println("\tTotal:"+total);
System.out.println("");
System.out.print("Thank you");
break;

default:
System.out.print("Book not found");
}

}

public void allBooks()throws IOException
{

System.out.println("Title\t\tAuthor\t\tPublisher\tQuantity\tPrice");
System.out.println("=============================================");
for(int a=0; a<author.length;a++)


{
System.out.println(""+title[a]+"\t"+author[a]+"\t\t|"+publisher[a]+"\t\t|"+quantity[a]+"\t\t|"+price[a]);
System.out.println("");
}

System.out.println("");


}//end of allbooks

public static void main(String args[])throws IOException
{
nathan bk = new nathan();
bk.nathan();
}

}
View Answers

May 1, 2010 at 11:20 AM

Hi Friend,

Try the following code:

import java.io.*;

public class nathan{
String title[]={"Biography","Computers","Science","Sports","Religion"};
String author[]={"Francis","Roland","Bobby","Keith","Robbert"};
String publisher[]={"USA","USA","Germany","France","Spain"};
Double price[]={19.00,25.50,20.80,19.60,13.80};
double quantity[]={10,40,32,36,41};
boolean done = false;
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(input);
public void nathan () throws IOException{
do{
System.out.println();
System.out.println("|!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!|");
System.out.println("| Welcome to |");
System.out.println("| Nathan Book Shop |");
System.out.println(" ------------------------------------------- ");
System.out.println("| 1. All Books |");
System.out.println("| 2. Books By Title |");
System.out.println("| 3. Purchase Books |");
System.out.println("| 4. Exit |");
System.out.println("|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|");
System.out.println("");
System.out.print("Enter your choice=>");
String op = br.readLine();
int read = Integer.parseInt(op);
switch(read){
case 1:

System.out.println("");
allBooks();
break;

case 2:

System.out.println("");
searchTitle();
break;

case 3:

System.out.println("");
purchase();
break;

case 4:

System.out.println("{{{{THANK YOU}}}}");
done=true;
break;

default:

System.out.print("Wrong Info. Please Enter Again");
}
}
while (!done);
}
public void searchTitle() throws IOException{
System.out.print("Enter Title Name::");
String name = br.readLine();
for(int i=0;i<5;i++){
if(name.equals(title[i])){
System.out.println("Author : "+author[i]);
System.out.println("Publisher : "+publisher[i]);
System.out.println("Price : "+price[i]);
System.out.println("Quantity : "+quantity[i]);
}
}
}
public void purchase() throws IOException{
System.out.print("Enter book name:");
String name = br.readLine();
for(int i=0;i<5;i++){
if(name.equals(title[i])){
System.out.println("Author : "+author[i]);
System.out.println("Publisher : "+publisher[i]);
System.out.println("Price : "+price[i]);
System.out.println("Quantity : "+quantity[i]);
System.out.println("Total Price : "+quantity[i]*price[i]);
}
}
}
public void allBooks()throws IOException{
System.out.println("Title\t\tAuthor\t\tPublisher\tQuantity\tPrice");
System.out.println("=============================================");
for(int a=0; a<author.length;a++){
System.out.println(""+title[a]+"\t"+author[a]+"\t\t|"+publisher[a]+"\t\t|"+quantity[a]+"\t\t|"+price[a]);
System.out.println("");
}
System.out.println("");
}
public static void main(String args[])throws IOException{
nathan bk = new nathan();
bk.nathan();
}
}

Thanks









Related Tutorials/Questions & Answers:
hi.. i hv few error. pls. - Java Beginners
hi.. i hv few error. pls.  hi sir, i have few error. can u pls help me. pls. im very new in java. ths my Uni assgmnt. please help me... import...(""); System.out.println("\t "+title[i]+"\t
hi , i cant make this programmer , can any one help me to make it pls - Java Beginners
hi , i cant make this programmer , can any one help me to make it pls  ... program. i cant find delete records or update records  pls can....  Hi friend, For solving all the problem visit to : http
Advertisements
i dont no how to solve it pls
i dont no how to solve it pls   Calculate and display the sum of all prime number from 1 to 100 covert in java system codes
ModuleNotFoundError: No module named 'hv'
ModuleNotFoundError: No module named 'hv'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'hv' How to remove the ModuleNotFoundError: No module named 'hv' error
ModuleNotFoundError: No module named 'hv'
ModuleNotFoundError: No module named 'hv'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'hv' How to remove the ModuleNotFoundError: No module named 'hv' error
pls i need help with my assignment
pls i need help with my assignment  how to write a code that ask the user for the height of the triangle and prints the triangle using * eg if height is 3 it prints * and also using import java.util.Scanner
hi... pls give me the example of java coding fo following question
hi... pls give me the example of java coding fo following question  example java coding that reads in the radius and length of cylinder and computes volume. formula: Area = radius * radius * PI Volume = area * length
hi... pls give me the example of java coding for following question
hi... pls give me the example of java coding for following question   Write a program that computes loan payments. The loan can be a car loan, a student loan, or a home mortgage loan. The program lets the user enter the interest
hi... pls give me the example of java coding fo following question
hi... pls give me the example of java coding fo following question  Write a java program that reads the following information and prints a payroll statement: Employeeâ??s name (e.g: Sam) Number of hours worked in a week (e.g: 10
ModuleNotFoundError: No module named 'hv-uploader'
ModuleNotFoundError: No module named 'hv-uploader'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named...-uploader' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'hv-uploader'
ModuleNotFoundError: No module named 'hv-uploader'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named...-uploader' error? Thanks   Hi, In your python environment
i have a problem to do this question...pls help me..
i have a problem to do this question...pls help me..  Write a program....   Hi Friend, Try this: import java.util.*; public class ReverseNumber... reversedNumber = 0; for (int i = 0; i <= num; i
how can i get output pls urget tell me
how can i get output pls urget tell me  HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception
I GOT ERROR FOR MY PROJECT
I GOT ERROR FOR MY PROJECT  Dear Friend/ RoseIndia Team, Firstly I would to thank u Guys help me so many time.. I got error on my little project when running at server. please correctly my error Guys... ERROR CODE: "LOGIN
Hi ..I am Sakthi.. - Java Beginners
Hi ..I am Sakthi..  can u tell me Some of the packages n Sub Directories starts with... import javax.swing.*; import javax._________;  ...;Hi friend, package javacode; import javax.swing.*; import
i want to retriev and update in same form but its not working pls help....
i want to retriev and update in same form but its not working pls help....  <p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html></p> <p>
Hi.. how to write more than one sheets in a excel file... pls anybody help me....
Hi.. how to write more than one sheets in a excel file... pls anybody help me....  i can write only one sheet in a excel file.. but i want to write... go to second sheet... pls help me.. here my code.. import
I/O Program output error
I/O Program output error  Hello All, I am working on a program... file, but I am getting incorrect output. I have been successfull with part of the program in that it reads the text file and analyzes it, however I need it to take
hi
hi   on clicking on button on 1st jsp page i want to display following options like friends,family,doctor etc.on next jsp page and also i want link... databases like the above i.e friends,family,etc pls can any one tell how can i do
hi
hi   on clicking on button on 1st jsp page i want to display following options like friends,family,doctor etc.on next jsp page and also i want link... databases like the above i.e friends,family,etc pls can any one tell how can i do
hi
hi  how i get answer of my question which is asked by me for few minutes ago.....rply
ModuleNotFoundError: No module named 'FEW'
ModuleNotFoundError: No module named 'FEW'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'FEW' How to remove the ModuleNotFoundError: No module named 'FEW' error
Jsp error when i run this a jsp file
Jsp error when i run this a jsp file  hi I got this error when i run the jsp file in IDE and outside also please help me java.lang.NullPointerException org.apache.jsp.insertjsp.jspInit(insert_jsp.java:22
i cant find any compile time error but there is runtime error.
i cant find any compile time error but there is runtime error.  ...   Hi, I tried the following updated code and it is working. Please..._TO_REPLACE_3 String i = res.getString("stud_code"); Thanks   Hi, Please
Hi i want java code that diaplays server scren at the client side
Hi i want java code that diaplays server scren at the client side  Hi I'm Shivaprasad i want java socket code that shows the server side screen when client gets connected with the server. Please help me   Please visit
Want to add a resource in the build directory that's created when i run an mvn assembly:assembly command. Pls help!
Want to add a resource in the build directory that's created when i run an mvn assembly:assembly command. Pls help!  I have got a certificate in my resource folder-> src/main/resources/cacerts. When I do a mvn assembly
hi i m new to hibernate..plzzzzzzzzzzzzzz help me.... - Hibernate
hi i m new to hibernate..plzzzzzzzzzzzzzz help me....  hi friends i m new to hibernate..& i m stuck in one positon in my pgm.. its a simple select...://www.roseindia.net/hibernate/selectclause.shtml Thanks.  hi deepak.. when i
i got an error while compile this program manually.
i got an error while compile this program manually.  import... mapping.findForward("errors.jsp"); } } i set both servlet,struts jar files and i got an error in saveErrors() error Heading cannot find
Hi i am new to J2ee Technology and struts - Struts
Hi i am new to J2ee Technology and struts  what exatly will happen when we hit the Login button? Once we enter in to the application, what will happen. How the UserID and Password validations will done. Can any one help
i am unable to identify the error in my code
i am unable to identify the error in my code  class Program { public static void main(String[] args) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter
i am unable to identify the error in my code
i am unable to identify the error in my code  class Program { public static void main(String[] args) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter
hi
hi   I have connected mysql with jsp in linux and i have used JDBC connectivity but when i run the program, its not working the program is displaying
Hi
Hi  Hi All, I am new to roseindia. I want to learn struts. I do not know anything in struts. What exactly is struts and where do we use it. Please help me. Thanks in advance. Regards, Deepak
hi
num=4; int p = num; int q = 0; for (int i = 0; i <= num; i++) { for (int j = p; j>= 1; j-- ) System.out.print(" "); p-=1; for (int k = 1; k <= i; k... * * * * * * * * * *print("code sample");   Hi Friend, Try
Hi
Hi  I want import txt fayl java.please say me...   Hi, Please clarify your problem! Thanks
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??  import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class add1 extends MIDlet implements
hi .. need help ASAP ..i have a project buit in eclipse , i have installed jasper. i want the steps to work on it ..
hi .. need help ASAP ..i have a project buit in eclipse , i have installed jasper. i want the steps to work on it ..   hi .. need help ASAP ..i have a project buit in eclipse , i have installed jasper. i want the steps to work
hi
hi   i want to develop a online bit by bit examination process as part of my project in this i am stuck at how to store multiple choice questions options and correct option for the question.this is the first project i am doing
hi
online multiple choice examination  hi i am developing online multiple choice examination for that i want to store questions,four options,correct answer in a xml file using jsp or java?can any one help me?   Please
hi!
hi!  how can i write aprogram in java by using scanner when asking... to to enter, like(int,double,float,String,....) thanx for answering....   Hi...); System.out.print("Enter integer: "); int i=input.nextInt
ModuleNotFoundError: No module named 'pls'
ModuleNotFoundError: No module named 'pls'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pls' How to remove the ModuleNotFoundError: No module named 'pls' error
ModuleNotFoundError: No module named 'pls'
ModuleNotFoundError: No module named 'pls'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pls' How to remove the ModuleNotFoundError: No module named 'pls' error
ModuleNotFoundError: No module named 'pls'
ModuleNotFoundError: No module named 'pls'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pls' How to remove the ModuleNotFoundError: No module named 'pls' error
hi.......
hi.......  i've a project on railway reservation... i need to connect netbeans and mysql with the help of jdbc driver... then i need to design the frame... aftr clickg run i need to enter data to ma frame and the data which i
hi
hi  sir i've a project on railway reservation... i need to connect netbeans and mysql with the help of jdbc driver... then i need to design the frame... aftr clickg run i need to enter data to ma frame and the data which i enter
hi
hi  sir i've a project on railway reservation... i need to connect netbeans and mysql with the help of jdbc driver... then i need to design the frame... aftr clickg run i need to enter data to ma frame and the data which i enter
Hi
Hi  The thing is I tried this by seeing this code itself.But I;m facing a problem with the code.Please help me in solving me the issue. HTTP Status... an internal error () that prevented it from fulfilling this request. exception
Hi
Hi   I need some help I've got my java code and am having difficulty to spot what errors there are is someone able to help import java.util.Scanner; public class Post { public static void main(String[] args) { Scanner sc
when I run exiting project that time I got error, I want solution on it?
when I run exiting project that time I got error, I want solution on it?  Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read...); for(int i=0;i<arr.length-1;i++) { newstr=newstr

Ads