PROGRAM:
import
java.io.*;
class
Inventory
{
public
static void main(String a[])throws IOException
{
System.out.println("BOOK
DETAILS");
System.out.println("BOOK
ID"+"\t\t"+"BOOK NAME"+"\t\t"+"AUTHOR"+"\t\t"+"PRICE");
System.out.println("1"+"\t\t"+"JAVA
N\W"+"\t\t"+"Elliotte"+"\t\t"+"135.00"+
"\n"+
"2"+"\t\t"+"J2ME"+"\t\t"+"Topley"+"\t\t"+"250.50"+"\n"+
"3"+"\t\t"+"J2EE"+"\t\t"+"Hunt"+"\t\t"+"247.50"+"\n"+
"4"+"\t\t"+"Java
bean"+"\t\t"+"EdRoman"+"\t\t"+"196.75");
DataInputStream d=new
DataInputStream(System.in);
System.out.println("Enter the
id,quantity");
int
id=Integer.parseInt(d.readLine());
int
qty=Integer.parseInt(d.readLine());
switch(id)
{
case 1:
System.out.println("You have selected JAVA
NETWORKING");
double price=qty*135.00;
System.out.println("You have to pay Rs.
"+price);
break;
case 2:
System.out.println("You have selected
J2ME");
double price=qty*250.50;
System.out.println("You have to pay Rs.
"+price);
break;
case 3:
System.out.println("You have selected
J2EE");
double price=qty*247.50;
System.out.println("You have to pay Rs.
"+price);
break;
case 4:
System.out.println("You have selected
JAVA BEANS");
double price=qty*196.75;
System.out.println("You
have to pay Rs. "+price);
break;
default:
System.out.println("You
have entered wrong id.");
exit(0);
}
FileOutputStream fos=new
FileOutputStream("invent.txt");
DataOutputStream dos=new
DataOutputStream(fos);
}
}
OUTPUT:
BOOK
DETAILS::
BOOK ID BOOK NAME AUTHOR PRICE
1 JAVA NETWORKING Elliotte 135.00
2 J2ME Topley 250.50
3 J2EE Hunt 247.50
4 Java bean EdRoman 196.75
Enter the
ID,Quantity::
3
2
You have
Selected J2EE Book
You have
to Pay Rs.495.00
No comments:
Post a Comment
Thanks for your valuable comments