Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
126 views

Java Lab Project

The document summarizes a Java project for an electronics store application created by three students - Aditya Oberai, Shreedev Ganesh Mishra, and Priyank Verma. It describes the objective of implementing basic functions for an electronics store. It details each group member's contributions and the classes and packages used including Products, FileWriter, FileReader. Screenshots of the GUI and flowchart are included along with the full code for the ElectronicsStore class in the appendix.

Uploaded by

Aditya Oberai
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views

Java Lab Project

The document summarizes a Java project for an electronics store application created by three students - Aditya Oberai, Shreedev Ganesh Mishra, and Priyank Verma. It describes the objective of implementing basic functions for an electronics store. It details each group member's contributions and the classes and packages used including Products, FileWriter, FileReader. Screenshots of the GUI and flowchart are included along with the full code for the ElectronicsStore class in the appendix.

Uploaded by

Aditya Oberai
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

JAVA LAB PROJECT –

ELECTRONICS STORE
Made By: Aditya Oberai, Shreedev Ganesh Mishra, Priyank Verma
Objective

The objective of our project is to implement the basic functioning of an application for an electronics
store. We had planned on working on a Point-of-Sale system with a JavaFX UI earlier but faced some
technical issues that we could not resolve in time. We will however be working on a UI with the AWT
package even after submission in order to improve the project.

Group Members and their Contributions

The group members of our project are:

 Aditya Oberai (A2305218017)

Aditya worked on the billing aspect of the program in order to implement the file handling
functions and connect them with the functions handling the product purchases.

 Shreedev Ganesh Mishra (A2305218002)

Shreedev developed the class which contained all the products designed to handle the
product purchases.

 Priyank Verma (A2305218745)

Priyank was responsible for implementing OOP principles to connect the Products class and
also designed the UI of the program for the console post the JavaFX issue.

Details of the Language

The project has solely been created in core Java. The IDE we used to develop the project was
Netbeans 8.2. The files we generated using file handling to manage the billing are of .TXT format.
Flow Chart of the Project
Important Packages and Classes

The most crucial package used in this project is the “java.io” package. The “java.io” package is what
allows inputting and outputting data to files outside the program. The following classes have been
used from the “java.io” package:

 BufferedReader: reads text from a character-input stream, buffering characters in order to


provide for the efficient reading of sequence of characters
 InputStreamReader: reads bytes and decodes them into characters using a specified charset
 PrintWriter: used to print the formatted representation of objects to the text-output stream
 FileWriter: used for writing streams of characters to external files
 FileReader: used for reading streams of characters from external files

Major Screenshots

Fig 1: Main Menu


Fig 2: Example of purchasing a laptop

Fig 3: Purchasing another item, tablet in this case


Fig 4: Viewing the cart and going to billing

Fig 5: Removing items from cart

Fig 6: End of Program


Appendix

Class ElectronicsStore

package electronics_store;

import java.io.*;

/**

* @author Aditya Oberai, Shreedev Ganesh Mishra, Priyank Verma

*/

public class ElectronicsStore

static double bill;

static char repeat;

static String N,address,name;

private void ElectronicsStore()

bill=0;

repeat='n';

N="";

address="";

name="";

public static void main(String []args) throws IOException

ElectronicsStore obj=new ElectronicsStore();


Products pr=new Products();

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

PrintWriter ofile=new PrintWriter(new FileWriter("bill1.txt"));

System.out.print("Enter your name : ");

name=br.readLine();

System.out.println("\n\n Welcome to The Electronics Store \


n__________________________________\n\n");

do

System.out.print("What would you like to buy :\n\n1.\tLaptops\n2.\tDesktops\n3.\tMobile


Phones\n4.\tGaming Consoles\n5.\tVideo Games\n6.\tCameras\n7.\tMP3 Players\n8.\tTablets\n9.\
tView Cart\n10.\tExit\n\nEnter your choice : ");

int a1 = Integer.parseInt(br.readLine());

switch (a1) {

case 1:

bill=pr.laptop(bill);

System.out.print("\nWould you like to add something else to your cart (y/n) : ");

repeat = (char)br.read();br.read();

break;

case 2:

bill=pr.desktop(bill);

System.out.print("\nWould you like to add something else to your cart (y/n) : ");

repeat = (char)br.read();br.read();

break;

case 3:

bill=pr.mobilePhone(bill);

System.out.print("\nWould you like to add something else to your cart (y/n) : ");

repeat = (char)br.read();br.read();

break;

case 4:

bill=pr.gamingConsole(bill);

System.out.print("\nWould you like to add something else to your cart (y/n) : ");
repeat = (char)br.read();br.read();

break;

case 5:

bill=pr.videogame(bill);

System.out.print("\nWould you like to add something else to your cart (y/n) : ");

repeat = (char)br.read();br.read();

break;

case 6:

bill=pr.camera(bill);

System.out.print("\nWould you like to add something else to your cart (y/n) : ");

repeat = (char)br.read();br.read();

break;

case 7:

bill=pr.mp3Player(bill);

System.out.print("\nWould you like to add something else to your cart (y/n) : ");

repeat = (char)br.read();br.read();

break;

case 8:

bill=pr.tablet(bill);

System.out.print("\nWould you like to add something else to your cart (y/n) : ");

repeat = (char)br.read();br.read();

break;

case 9:

obj.viewcart();

break;

case 10:

System.out.print("\n\nDo you want to close the aplication without going ahead with any
purchases (y/n): ");

char ex=(char)br.read();

br.read();

if(ex=='y'){System.out.println("\n\nHave a nice day!!");System.exit(0);}


repeat='y';

break;

default:

break;

System.out.print("\n\n");

while(repeat=='y');

if(repeat=='n')

System.out.print("\n\nDo you want to purchase the items in the cart (y/n): ");

char ex=(char)br.read();br.read();

if(ex=='n'){System.out.println("\n\nHave a nice day!!");System.exit(0);}

obj.bill_1();

private void replace(String Temp, String Ori)throws IOException

BufferedReader ifile = new BufferedReader(new FileReader(Temp));

FileWriter file= new FileWriter(Ori);

PrintWriter ofile= new PrintWriter(file);

String S;

while(true)

S=ifile.readLine();

if(S==null) break;

ofile.println(S);

ifile.close();

ofile.close();
}

private void delete() throws IOException

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

boolean flag=false;

double a;

while(true)

BufferedReader ifile=new BufferedReader(new FileReader("bill1.txt"));

PrintWriter file= new PrintWriter(new FileWriter("bill2.txt"));

System.out.print("\nEnter the name of the item to be removed from cart (exactly as


mentioned) : ");

String S=br.readLine();

N=ifile.readLine();

while(N!=null)

a=Double.parseDouble(ifile.readLine());

if((S.toLowerCase()).compareTo(N.toLowerCase())==0)

flag=true;

bill-=a;

else

file.println(N);

file.println(a);

N=ifile.readLine();

if(flag==false)System.out.println("Item not found.");


if(N==null) System.out.print("");

file.close();

replace("bill2.txt","bill1.txt");

break;

private void bill_1() throws IOException

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

BufferedReader ifile=new BufferedReader(new FileReader("bill1.txt"));

char f;

double a;

System.out.println("\n\n\n\nHere is your cart :- \n");

while(true)

N=ifile.readLine();

if(N!=null)

a=Integer.parseInt(ifile.readLine());

System.out.println("Item : "+N+"\nCost = Rs."+a+"\n");

else

System.out.print("\nDo you want to remove something from your cart (y/n) : ");

f=(char)br.read();br.read();

ifile.close();

this.bill_2(f);

}
private void bill_2(char f) throws IOException

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

char n=f;

do

if(n=='y') this.delete();

else this.bill_3();

System.out.print("\nDo you want to remove something else from your cart (y/n) : ");

n=(char)br.read();br.read();

while(n=='y'||n=='n');

private void bill_3() throws IOException

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

System.out.print("\n\n\n\nADDRESS FOR DELIVERY :-\n\nEnter street address : ");

String add1=br.readLine();

System.out.print("Enter city : ");

String add2=br.readLine();

System.out.print("Enter pincode : ");

String add3=br.readLine();

System.out.print("Enter a landmark near location of delivery : ");

String add4=br.readLine();

address=add1+" , "+add2+" - "+add3+(" Landmark : ")+add4;

this.bill_4_printing();

private void bill_4_printing() throws IOException


{

BufferedReader ifile=new BufferedReader(new FileReader("bill1.txt"));

System.out.println("\n\n\n\nHere is your bill :- \n");

int x=1;

double a;

while(x==1)

N=ifile.readLine();

if(N!=null)

a=Double.parseDouble(ifile.readLine());

System.out.println("Item : "+N+"\nCost = Rs."+a+"\n");

else

System.out.println();

break;

double tax=0.05*bill;

double amt=bill+tax;

System.out.println("\nTotal cost = Rs."+bill+"\nTax = Rs."+tax+"\nFinal amount payable =


Rs."+amt+"\n\n\nYour item(s) will be delivered at the following address in a few days :\n\
n"+address+"\n\nThe amount will be paid on delivery.\n\nThank you "+name+" and have a nice
day!\n");

ifile.close();

System.exit(0);

private void viewcart() throws IOException

PrintWriter ofile=new PrintWriter(new FileWriter("bill1.txt",true));


BufferedReader ifile=new BufferedReader(new FileReader("bill1.txt"));

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

double a;

System.out.println("\n\n\n\nHere is your cart :- \n");

while(true)

N=ifile.readLine();

if(N!=null)

a=Integer.parseInt(ifile.readLine());

System.out.println("Item : "+N+"\nCost = Rs."+a+"\n");

else

System.out.println();

break;

System.out.print("Do you want to add something else to cart (y/n) : ");

repeat=(char) br.read();br.read();

Class Products

package electronics_store;

import java.io.*;

/**

* @author Aditya Oberai, Shreedev Ganesh Mishra, Priyank Verma

*/
public class Products

protected double laptop(double bill) throws IOException

char r;

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

PrintWriter ofile=new PrintWriter(new FileWriter("bill1.txt",true));

int c[]={40000,45000,50000,55000,70000,75000,80000,90000,100000,130000};

String l[] = {"Dell Inspiron 3048","Lenovo Flex 2-14","Dell Inspiron 5048","HP Pavilion 15","HP
Envy 15","Dell Inspiron 7048","Lenovo Y50","MSI GT60","Alienware 15","Alienware 17"};

do

System.out.println("\n\n|-------|--------------------------|----------------|");

System.out.println("| S.no. | Laptop | Price |");

System.out.println("|-------|--------------------------|----------------|");

System.out.println("| 1. | Dell Inspiron 3048 | Rs.40000 |");

System.out.println("| 2. | Lenovo Flex 2-14 | Rs.45000 |");

System.out.println("| 3. | Dell Inspiron 5048 | Rs.50000 |");

System.out.println("| 4. | HP Pavilion 15 | Rs.55000 |");

System.out.println("| 5. | HP Envy 15 | Rs.70000 |");

System.out.println("| 6. | Dell Inspiron 7048 | Rs.75000 |");

System.out.println("| 7. | Lenovo Y50 | Rs.80000 |");

System.out.println("| 8. | MSI GT60 | Rs.90000 |");

System.out.println("| 9. | Alienware 15 | Rs.100000 |");

System.out.println("| 10. | Alienware 17 | Rs.130000 |");

System.out.println("|-------|--------------------------|----------------|");

System.out.print("\nEnter your choice : ");

int a1 = Integer.parseInt(br.readLine());

if(a1>0 && a1<=l.length)

bill+=c[a1-1];
ofile.println(l[a1-1]);

ofile.println(c[a1-1]);

else System.out.println("Error in Input");

System.out.print("\nWould you like buy another laptop (y/n) : ");

r = (char)br.read();br.read();

while(r=='y');

ofile.close();

return bill;

protected double desktop(double bill) throws IOException

char r;

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

PrintWriter ofile=new PrintWriter(new FileWriter("bill1.txt",true));

int c[]={40000,45000,55000,60000,65000,30000,27000,30000,80000,90000};

String l[] = {"Dell Inspiron One 20 3048","Lenovo C360","Lenovo B40-30","HP Pavilion


23","Lenovo B50-30","Acer Aspire Z1","Lenovo C260","HP 20-2312","Alienware x51","Alienware
Aurora R4"};

do

System.out.println("\n\n| S.no. | Desktop | Price | ");

System.out.println("|-------|---------------------------------|----------------|");

System.out.println("| 1. | Dell Inspiron One 20 3048 | Rs.40000 |");

System.out.println("| 2. | Lenovo C360 | Rs.45000 |");

System.out.println("| 3. | Lenovo B40-30 | Rs.55000 |");

System.out.println("| 4. | HP Pavilion 23 | Rs.60000 |");

System.out.println("| 5. | Lenovo B50-30 | Rs.65000 |");

System.out.println("| 6. | Acer Aspire Z1 | Rs.30000 |");

System.out.println("| 7. | Lenovo C260 | Rs.27000 |");


System.out.println("| 8. | HP 20-2312 | Rs.30000 |");

System.out.println("| 9. | Alienware x51 | Rs.80000 |");

System.out.println("| 10. | Alienware Aurora R4 | Rs.90000 |");

System.out.println("|-------|---------------------------------|----------------|");

System.out.print("\nEnter your choice : ");

int a1 = Integer.parseInt(br.readLine());

if(a1>0 && a1<=l.length)

bill+=c[a1-1];

ofile.println(l[a1-1]);

ofile.println(c[a1-1]);

else System.out.println("Error in Input");

System.out.print("Would you like to buy another desktop (y/n) : ");

r=(char)br.read();br.read();

while(r=='y');

ofile.close();

return bill;

protected double mobilePhone(double bill) throws IOException

char r;

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

PrintWriter ofile=new PrintWriter(new FileWriter("bill1.txt",true));

int c[]={14000,10000,21000,25000,30000,40000,43000,50000};

String l[] = {"Microsoft Lumia 640 XL","Lenovo K3 Note","Blackberry Leap","HTC Desire


826","iPhone 5S","Samsung Galaxy Note 4","Sony Xperia Z3+","iPhone 6+"};

do

{
System.out.println("\n\n|-------|--------------------------|----------------|");

System.out.println("| S.no. | Mobile Phone | Price |");

System.out.println("|-------|--------------------------|----------------|");

System.out.println("| 1. | Microsoft Lumia 640 XL | Rs.14000 |");

System.out.println("| 2. | Lenovo K3 Note | Rs.10000 |");

System.out.println("| 3. | Blackberry Leap | Rs.21000 |");

System.out.println("| 4. | HTC Desire 826 | Rs.25000 |");

System.out.println("| 5. | iPhone 5S | Rs.30000 |");

System.out.println("| 6. | Samsung Galaxy Note 4 | Rs.40000 |");

System.out.println("| 7. | Sony Xperia Z3+ | Rs.43000 |");

System.out.println("| 8. | iPhone 6+ | Rs.50000 |");

System.out.println("|-------|--------------------------|----------------|");

System.out.print("\nEnter your choice : ");

int a1 = Integer.parseInt(br.readLine());

if(a1>0 && a1<=l.length)

bill+=c[a1-1];

ofile.println(l[a1-1]);

ofile.println(c[a1-1]);

else System.out.println("Error in Input");

System.out.print("\nWould you like buy another mobile phone (y/n) : ");

r = (char)br.read();br.read();

while(r=='y');

ofile.close();

return bill;

protected double gamingConsole(double bill) throws IOException

{
char r;

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

PrintWriter ofile=new PrintWriter(new FileWriter("bill1.txt",true));

int c[]={18000,35000,25000,35000,20000,15000,30000};

String l[] = {"PS3","PS4","XBOX 360","XBOX One","Nintendo 3DS","Nintendo Wii","Nintendo Wii


U"};

do

System.out.println("\n\n|-------|--------------------------|----------------|");

System.out.println("| S.no. | Gaming Console | Price |");

System.out.println("|-------|--------------------------|----------------|");

System.out.println("| 1. | PS3 | Rs.18000 |");

System.out.println("| 2. | PS4 | Rs.35000 |");

System.out.println("| 3. | XBOX 360 | Rs.25000 |");

System.out.println("| 4. | XBOX One | Rs.35000 |");

System.out.println("| 5. | Nintendo 3DS | Rs.20000 |");

System.out.println("| 6. | Nintendo Wii | Rs.15000 |");

System.out.println("| 7. | Nintendo Wii U | Rs.30000 |");

System.out.println("|-------|--------------------------|----------------|");

System.out.print("\nEnter your choice : ");

int a1 = Integer.parseInt(br.readLine());

if(a1>0 && a1<=l.length)

bill+=c[a1-1];

ofile.println(l[a1-1]);

ofile.println(c[a1-1]);

else System.out.println("Error in Input");

System.out.print("\nWould you like buy another gaming console (y/n) : ");

r = (char)br.read();br.read();

}
while(r=='y');

ofile.close();

return bill;

protected double videogame(double bill) throws IOException

char r;

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

PrintWriter ofile=new PrintWriter(new FileWriter("bill1.txt",true));

int c[]={2700,3400,1000,1500,2700,3000,3600,1300,1000,2700};

String l[] = {"Far Cry 4 PS3","Batman Arkham Knight PS4","Metal Gear Solid 5 PC","The Witcher 3
PC ","Bloodborne PS4","Mortal Kombat X XBOX One","Mad Max XBOX One","Hitman Absolution
PS3","Need For Speed Rivals PC","FIFA 15 XBOX 360"};

do

System.out.println("\n\n|-------|---------------------------|----------------|");

System.out.println("| S.no. | Video Game | Price |");

System.out.println("|-------|---------------------------|----------------|");

System.out.println("| 1. | Far Cry 4 PS3 | Rs.2700 |");

System.out.println("| 2. | Batman Arkham Knight PS4| Rs.3400 |");

System.out.println("| 3. | Metal Gear Solid 5 PC | Rs.1000 |");

System.out.println("| 4. | The Witcher 3 PC | Rs.1500 |");

System.out.println("| 5. | Bloodborne PS4 | Rs.2700 |");

System.out.println("| 6. | Mortal Kombat X XBOX One| Rs.3000 |");

System.out.println("| 7. | Mad Max XBOX One | Rs.3600 |");

System.out.println("| 8. | Hitman Absolution PS3 | Rs.1300 |");

System.out.println("| 9. | Need For Speed Rivals PC| Rs.1000 |");

System.out.println("| 10. | FIFA 15 XBOX 360 | Rs.2700 |");

System.out.println("|-------|---------------------------|----------------|");

System.out.print("\nEnter your choice : ");

int a1 = Integer.parseInt(br.readLine());
if(a1>0 && a1<=l.length)

bill+=c[a1-1];

ofile.println(l[a1-1]);

ofile.println(c[a1-1]);

else System.out.println("Error in Input");

System.out.print("\nWould you like buy another video game (y/n) : ");

r = (char)br.read();br.read();

while(r=='y');

ofile.close();

return bill;

protected double camera(double bill) throws IOException

char r;

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

PrintWriter ofile=new PrintWriter(new FileWriter("bill1.txt",true));

int c[]={5700,6000,7500,10000,14000,12500,26000};

String l[] = {"Canon Powershot IXUS 145","Sony CyberShot DSC W800","Sony CyberShot DSC
W830","Canon PowerShot SX400 IS","Panasonic Lumix DMC-LZ40","Kodak Pixpro AZ361","Sony DSC-
RX100"};

do

System.out.println("\n\n|-------|---------------------------|----------------|");

System.out.println("| S.no. | Camera | Price |");

System.out.println("|-------|---------------------------|----------------|");

System.out.println("| 1. | Canon PowerShot IXUS 145| Rs.5700 |");

System.out.println("| 2. | Nikon Coolpix S3700 | Rs.6000 |");

System.out.println("| 3. | Sony CyberShot DSC W830 | Rs.7500 |");


System.out.println("| 4. | Canon PowerShot SX400 IS| Rs.10000 |");

System.out.println("| 5. | Panasonic Lumix DMC-LZ40| Rs.14000 |");

System.out.println("| 6. | Kodak Pixpro AZ361 | Rs.12500 |");

System.out.println("| 7. | Sony DSC-RX100 | Rs.26000 |");

System.out.println("|-------|---------------------------|----------------|");

System.out.print("\nEnter your choice : ");

int a1 = Integer.parseInt(br.readLine());

if(a1>0 && a1<=l.length)

bill+=c[a1-1];

ofile.println(l[a1-1]);

ofile.println(c[a1-1]);

else System.out.println("Error in Input");

System.out.print("\nWould you like buy another camera (y/n) : ");

r = (char)br.read();br.read();

while(r=='y');

ofile.close();

return bill;

protected double mp3Player(double bill) throws IOException

char r;

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

PrintWriter ofile=new PrintWriter(new FileWriter("bill1.txt",true));

int c[]={5200,5300,5300,8700,12000,14700,18000};

String l[] = {"Sony Walkman MWZ-E383 4Gb","Apple iPod Shuffle 2Gb","Philips GoGear Tapp
4Gb","Sony Walkman NWZ-WH303 4Gb","Apple iPod Nano 16Gb","FiiO X3 1Gb","Apple iPod Touch
32Gb"};

do
{

System.out.println("\n\n|-------|-----------------------------|----------------|");

System.out.println("| S.no. | MP3 Player | Price |");

System.out.println("|-------|-----------------------------|----------------|");

System.out.println("| 1. | Sony Walkman MWZ-E383 4Gb | Rs.5200 |");

System.out.println("| 2. | Apple iPod Shuffle 2Gb | Rs.5300 |");

System.out.println("| 3. | Philips GoGear Tapp 4Gb | Rs.5300 |");

System.out.println("| 4. | Sony Walkman NWZ-WH303 4Gb| Rs.8700 |");

System.out.println("| 5. | Apple iPod Nano 16Gb | Rs.12000 |");

System.out.println("| 6. | FiiO X3 1Gb | Rs.14700 |");

System.out.println("| 7. | Apple iPod Touch 32Gb | Rs.18000 |");

System.out.println("|-------|-----------------------------|----------------|");

System.out.print("\nEnter your choice : ");

int a1 = Integer.parseInt(br.readLine());

if(a1>0 && a1<=l.length)

bill+=c[a1-1];

ofile.println(l[a1-1]);

ofile.println(c[a1-1]);

else System.out.println("Error in Input");

System.out.print("\nWould you like buy another mp3 player (y/n) : ");

r = (char)br.read();br.read();

while(r=='y');

ofile.close();

return bill;

protected double tablet(double bill) throws IOException

{
char r;

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

PrintWriter ofile=new PrintWriter(new FileWriter("bill1.txt",true));

int c[]={10000,14000,19000,20500,26000,28000,30000};

String l[] = {"Mi Pad","Asus Fonepad 8","Lenovo Yoga 2","Samsung Galaxy Tab A","Samsung
Galaxy Tab 3","Dell Venue 8","Apple iPad Mini 3"};

do

System.out.println("\n\n|-------|-----------------------------|----------------|");

System.out.println("| S.no. | Tablet | Price |");

System.out.println("|-------|-----------------------------|----------------|");

System.out.println("| 1. | Mi Pad | Rs.10000 |");

System.out.println("| 2. | Asus Fonepad 8 | Rs.14000 |");

System.out.println("| 3. | Lenovo Yoga 2 | Rs.19000 |");

System.out.println("| 4. | Samsung Galaxy Tab A | Rs.20500 |");

System.out.println("| 5. | Samsung Galaxy Tab 3 | Rs.26000 |");

System.out.println("| 6. | Dell Venue 8 | Rs.28000 |");

System.out.println("| 7. | Apple iPad Mini 3 | Rs.30000 |");

System.out.println("|-------|-----------------------------|----------------|");

System.out.print("\nEnter your choice : ");

int a1 = Integer.parseInt(br.readLine());

if(a1>0 && a1<=l.length)

bill+=c[a1-1];

ofile.println(l[a1-1]);

ofile.println(c[a1-1]);

else System.out.println("Error in Input");

System.out.print("\nWould you like buy another tablet (y/n) : ");

r = (char)br.read();br.read();

}
while(r=='y');

ofile.close();

return bill;

You might also like