Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package stock.market.project;
- import java.io.BufferedWriter;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.text.DecimalFormat;
- import java.util.Scanner;
- import java.util.NoSuchElementException;
- /**
- *
- * * Password: SpanishInquisition
- * Admin Password: Shinobu
- * @author MIKU
- */
- public class StockMarketProject
- {
- static Scanner InputSC = new Scanner (System.in);
- /**
- * @param args the command line arguments
- * @throws java.io.IOException
- */
- public static void main(String[] args) throws IOException , NoSuchElementException
- {
- boolean Pw = true , Loop = true , Adp;
- String operation;
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- System.out.println(": WELCOME TO THE PHILIPPINE STOCK EXCHANGE(PSE) :");
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- System.out.println(" ");
- System.out.println("Enter Username: Zeo Q. Juntilla");
- while(Pw == true)
- {
- Pw = Password();
- /* Password: SpanishInquisition */
- /* Admin Password: Shinobu */
- }
- System.out.println(": : : : : : : : : : : : : : ");
- System.out.println(": : ");
- System.out.println(": MAIN MENU :");
- System.out.println(": : ");
- System.out.println(": [1] Add new Index : ");
- System.out.println(": [2] View User Info :");
- System.out.println(": [3] View Indices :");
- System.out.println(": [4] Delete Index : ");
- System.out.println(": [5] Sell Stock :");
- System.out.println(": [6] Buy Stock :");
- System.out.println(": [7] Exit :");
- System.out.println(": : ");
- System.out.println(": : : : : : : : : : : : : : ");
- while(Loop == true)
- {
- System.out.println(" ");
- System.out.print(" Enter operation: ");
- operation = InputSC.next();
- switch(operation)
- {
- case "1":
- Adp = AdminPAssword();
- if(Adp == true)
- {
- AddIndex();
- }
- break;
- case "2":
- UserInfo();
- break;
- case "3":
- ViewAll();
- break;
- case "4":
- Adp = AdminPAssword();
- if(Adp == true)
- {
- DeleteIndex();
- }
- break;
- case "5":
- SellStock();
- break;
- case "6":
- BuyStock();
- break;
- case "7":
- Loop = false;
- break;
- default:
- {
- System.out.print("Wrong Operation!!");
- }
- }
- }
- }
- private static boolean Password()
- {
- String input;
- System.out.print("Enter Password: ");
- input = InputSC.next();
- if("SpanishInquisition".equals(input))
- {
- System.out.println(" ");
- return false;
- }
- else
- {
- System.out.println(": : : : : : : : : : : : : : : : : : : ");
- System.out.println(": Wrong Password Please Try Again : ");
- System.out.println(": Hint: Unexpected Pssword :");
- System.out.println(": : : : : : : : : : : : : : : : : : : ");
- System.out.println(" ");
- }
- return true;
- }
- private static boolean AdminPAssword()
- {
- String input;
- System.out.print("Enter Admin Password: ");
- input = InputSC.next();
- if("Shinobu".equals(input))
- {
- System.out.println(" ");
- return true;
- }
- else
- {
- System.out.println(": : : : : : : : : : : : : : : : : : : ");
- System.out.println(": Wrong Password Please Try Again : ");
- System.out.println(": Hint: Doge :");
- System.out.println(": : : : : : : : : : : : : : : : : : : ");
- System.out.println(" ");
- }
- return false;
- }
- private static void AddIndex() throws IOException
- {
- try (BufferedWriter bufferedwriter = new BufferedWriter(new FileWriter("rc\\stock\\market\\project\\Stock.txt", true)))
- {
- Scanner input = new Scanner(System.in);
- String flower;
- int price,quantity;
- System.out.print("Enter Index name ");
- flower = input.next();
- System.out.print("Enter price: ");
- price = input.nextInt();
- System.out.print("Enter quantity: ");
- quantity = input.nextInt();
- bufferedwriter.append(flower+" "+price+" "+quantity+"\n");
- }
- }
- private static void UserInfo() throws FileNotFoundException
- {
- System.out.println("");
- System.out.println(": : : : : : : : : : : : : : ");
- System.out.println(": : ");
- System.out.println(": USER'S INFO MENU :");
- System.out.println(": :");
- System.out.println(": [1] View Bought Stocks :");
- System.out.println(": [2] View Sold Stocks :");
- System.out.println(": [3] Back :");
- System.out.println(": : ");
- System.out.println(": : : : : : : : : : : : : : ");
- boolean Loop = true;
- String operation;
- while(Loop == true)
- {
- String In , In1 , In2 , In3 , In4 , In5 ;
- Scanner txt=new Scanner(new FileReader("src\\stock\\market\\project\\UserFiles"));
- System.out.println(" ");
- System.out.print(" Enter operation: ");
- operation = InputSC.next();
- switch(operation)
- {
- case "1":
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- System.out.println(":\t"+"Index"+"\t"+":"+"\t"+"Price"+"\t"+":"+"\t"+"Quantity"+"\t"+":");
- while(txt.hasNextLine())
- {
- String line=txt.nextLine();
- Scanner textline= new Scanner(line);
- In = textline.next();
- In1 = textline.next();
- In2 = textline.next();
- In3 = textline.next();
- In4 = textline.next();
- if(line.equals(" "))
- {
- /*continue*/
- }
- if("Buy".equals(In4))
- {
- System.out.println(":\t"+In+"\t"+":"+"\t"+In1+"\t"+":"+"\t"+In2+"\t\t"+":" );
- }
- }
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- txt.reset();
- break;
- case "2":
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- System.out.println(":\t"+"Index"+"\t"+":"+"\t"+"Price"+"\t"+":"+"\t"+"Quantity"+"\t"+":");
- while(txt.hasNextLine())
- {
- String line=txt.nextLine();
- Scanner textline= new Scanner(line);
- In = textline.next();
- In1 = textline.next();
- In2 = textline.next();
- In3 = textline.next();
- In4 = textline.next();
- if(line.equals(" "))
- {
- /*continue*/
- }
- if("Sell".equals(In4))
- {
- System.out.println(":\t"+In+"\t"+":"+"\t"+In1+"\t"+":"+"\t"+In2+"\t\t"+":" );
- }
- }
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- txt.reset();
- break;
- case "3":
- Loop = false;
- break;
- default:
- System.out.print("Wrong Operation!!");
- break;
- }
- if(Loop == false)
- {
- System.out.println(": : : : : : : : : : : : : : ");
- System.out.println(": : ");
- System.out.println(": MAIN MENU :");
- System.out.println(": : ");
- System.out.println(": [1] Add new Index : ");
- System.out.println(": [2] View User Info :");
- System.out.println(": [3] View Indices :");
- System.out.println(": [4] Delete Index : ");
- System.out.println(": [5] Sell Stock :");
- System.out.println(": [6] Buy Stock :");
- System.out.println(": [7] Exit :");
- System.out.println(": : ");
- System.out.println(": : : : : : : : : : : : : : ");
- }
- }
- }
- private static void ViewAll() throws FileNotFoundException, IOException
- {
- String In , In1 ,In2 ;
- boolean Loop = true;
- String operation;
- System.out.println("");
- System.out.println(": : : : : : : : : : : : : : ");
- System.out.println(": : ");
- System.out.println(": INDICES MENU :");
- System.out.println(": :");
- System.out.println(": [1] View ALL :");
- System.out.println(": [2] Search Index :");
- System.out.println(": [3] View Available : ");
- System.out.println(": [4] View Out of Stock : ");
- System.out.println(": [5] Edit Price : ");
- System.out.println(": [6] Back :");
- System.out.println(": : ");
- System.out.println(": : : : : : : : : : : : : : ");
- while(Loop == true)
- {
- Scanner txt=new Scanner(new FileReader("src\\stock\\market\\project\\Stock.txt"));
- System.out.println(" ");
- System.out.print(" Enter operation: ");
- operation = InputSC.next();
- switch(operation)
- {
- case "1":
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- System.out.println(":\t"+"Index"+"\t"+":"+"\t"+"Price"+"\t"+":"+"\t"+"Quantity"+"\t"+":");
- while(txt.hasNextLine())
- {
- String line=txt.nextLine();
- Scanner textline= new Scanner(line);
- In = textline.next();
- In1 = textline.next();
- In2 = textline.next();
- if(line.equals(" "))
- {
- /*continue*/
- }
- System.out.println(":\t"+In+"\t"+":"+"\t"+In1+"\t"+":"+"\t"+In2+"\t\t"+":" );
- }
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- txt.reset();
- break;
- case "2":
- String input;
- System.out.print("Enter an Index: ");
- input=InputSC.next();
- while(txt.hasNextLine())
- {
- String line=txt.nextLine();
- if(line.equals(" "))
- {
- /*continue*/
- }
- else
- {
- Scanner sline= new Scanner(line);
- String index=sline.next();
- String index1=sline.next();
- String index2=sline.next();
- if(index.equals(input))
- {
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- System.out.println(":\t"+"Index"+"\t"+":"+"\t"+"Price"+"\t"+":"+"\t"+"Quantity"+"\t"+":");
- System.out.println(":\t"+index+"\t"+":"+"\t"+index1+"\t"+":"+"\t"+index2+"\t\t"+":" );
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- break;
- }
- }
- }
- txt.reset();
- break;
- case "3":
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- System.out.println(":\t"+"Index"+"\t"+":"+"\t"+"Price"+"\t"+":"+"\t"+"Quantity"+"\t"+":");
- while(txt.hasNextLine())
- {
- String line=txt.nextLine();
- Scanner textline= new Scanner(line);
- In = textline.next();
- In1 = textline.next();
- In2 = textline.next();
- if(In2.equals("0"))
- {
- }
- else
- {
- System.out.println(":\t"+In+"\t"+":"+"\t"+In1+"\t"+":"+"\t"+In2+"\t\t"+":" );
- }
- }
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- txt.reset();
- break;
- case "4":
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- System.out.println(":\t"+"Index"+"\t"+":"+"\t"+"Price"+"\t"+":"+"\t"+"Quantity"+"\t"+":");
- while(txt.hasNextLine())
- {
- String line=txt.nextLine();
- Scanner textline= new Scanner(line);
- In = textline.next();
- In1 = textline.next();
- In2 = textline.next();
- if(In2.equals("0"))
- {
- System.out.println(":\t"+In+"\t"+":"+"\t"+In1+"\t"+":"+"\t"+In2+"\t\t"+":" );
- }
- }
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : ");
- txt.reset();
- break;
- case "5":
- boolean Adp;
- Adp = AdminPAssword();
- if(Adp == true)
- {
- String line , Data ="";
- System.out.print ("Enter Index name: ");
- String Index = InputSC.next();
- System.out.print ("Enter new price for "+Index+":");
- String newprice = InputSC.next();
- while (txt.hasNextLine())
- {
- line = txt.nextLine();
- if(line.equals(" "))
- {
- /*continue*/
- }
- Scanner lineinput = new Scanner(line);
- String Index1;
- Index1 = lineinput.next();
- if(Index.equals(Index1))
- {
- String oldprice = lineinput.next();
- line = line.replace (oldprice,newprice);
- }
- Data = Data + line+ "\n";
- }
- try (BufferedWriter bw = new BufferedWriter(new FileWriter("src\\stock\\market\\project\\Stock.txt")))
- {
- bw.append(Data);
- }
- }
- txt.reset();
- break;
- case "6":
- Loop = false;
- break;
- default:
- System.out.print("Wrong Operation!!");
- }
- if(Loop == false)
- {
- System.out.println("");
- System.out.println(": : : : : : : : : : : : : : ");
- System.out.println(": : ");
- System.out.println(": MAIN MENU :");
- System.out.println(": : ");
- System.out.println(": [1] Add new Index : ");
- System.out.println(": [2] View User Info :");
- System.out.println(": [3] View Indices :");
- System.out.println(": [4] Delete Index : ");
- System.out.println(": [5] Sell Stock :");
- System.out.println(": [6] Buy Stock :");
- System.out.println(": [7] Exit :");
- System.out.println(": : ");
- System.out.println(": : : : : : : : : : : : : : ");
- }
- else
- {
- System.out.println("");
- System.out.println(": : : : : : : : : : : : : : ");
- System.out.println(": : ");
- System.out.println(": INDICES MENU :");
- System.out.println(": :");
- System.out.println(": [1] View ALL :");
- System.out.println(": [2] Search Index :");
- System.out.println(": [3] View Available : ");
- System.out.println(": [4] View Out of Stock : ");
- System.out.println(": [5] Edit Price : ");
- System.out.println(": [6] Back :");
- System.out.println(": : ");
- System.out.println(": : : : : : : : : : : : : : ");
- }
- }
- }
- private static void DeleteIndex() throws IOException
- {
- Scanner Dsc;
- Dsc = new Scanner (new FileReader("src\\stock\\market\\project\\Stock.txt"));
- String line , Data ="";
- System.out.print ("Enter Index name: ");
- String Index = InputSC.next();
- while (Dsc.hasNextLine())
- {
- line = Dsc.nextLine();
- if(line.equals(" "))
- {
- /*continue*/
- }
- Scanner lineinput = new Scanner(line);
- String Index1;
- Index1 = lineinput.next();
- if(Index.equals(Index1))
- {
- /*continue*/
- }
- else
- {
- Data = Data + line+ "\n";
- }
- }
- Dsc.close();
- try (BufferedWriter bw = new BufferedWriter(new FileWriter("src\\stock\\market\\project\\Stock.txt"))) {
- bw.append(Data);
- }
- }
- private static void BuyStock() throws IOException
- {
- Boolean Loop = true , Loop2 = true;
- Double Credit = 0.0 , Price = 0.0 , TPrice = 0.0, VAT ,Ofees , Comm , NDebit ;
- Integer Price1 ;
- String Amount , Data1 = "" ;
- while(Loop == true)
- {
- boolean Loop1 = true ;
- Scanner Dsc = new Scanner (new FileReader("src\\stock\\market\\project\\Stock.txt"));
- Scanner Usc = new Scanner (new FileReader("src\\stock\\market\\project\\UserFiles"));
- String line , Data ="" , Data2 = "", Data3 = "";
- System.out.print ("Enter Index name: ");
- String Index = InputSC.next();
- System.out.print ("Enter Buy Amount:");
- String NewAmount = InputSC.next();
- while (Dsc.hasNextLine())
- {
- line = Dsc.nextLine();
- if(line.equals(" "))
- {
- /*continue*/
- }
- Scanner lineinput = new Scanner(line);
- String Index1 = lineinput.next();
- String Index2 = lineinput.next();
- String Index3 = lineinput.next();
- while(Usc.hasNextLine() && Index.equals(Index1))
- {
- String line2=Usc.nextLine();
- if(line2.equals(" "))
- {
- /*continue*/
- }
- {
- Scanner lineinput1 = new Scanner(line2);
- String Index11 = lineinput1.next();
- String Index22 = lineinput1.next();
- if(Index11.equals("Credit"))
- {
- Credit = Double.parseDouble(Index22);
- Double Credit1 = Credit;
- Price = Double.parseDouble(NewAmount) * Double.parseDouble(Index2);
- Credit1 = Credit1 - Price;
- line2 = line2.replace(String.valueOf(Credit),String.valueOf(Credit1));
- Data3 = Data3 + line2 + "\n";
- }
- else
- {
- Data3 = Data3 + line2 + "\n";
- }
- }
- }
- if(Index.equals(Index1) && Credit < Price )
- {
- System.out.println ("Insuficient Balance");
- System.out.print ("Plz Try again \n");
- Data = Data +line+ "\n";
- continue;
- }
- if(Integer.parseInt(NewAmount)> Integer.parseInt(Index3)&& Index.equals(Index1))
- {
- if("0".equals(Index3))
- {
- System.out.println ("This Index is Out of Stock");
- System.out.print ("Plz Try again \n");
- }
- else
- {
- System.out.println ("Buy amount can not excide Base amount");
- System.out.print ("Plz Try again \n");
- Data = Data +line+ "\n";
- continue;
- }
- }
- if(Index.equals(Index1) && !"0".equals(Index3))
- {
- if(Credit >=Price && Loop2 == true)
- {
- DecimalFormat Df3 = new DecimalFormat(".##");
- double PriceIn = 0.0;
- PriceIn = Price + (Price * 0.0025) + (Price * 0.0003) + (Price * 0.0001);
- String OldAmount = Index3;
- Amount = NewAmount;
- NewAmount = String.valueOf(Integer.parseInt(OldAmount) - Integer.parseInt(NewAmount));
- line = line.replace (OldAmount,NewAmount);
- Price1 = Integer.parseInt(Amount) * Integer.parseInt(Index2) ;
- Data = Data +line+ "\n";
- Data1 = Data1+":\t"+Index+"\t\t->\t"+Amount+"\t\t->\t"+Index2+"\t\t->\t"+Price+"\t\t :"+"\n";
- Data2 =Index + " " + Index2 + " " + Amount + " " + Df3.format(PriceIn) + " Buy" + " Available" + "\n";
- TPrice = Price + TPrice;
- Loop2 = false;
- }
- else
- {
- Data = Data +line+ "\n";
- }
- }
- else
- {
- Data = Data +line+ "\n";
- }
- }
- Dsc.close();
- if(Loop2 == false)
- {
- try (BufferedWriter bw = new BufferedWriter(new FileWriter("src\\stock\\market\\project\\Stock.txt")))
- {
- bw.append(Data);
- }
- try (BufferedWriter bw1 = new BufferedWriter(new FileWriter("src\\stock\\market\\project\\UserFiles")))
- {
- bw1.append(Data3);
- }
- try (BufferedWriter bw2 = new BufferedWriter(new FileWriter("src\\stock\\market\\project\\UserFiles", true)))
- {
- bw2.append(Data2);
- }
- }
- Dsc.reset();
- Usc.reset();
- Loop2 = true;
- System.out.print("Would you like to Buy more [Y] [N] :");
- String YNloop;
- YNloop = InputSC.next();
- if("N".equals(YNloop) || "n".equals(YNloop) )
- {
- Loop = false;
- }
- }
- DecimalFormat Df3 = new DecimalFormat(".##");
- Comm = TPrice * 0.0025;
- VAT = TPrice * 0.0003;
- Ofees = TPrice * 0.0001;
- NDebit = TPrice + Comm + VAT + Ofees;
- System.out.println("RECIEPT");
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :");
- System.out.println(":\t"+"Issue Code"+"\t:\t"+"Quantity"+"\t:\t"+"Unit Price"+"\t:\t"+"Extension"+"\t :");
- System.out.print(Data1);
- System.out.println(": \t\t\t\t\t\t\t\t"+" __________________"+"\t :");
- System.out.println(": \t\t \t DEBIT = "+Df3.format(TPrice)+"\t\t :");
- System.out.println(":\t\t\t\t\t\t\t\t\t\t\t\t :");
- System.out.println(": \t\t \t Commision = "+Df3.format(Comm)+"\t\t :");
- System.out.println(": \t\t \t VAT = "+Df3.format(VAT)+"\t\t :");
- System.out.println(": \t\t \t SCCP FEES = "+Df3.format(Ofees)+"\t\t :");
- System.out.println(": \t\t\t\t\t\t\t\t"+" __________________"+"\t :");
- System.out.println(": \t \t\t\t\t\t NET DEBIT = "+Df3.format(NDebit)+"\t\t :");
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :");
- }
- private static void SellStock() throws IOException , NoSuchElementException
- {
- {
- Boolean Loop = true ;
- Double Credit = 0.0 , Price = 0.0 , STP = 0.0 , TPrice = 0.0, VAT ,Ofees , Comm , NDebit , Stax , GL , Value = 0.0 ;
- Integer Price1 = 0;
- String Amount , Data1 = "" ;
- while(Loop == true)
- {
- boolean Loop1 = true , Loop2 = true , Loop3 = true;
- Scanner Dsc = new Scanner (new FileReader("src\\stock\\market\\project\\Stock.txt"));
- Scanner D1sc = new Scanner (new FileReader("src\\stock\\market\\project\\Stock.txt"));
- Scanner Usc = new Scanner (new FileReader("src\\stock\\market\\project\\UserFiles"));
- Scanner U1sc = new Scanner (new FileReader("src\\stock\\market\\project\\UserFiles"));
- String line , line1 , Data ="" , Data2 = "", Data3 = "";
- System.out.print ("Enter Index name: ");
- String Index = InputSC.next();
- System.out.print ("Enter Sell Amount:");
- String NewAmount = InputSC.next();
- while(Usc.hasNextLine())
- {
- line1 = Usc.nextLine();
- if(line1.equals(" "))
- {
- /*continue*/
- }
- Scanner lineinput = new Scanner(line1);
- String Index11 = lineinput.next();
- String Index21 = lineinput.next();
- String Index31 = lineinput.next();
- String Index41 = lineinput.next();
- String Index51 = lineinput.next();
- String Index61 = lineinput.next();
- if("Credit".equals(Index11))
- {
- Credit = Double.parseDouble(Index21);
- }
- if(Integer.parseInt(Index31) < Integer.parseInt(NewAmount)&& Index.equals(Index11))
- {
- if("Buy".equals(Index51))
- {
- System.out.println ("Sell amount can not excede Base amount");
- System.out.print ("Plz Try again \n");
- break;
- }
- }
- if(Index.equals(Index11) && Loop2 == true && Index61.equals("Available") )
- {
- while(D1sc.hasNextLine())
- {
- String line11 = D1sc.nextLine();
- if(line1.equals(" "))
- {
- /*continue*/
- }
- Scanner lineinput1 = new Scanner(line11);
- String Index111 = lineinput1.next();
- String Index211 = lineinput1.next();
- if(Index.equals(Index111))
- {
- STP = Double.parseDouble(Index211);
- }
- }
- DecimalFormat Df3 = new DecimalFormat(".##");
- double PriceIn = 0.0;
- Amount = NewAmount;
- Price = Double.parseDouble(NewAmount) * STP;
- PriceIn = Price + (Price * 0.0025) + (Price * 0.0003) + (Price * 0.0001) + (Price * 0.0055);
- Data1 = Data1+":\t"+Index+"\t\t->\t"+Amount+"\t\t->\t"+Index21+"\t\t->\t"+Price+"\t\t :"+"\n";
- Data2 =Index + " " + STP + " " + Amount + " " + Df3.format(PriceIn) + " Sell" + " w" + "\n";
- TPrice = TPrice + Price;
- Loop2 = false;
- }
- }
- Usc.reset();
- String line11;
- while(U1sc.hasNextLine() && Loop2 == false)
- {
- line11 = U1sc.nextLine();
- if(line11.equals(" "))
- {
- /*continue*/
- }
- Scanner lineinput1 = new Scanner(line11);
- String Index111 = lineinput1.next();
- String Index211 = lineinput1.next();
- String Index311 = lineinput1.next();
- String Index411 = lineinput1.next();
- String Index511 = lineinput1.next();
- String Index611 = lineinput1.next();
- if("Credit".equals(Index111))
- {
- Credit = Credit + Price;
- line11 = line11.replace (Index211,String.valueOf(Credit));
- Data3 = Data3 + line11 + "\n";
- }
- else if(Index.equals(Index111) && Index611.equals("Available") && Loop3 == true)
- {
- line11 = line11.replace (Index611,"SoldOut");
- Value = Double.parseDouble(Index411);
- Data3 = Data3 + line11 + "\n";
- Loop3 = false;
- }
- else
- {
- Data3 = Data3 + line11 + "\n";
- }
- }
- String line12;
- while(Dsc.hasNextLine() && Loop2 == false)
- {
- line12 = Dsc.nextLine();
- if(line12.equals(" "))
- {
- /*continue*/
- }
- Scanner lineinput = new Scanner(line12);
- String Index12 = lineinput.next();
- String Index22 = lineinput.next();
- String Index32 = lineinput.next();
- if(Index.equals(Index12))
- {
- String NewAmount12 = String.valueOf(Integer.parseInt(Index32) + Integer.parseInt(NewAmount));
- line12 = line12.replace (Index32,NewAmount12);
- Data = Data + line12 + "\n";
- }
- else
- {
- Data = Data + line12 + "\n";
- }
- }
- if(Loop2 == false)
- {
- try (BufferedWriter bw = new BufferedWriter(new FileWriter("src\\stock\\market\\project\\Stock.txt")))
- {
- bw.append(Data);
- }
- try (BufferedWriter bw1 = new BufferedWriter(new FileWriter("src\\stock\\market\\project\\UserFiles")))
- {
- bw1.append(Data3);
- }
- try (BufferedWriter bw2 = new BufferedWriter(new FileWriter("src\\stock\\market\\project\\UserFiles", true)))
- {
- bw2.append(Data2);
- }
- }
- Loop1 = true;
- System.out.print("Would you like to Buy more [Y] [N] :");
- String YNloop;
- YNloop = InputSC.next();
- if("N".equals(YNloop) || "n".equals(YNloop) )
- {
- Loop = false;
- }
- }
- DecimalFormat Df3 = new DecimalFormat(".##");
- Comm = TPrice * 0.0025;
- VAT = TPrice * 0.0003;
- Ofees = TPrice * 0.0001;
- Stax = TPrice * 0.0055;
- NDebit = TPrice + Comm + VAT + Ofees + Stax;
- GL = NDebit - Value ;
- System.out.println("RECIEPT");
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :");
- System.out.println(":\t"+"Issue Code"+"\t:\t"+"Quantity"+"\t:\t"+"Unit Price"+"\t:\t"+"Extension"+"\t :");
- System.out.print(Data1);
- System.out.println(": \t\t\t\t\t\t\t\t"+" __________________"+"\t :");
- System.out.println(": \t\t \t Profit = "+Df3.format(TPrice)+"\t\t :");
- System.out.println(":\t\t\t\t\t\t\t\t\t\t\t\t :");
- System.out.println(": \t\t \t Commision = "+Df3.format(Comm)+"\t\t :");
- System.out.println(": \t\t \t VAT = "+Df3.format(VAT)+"\t\t :");
- System.out.println(": \t\t \t Sales Tax = "+Df3.format(Stax)+"\t\t :");
- System.out.println(": \t\t \t SCCP FEES = "+Df3.format(Ofees)+"\t\t :");
- System.out.println(": \t\t\t\t\t\t\t\t"+" __________________"+"\t :");
- System.out.println(": \t \t\t\t\t\t NET Profit = "+Df3.format(NDebit)+"\t\t :");
- System.out.println(":\t\t\t\t\t\t\t\t\t\t\t\t :");
- System.out.println(": \t \t\t\t\t\t NET Gain/Loss = "+Df3.format(GL)+"\t\t :");
- System.out.println(":\t\t\t\t\t\t\t\t\t\t\t\t :");
- System.out.println(": : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement