Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners hi.. i hv few error. pls.

Have Programming Question? Ask it here!
 
 
 


nathan
hi.. i hv few error. pls.
1 Answer(s)      4 years ago
Posted in : Java Beginners


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();
}

}

Advertisement
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
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
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
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 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 ..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 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
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
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
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
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
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
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
i cant find any compile time error but there is runtime error.
i cant find any compile time error but there is runtime error.  ...){ System.out.println("Error:connection not created"); }   Hi..."); Thanks   Hi, Please check the thread JDBC ODBC error and the specified
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
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  int A[]=new int{2,5,4,1,3}; what is the error in declaration of this   Hi Friend, This is the wrong way of declaring an array. Array is always declared in the following ways: 1)int arr[]=new int[5]; 2)int arr
Hi
Hi  I want import txt fayl java.please say me...   Hi, Please clarify your problem! Thanks
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
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
hi!
hi!  public NewJFrame() { initComponents(); try { Class.forName("java.sql.Driver"); con=DriverManager.getConnection("jdbc...... jbutton1 s d clear button.. and jbutton2 s d savebutton.. if u find any error
Hi,
Hi,  Hi,what is the purpose of hash table
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
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'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   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,
Hi,   labels = new Hashtable<Integer,JLabel>
Hi..
Hi..  what are access specifier available in java
Hi..
Hi..   what are the keywords available in simple HelloWorld program
HI.
HI.  hi,plz send me the code for me using search button bind the data from data base in dropdownlist
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
hi
hi  ANY SUGGESSION FOR THIS ERROR javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.apache.struts.taglib.html.FormTag
Hi..
Hi..  null is a keyword.True/False?   hi friend, In Java true, false and null are not a Java keyword they are literals in Java. For reading in detail go through the following link The null keyword
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,  print("code sample");how to display all elements in 2d array usin any one loop
Hi
Hi  Hi How to implement I18N concept in struts 1.3? Please reply to me
hi....
hi....  plzz sent me d code for counting vowels in a string... gui programme
Hi
Hi  Hi this is really good example to beginners who is learning struts2.0 thanks
Advertisements
 

 

 

DMCA.com