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



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


nathan
hi.. i hv few error. pls.
1 Answer(s)      4 years and 5 months 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 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
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
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 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
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
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
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 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
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 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
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
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  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 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  I want import txt fayl java.please say me...   Hi, Please clarify your problem! Thanks
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  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
 

 

 

DMCA.com