1 / 6

Team Assignment presentation

Be All You Can Be. Team Assignment presentation. Integer type arrPur [] (mảng lưu trữ hàng nhập vào) arrUnitCost [] (mảng lưu trữ đơn giá hàng nhập vào) i = 0; ( i là biến chạy sử dụng cho 2 mảng ở trên) p = 0 ; ( p là biến dùng để chỉ số lượng hàng nhập vào mỗi đợt)

ion
Download Presentation

Team Assignment presentation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Be All You Can Be Team Assignment presentation

  2. Integer type arrPur[](mảng lưu trữ hàng nhập vào) arrUnitCost[](mảng lưu trữ đơn giá hàng nhập vào) i = 0; (i là biến chạy sử dụng cho 2 mảng ở trên) p= 0; (p là biến dùng để chỉ số lượng hàng nhập vào mỗi đợt) c= 0; (c là biến dùng để chỉ giá tiền mặt hàng nhập vào) s= 0; (s là biến dùng để chỉ số hàng bán ra mỗi đợt) Integer type totalSale= 0;(tổng giá tiền bán ) totalPur = 0;(tổng giá trị nhập vào ) Beginning= 0;(tổng giá trị hàng tồn kho) Ending= 0;(tổng giá trị các phiên giao dịch trong tháng ) String type Trans= “ “ ; (phiên giao dịch )

  3. While(hasNextline) trans = Transaction if (trans = “Beginning Inventory” ) do p = get Purchase Unit c = get Unit Cost do Begin(p,c) function else if(trans = “Purchase”) do p = get Purchase Unit c = get Unit Cost do Purchase(p,c) function else if(trans = “sale”) do s = get Sold Unit do Sale(s) function else Ending = Beginning +totalPur – totalSale output Ending output totalSalse break //gán giá trị Purchase cho p //gán giá trị Unit Cost cho c //gọi hàm Begin và truyền vào 2 tham số p,c //gọi hàm Purchase và truyền vào 2 tham số p, c //gọi hàm Sale và truyền vào tham số s

  4. // Hàm cần truyền 2 tham số : p là đơn vị mặt hàng nhập vào c là giá mặt hàng //Hàm sẽ lưu trữ p, c vào arrPur[] , arrUnitCost[] // Tính tổng giá trị nhập vào totalPur Purchase(int p, int c) i = i + 1; arrPur[i] = p; arrUnitCost = c; totalPur += arrPur[i] * arrUnitCost[i] //lấy giá trị p lưu vào mảng //lấy giá trị c lưu vào mảng //tính tổng giá trị phiên nhập vào

  5. //hàm thực hiện lưu giá trị hàng tồn kho vào mảng và tính tổng giá trị hàng tồn kho (hiện tại hàng tồn kho chỉ là 1 mặt hàng với 1 giá trị tiền) Begin(p,c) arrPur[i] = p arrUnitCost[i] = c Beginning = arrPur[i] * arrUnitCost[i] //lưu giá trị p vào mảng //lưu giá trị c vào mảng //tính tổng giá trị hàng tồn kho

  6. Sale(int s) Boolean done = false While (done is false ) do if(s > arrPur[i]) do s = s – arrPur[i] totalSale = totalSale + arrPur[i] * arrUnitCost[i] delete arrPur[i] delete arrUnitCost[i] i = i – 1 if(s = arrPur[i]) do totalSale = totalSale + arrPur[i] * arrUnitCost[i] delete arrPur[i] delete arrUnitCost[i] i = i – 1 done = true if(s < arrPur[i]) do arrPur[i] = arrPur[i] – s totalSale = totalSale + s * arrUnitCost[i] done = true //xóa phần tử tại i trong mảng //xóa phần tử tại i trong mảng //xóa phần tử tại i trong mảng //xóa phần tử tại i trong mảng

More Related