setNameName pwprintlnName Customer Contact No

Setnamename pwprintlnname customer contact no

This preview shows page 5 - 13 out of 13 pages.

Customer.setName(Name);
Image of page 5
pw.println(Name); System.out.println("Enter Customer Contact No:"); ContactNo=in.nextLine(); Customer.setContactNo(ContactNo); pw.println(ContactNo); do{try{error=false; System.out.println("Enter Amount Due: "); amountDue=in.nextDouble(); }catch(InputMismatchException e) { error=true; System.out.println("Invalid Data Type"); } }while(amountDue<=0||error); Customer.setAmountDue(amountDue); pw.println(amountDue); do{try{error=false; System.out.println("Enter Amount Paid: "); amountPaid=in.nextDouble(); }catch(InputMismatchException e) { error=true; System.out.println("Invalid Data Type"); } }while(amountPaid<=0||error); Customer.setAmountPaid(amountPaid); pw.println(amountPaid);
Image of page 6
pw.println("\n"); pw.close(); break; case 2: { do{ in.nextLine(); System.out.println("Enter File Name with file extention:"); fileName=in.nextLine(); if(!fileName.contains(".txt")){ System.out.println("Only Text File allowed(.txt)"); } }while(!fileName.contains(".txt")); File file = new File(fileName); Scanner sc = new Scanner(file); while(sc.hasNext()) { Customer Cust = new Customer(); int txtID = sc.nextInt(); Cust.setId(txtID); sc.nextLine(); String txtName = sc.nextLine(); Cust.setName(txtName); String txtContactNo = sc.nextLine();
Image of page 7
Cust.setContactNo(txtContactNo); double txtAD = sc.nextDouble(); Cust.setAmountDue(txtAD); double txtAP = sc.nextDouble(); Cust.setAmountPaid(txtAP); List.add(Cust); } Iterator<Customer> iter = List.iterator(); while (iter.hasNext() ) { Customer Cust = iter.next(); System.out.println(Cust + "\n"); } sc.close(); } break; case 3: do{ try{ do{ System.out.println("Enter File Name with file extention:"); fileName=in.next(); if(!fileName.contains(".txt")){ System.out.println("Only Text File allowed(.txt"); } }while(!fileName.contains(".txt"));
Image of page 8
File = new File(fileName); Scanner gb = new Scanner(File); System.out.println("Enter Customer Id:"); Id=in.nextInt(); Customer.setId(Id); while (gb.hasNext()){ Customer Cust2 = new Customer(); int CID = gb.nextInt(); Cust2.setId(CID); gb.nextLine(); String CName = gb.nextLine(); Cust2.setName(CName); String CContactNo = gb.nextLine(); Cust2.setContactNo(CContactNo); double CAD = gb.nextDouble(); Cust2.setAmountDue(CAD); double CAP = gb.nextDouble(); Cust2.setAmountPaid(CAP); if(Id==CID){ System.out.println("------------------"); System.out.println(Cust2);
Image of page 9
}else { System.out.println("record not found"); } } gb.close(); }catch(FileNotFoundException e) { error = true; System.out.println("File Does Not Exist"); } }while(error); break; } }while(option!=0); } }
Image of page 10
Image of page 11
Image of page 12
Image of page 13

You've reached the end of your free preview.

Want to read all 13 pages?

  • Three '19
  • Filename extension, @author, @Override, public class Customer, Fabian Baxter Morais

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture