Professional Documents
Culture Documents
ASSIGNMENT HNCS 003 PROGRAMMING CONCEPTS Submitted by: - Aaqib Rashid (BTEC HND in Computing) ID # 08604
Department of Science and Technology The London College UCK, Victoria Gardens London Table Of Contents
HNCS 003 Programming Concepts H1
Page Introduction .. 4 TASK # 1 1.1) Input/output layout .. 4 TASK # 2 2.1) Graphical user Interface (GUI) 2.2) Flow Chart 7 5
TASK # 1 1.2) Code of Assignment . .. TASK # 3 3.1) Testing .. 17 a) Black Box Testing .. 17 b) White Box Testing 18 10
Bibliography 27
Introduction
Reina DVD is a small store owned by reina. The stores sells videos and DVDs , among other things. He plans to eventually develop a sales transaction processing system that allows her cashiers to enter data for DVD purchase and output information such as Quantities, prices, Subtotal, Total. If quantity is greater than 15 of the same DVD title then there is a discount of 25 %. A total of 10-14 DVDs results in 17 % discount, and a total of 5-9 DVDs results in a 12 % discount. A total of less than 5 results no discount.
TASK: 1
These Output boxes are used for Outputs after performing processes on the input and in this project Outputs are Discount Available, Subtotal Cost, VAT and Total Cost.
The Below Screen shot displays a confirmation Box. From This User Can buy another DVD or cancel the transaction.
10
11
Features not to be tested The data stored in to the file. Flow Charts. JSD (Jackson Structure Diagram).
12
Approach The approach which is to be used in this assignment is Black box testing and white Box testing. Item Pass/Fail Compare and contrast the inputs and expected output. If actual output is same as expected output then Item or feature is passed otherwise fail. TASK # 1 1.2) CODE OF ASSIGNMENT
Below is the code of Class DVD, in which showInputDialog is used for the Input Title, Identification Code, Quantity and Price of DVD.
package javaapplication5; import java.io.*; import static javax.swing.JOptionPane.*; /** * * @author Aaqib
HNCS 003 Programming Concepts H1
13
*/ public class Dvd { // INPUT DIALOGS FOR TITLE,ID,Quantity And Price String TitleStr = showInputDialog("THE TITLE OF DVD"); String IdStr= showInputDialog("The Identification Code"); String QStr= showInputDialog("The Quantity of DVD"); long quan = Long.parseLong(QStr); String PStr =showInputDialog("THE PRICE OF DVD"); double price = Double.parseDouble(PStr); }
Below is the code of Class Transaction, in which Selection statements are used for calculating Discount price.
public class Transaction { // calculate the Discount for the transaction public double discount(long quan, double price){ double cost = quan * price; if (quan >= 15){ cost = cost * 0.25; }else if (quan>=10 && quan <=14 ){ cost = cost * 0.17; }else if (quan>=5 && quan <=9 ){ cost = cost * 0.12;
HNCS 003 Programming Concepts H1
14
MAIN CLASS
This is a main class of a program which calculates the Discount Available, Subtotal Cost, VAT and Total Cost then displays. Furthermore, it creates a text file named file and then write all the data in to the file. Here is the code of the main class
>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<< /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javaapplication5;
//import java.util.Locale;
import java.io.*; // import the java library import static javax.swing.JOptionPane.*; HNCS 003 Programming Concepts H1
15
import java.io.IOException; import java.text.DecimalFormat; /** * * @author Aaqib */ public class Main {
public static void main(String[] args) throws IOException { // Declare the variable double type which store the total Cost
double totalCost = 0; boolean flag = true; while(flag){ try { //DataOutputStream first = new BufferedOutputStream(new FileOutputStream( ))); // Saves the text file in to a Files folder in drive C PrintWriter first = new PrintWriter(new BufferedWriter(new FileWriter(new File("C:file.txt")))); // Declare the object for Dvd class Dvd obj1 = new Dvd(); // Declare the object for Dvd class Main obj = new Main(); HNCS 003 Programming Concepts H1 DataOutputStream(new
16
// Declare the object for Dvd class Transaction obj2 = new Transaction();
// Using object of Main class calling the discount method double disc = obj2.discount(obj1.quan, obj1.price); // Displays The Discount Price showMessageDialog(null,"Discount Available: "+""+ disc); // calculating The Cost after discount double cost = (obj1.quan * obj1.price)-disc; // Displays The Discount Price showMessageDialog(null,"Sub Total Cost: "+""+cost); // Calculating VAT double subtotal = ((obj1.quan * obj1.price)*0.20); showMessageDialog(null," The VAT is: "+""+subtotal); double SubTotal = cost + subtotal; totalCost = totalCost + SubTotal; // Writing in to the file first.write("Title of Dvd =" + obj1.TitleStr); first.write("\r\n"); first.write("ID No. of Dvd =" + obj1.IdStr); first.write("\r\n"); first.write("Quantity of Dvd =" + obj1.QStr); first.write("\r\n"); first.write("Price of Dvd =" + obj1.PStr); first.write("\r\n"); first.write("Discount Available =" + Double.toString(disc)); first.write("\r\n"); HNCS 003 Programming Concepts H1
17
first.write("Subtotal Cost = " + Double.toString(cost)); first.write("\r\n"); first.write("V.A.T = " + Double.toString(subtotal)); first.write("\r\n"); first.write("Total Cost = " + Double.toString(totalCost));
//first.writeString("Price of Single Dvd =" + PStr); first.close(); } catch (Exception e){ // File is not present System.err.println("FILE NOT FOUND"); } // Want to shop another DVD int returned = showConfirmDialog(null, "Want to Buy Another Dvd ?"); // Dont want to shop more than No will be clicked this terminate the program if(returned==1 ){flag = false;} else if (returned ==2){showMessageDialog(null,"NO PROBLEM HAVE A NICE DAY"); flag = false; } } // Displays total cost of a Entire Transaction showMessageDialog(null,"Total Cost of Transaction: "+ totalCost +""); try { Thread.sleep(500); HNCS 003 Programming Concepts H1
18
TASK # 3
TESTING
19
20
21
22
23
ACTUAL OUTPUTS
24
25
So it is clear from the above screen shots that that expected and real outputs are same. Hence the Program is working accurately
TASK # 4
HNCS 003 Programming Concepts H1
26
4.1 ) USER GUIDE DOCUMENT a)Input When entering the input in to the system at that time user must not enter the alpha value in quantity and price. If done then entire program will be crash. Once all input is done correctly then it will be entered in to the processing stage. b)Process In process there are calculating Discount, VAT, and Subtotal Cost and then finally display. While Calculating Discount User must know that if he enters the DVD quantity more or equal then 15 then he will get 25 % of discount, a total of 1014 DVD results 17 %, 5-9 DVD gives 12 % discount and less than 5 DVD gives no discount. c)Confirmation Dialog After buying a DVD of same title at the end of a transaction confirmation Box is displayed to ensure that Client want to buy more DVD? If yes then all the process will be repeated again if NO then total cost of that transaction will be
HNCS 003 Programming Concepts H1
27
displayed. If client want to CANCEL then the message will be displayed No problem Have a nice day d)Output After calculating all the process finally output will be displayed in the form of a total Cost of a transaction.
4.4) Testing report It is clear from the above testing task (Black box testing and white box testing) and screen shots that this programs expected output and actual output is same so this program works good and according to the demand of user.
28
SELF EVALUATION This assignment is a first step that leading towards the vast field of programing. The assignment itself gives a clear idea about the basic structure of programming concepts. Furthermore, this assignment elaborates to me that how to tackle with a classes and objects.
a) Interesting Part This assignment was thoroughly so practical and I also prefer practical things instead of theoretical. The most interesting part of this assignment was designing a Jackson structure Diagram and Flow chart. b) Weakness The planning and analysis of the assignment may not be sufficient. The bibliography provided is not sufficient that means only 2.
HNCS 003 Programming Concepts H1
29
a) Strong Part I have provided the Testing in detail. I also have put the focus on Harvard Referencing Style. Implementing a program in a required way. a) Knowledge Gained While preparing this assignment I come to know about different concepts of Programming as Im totally new in java so I gained many of basic concepts and writing syntax of java. I knew how to design and Implement program in a java To prepare Flow charts.
30
REFRENCES
a) Webopedia (2010) Black Box testing : Available from <http://www.webopedia.com/TERM/B/Black_Box_Testing.htm l> [Accessed 21 Dec 2010]
b) Build Security In (2010) White Box Testing : Available from <https://buildsecurityin.us-cert.gov/bsi/articles/bestpractices/white-box/259-BSI.html> [Accessed 21 Dec 2010]
c)
Oracle(2010) Essential of Java Programming Part 1 : Available from<http://www.oracle.com/technetwork/java/index -138747.html> [Accessed 22 Dec 2010]
31 d)
Design Shop (2010) Assessment : Available from <http://www.edtech.vt.edu/edtech/id/assess/items.ht ml> [Accessed 22 Dec 2010. Bibliography
A)
Peter van roy and seif haradi. (2004). Programming concepts. In: Brain Harvey Concepts, Techniques, and Models of Computer Programming. Belgium: Joseph. p3858. William joseph (2001). Java Basics . In : Andrew Publication Java development and concepts. (Unknown) p 120-150
B)