StudentShare
Contact Us
Sign In / Sign Up for FREE
Search
Go to advanced search...
Free

Computer Programming - Coursework Example

Cite this document
Summary
The aim of programming is to create instructions that computers will use in order to perform specific operations. This report will state how the program was developed to help the Chinese packing company use an order…
Download full paper File format: .doc, available for editing
GRAB THE BEST PAPER98.8% of users find it useful
Computer Programming
Read Text Preview

Extract of sample "Computer Programming"

Computer Programming Assignment [Insert [Insert Grade [Insert Introduction Computer programming is art of developing computer software. The aim of programming is to create instructions that computers will use in order to perform specific operations. This report will state how the program was developed to help the Chinese packing company use an order system to streamline orders from their user. System Requirements While making an order, the system should allow the user to specify the following requirements: a) The size of the container (length, height, width and/or radius). b) The grade of the card. c) Colouring required; no colouring, one or two colours. d) Whether they need any reinforcement at the bottom. e) Whether the container should have a sealable top. f) Quantity ordered for each type of container. The system should also compute the cost of the request ordered and display it to the user. Allow the user to place the order. It should also confirm to the intended user that the order will be met. System Design The system will make use of the following Object Oriented (OO) design approaches: a) Inheritance b) Encapsulation c) Polymorphism and d) Unified Modelling Language (UML) Use Case, Classes and Instance diagrams. Unified Modelling Language (UML) Diagrams. i. Use case diagram for the Ordering System. USER OBJECT ATTRIBUTES The system makes use of only one class OrderMenu. Line 12 uses “extends” keyword to indicate that the class inherits from Jpanel. Class OrderMenu is an enhanced type of Jpanel. Thus class OrderMenu is a sub class of a super class Jpanel. The “implements” keyword is used by a concrete class to indicate that it implements the interface and that each method in the interface is declared with the signature specified in the interface declaration. Note that we use an interface class instead of an abstract class since there is no default implementation to inherit as would be in abstract classes. It is also noteworthy that an interface class must be declared in a file with the same name and a .java file-name extension. Lines 60-250 declare a class OrderMenu constructor. The constructor takes no parameters hence the empty parenthesis. The class OrderMenu inherits from the following classes of package java.awt imported in the imports section: i. Class Component- A subclass of object that declares many of the attributes and behaviours common to the GUI components in the package. ii. Class Container- A subclass of component. It is used to organize and display components attached to it on the screen. iii. Class JComponent- A subclass of container. From this class we are then able to derive the rest of the components in the class including JButton, JCheckbox, and JTextfield etc. Class Hierarchy Diagram Events (methods) through which the user interacts with the system include: a) Select type of grade() b) Select quantity() c) Select colour() d) Select reinforcement() e) Select sealable() f) Enter height() g) Enter width() h) Enter length() The system responds to the user by doing the following: a) Compute cost() b) Confirm order() c) Display cost() Properties possessed by the objects include: a) Colour b) Height c) Breathe d) Length e) Surface area f) Reinforced g) Sealable Methods associated to the objects include: a) setColour() getColour() b) setHeight() getHeight() c) setBreathe() getBreathe () d) setLength() getLength() e) setSurfaceArea() getSurfaceArea f) setReinforced() getReinforced() g) setSealable() getSealable() Class diagram Class OrderMenu setColour() getColour() setHeight() getHeight() setBreathe() getBreathe() setLength() getLength() setSurfaceArea() getSurfaceArea setReinforced() getReinforced() setSealable() getSealable() ordermenu() +displayColour(colour) +diplayHeight() : double +displayBreath() : double +disLenght() : double +displaySurfaceArea() : double +displayReinforced() : Boolean +displaySealable() : Boolean Testing and evaluation The following are captured screen shots used to show how the system was tested and evaluated: Fig 1. Welcome screen Fig 2. Main Order Form. Possible input errors. Should the user click on the calculate price button before selecting the type of container and its dimensions, the system displays an error message as shown below. Should the user insert an invalid number or even a letter instead of a number, the calculate price button gives a null or a zero for the result as shown below. Should the user fail to select anything in the special features panel that is reinforced or sealable top, the default is, it is assumed that the container is not reinforced or can’t have a sealable top as appropriate. Assumptions: i. The user will only enter the exact dimensions of the desired container and that these dimensions will be within the range that the company can make. That is there is no way of checking whether the ordered dimensions can actually be met. ii. The user will intuitively know how to use the system. That is there is no help menu included in the system. Limitations: i. The colour option is not incorporated in the costing. ii. You can only choose to have one colour. iii. Once the user clicks the container button, they can’t cancel the process. They have to enter the dimensions and click reset later. iv. Should the user desire to reset after having made several entries, all the entries are reset. That is you can’t undo a particular entry. Appendixes Source code. package boxtubes; import java.awt.event.*; import java.awt.*; import java.io.*; import java.util.*; import java.text.*; import javax.swing.*; import javax.swing.border.*; class ordermenu extends JFrame implements ActionListener { JButton jbtRec;// Rectangular shaped JButton jbtCirc;//Circular shaped JButton jbtTri;//Triangular shaped JButton jbtReinforced,jbtSealable; JButton jbBack,jbconfirmorder; JButton jbtPrice, jbtReset, jbtMore; JRadioButton jrbNoColor, jrb1Color, jrb2Color, jrbGrade1, jrbGrade2, jrbGrade3; JTextField jtfItem,jtfitems, jtfPrice, jtfSub, jtfRein, jtfSeal, jtf1Co, jtf2Co, jtfTax, jtfTotal; JComboBox jcbquantity, jcbRein, jcbSeal, jcbColor; JTextArea jtasummary,jtaItems; String[] items = new String[50]; double[] cost = new double[50]; double[] quantity = new double[50]; double[] price2 = new double[50]; int x=0, y=0, z=0; double subtotal=0, area=0, reinfcd=0, sealable=0, total=0, price=0, x1, x2, x3, a, b, c; String sizeConvert=""; DecimalFormat df=new DecimalFormat("0.00"); //Main method public static void main(String[] args){ ordermenu frame = new ordermenu(); frame.pack(); frame.setTitle("Ordering System"); frame.setSize(800, 550); frame.setVisible(true); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); } //Constructor public ordermenu(){ Container cont = getContentPane(); cont.setLayout(new GridLayout(3,1)); JPanel p01 = new JPanel(new GridLayout(2,2)); JPanel p001 = new JPanel(new GridLayout(1,3,1,1)); p001.add(jbtRec = new JButton("RECTANGULAR")); p001.add(jbtTri = new JButton("TRIANGULAR")); p001.add(jbtCirc = new JButton("CIRCULAR")); p001.setBackground(Color.LIGHT_GRAY); TitledBorder centerBorderMD = BorderFactory.createTitledBorder("SELECT DESIRED SHAPE HERE"); centerBorderMD.setTitleJustification(TitledBorder.CENTER); p001.setBorder(centerBorderMD); p01.add(p001); JPanel p0001 = new JPanel(new GridLayout(2,1,1,1)); p0001.add(jcbRein = new JComboBox(new Object[]{"REINFORCED","YES","NO"})); jcbRein.setToolTipText("Choose whether a reinforced container"); p0001.add(jcbSeal = new JComboBox(new Object[]{"SEALABLE TOP","YES","NO"})); jcbSeal.setToolTipText("Choose whether a sealable container"); p0001.setBackground(Color.LIGHT_GRAY); TitledBorder centerBorderSpecial = BorderFactory.createTitledBorder("SPECIAL FEATURES"); centerBorderSpecial.setTitleJustification(TitledBorder.CENTER); p0001.setBorder(centerBorderSpecial); p01.add(p0001); //----------------------------------------------------------------------------------------------------------- JPanel p010=new JPanel(new GridLayout(2,2,1,1)); p010.add(new JLabel("Choose colour : ")); p010.add(jcbColor = new JComboBox(new Object[]{"Red","Blue","Yellow","Green","Brown"})); jcbColor.setToolTipText("Select The Desired Colour"); //----------------------------------------------------------------------------------------------------------- JPanel p011=new JPanel(new GridLayout(2,3,1,1)); p011.add(new JLabel("Item : ")); p011.add(jtfItem = new JTextField(10));//item try catch p011.add(new JLabel("")); p011.add(new JLabel("Quantity :")); p011.add(jcbquantity = new JComboBox(new Object[]{"1","2","3","4","5","6","7","8","9","10"})); jcbquantity.setToolTipText("Select Your Quantity"); p011.add(new JLabel("")); jtfItem.setEditable(false); p011.setBorder(new TitledBorder("")); p011.setBackground(Color.LIGHT_GRAY); JPanel p012=new JPanel(new GridLayout(1,3,20,20)); p012.setBackground(Color.LIGHT_GRAY); p012.add(jrbGrade1 = new JRadioButton("Grade 1")); jrbGrade1.setBackground(Color.LIGHT_GRAY); p012.add(jrbGrade2 = new JRadioButton("Grade 2")); jrbGrade2.setBackground(Color.LIGHT_GRAY); p012.add(jrbGrade3 = new JRadioButton("Grade 3")); jrbGrade3.setBackground(Color.LIGHT_GRAY); p012.setBorder(new TitledBorder("Grade Required")); p012.setBackground(Color.LIGHT_GRAY); //Set default size jrbGrade3.setSelected(true); ButtonGroup group = new ButtonGroup(); group.add(jrbGrade1); group.add(jrbGrade2); group.add(jrbGrade3); JPanel p013=new JPanel(new GridLayout(2,1)); p013.setBackground(Color.LIGHT_GRAY); p013.add(p012); p013.add(p011); JPanel p014=new JPanel(new GridLayout(2,1)); p014.add(p013); p014.add(p010); JPanel p015=new JPanel(new GridLayout(1,2)); p015.add(p01); p015.add(p014); cont.add(p015); //--------------------------------------------------------------------------------------- JPanel p02 = new JPanel(new GridLayout(4,3,3,3)); p02.add(new JLabel("")); p02.add(new JLabel("")); p02.add(new JLabel("")); p02.add(new JLabel("")); p02.add(jbtMore = new JButton("Add More")); jbtMore.setToolTipText("Add More Containers"); p02.add(new JLabel("")); p02.add(new JLabel("")); p02.add(jbtReset = new JButton("Reset")); p02.add(new JLabel("")); p02.add(new JLabel("")); jbtReset.setToolTipText("Clear All Enterences"); p02.setBackground(Color.LIGHT_GRAY); JPanel PA=new JPanel(new GridLayout(2,1));//new BorderLayout(5,5) PA.add(p02,BorderLayout.CENTER); JPanel p021 = new JPanel(new GridLayout(8,3)); p021.add(jbtPrice = new JButton("Calculate Price $")); jbtPrice.setToolTipText("View Price Order"); p021.add(jtfPrice = new JTextField(4)); jtfPrice.setEditable(false);//User cannot edit content p021.add(new JLabel("")); p021.add(new JLabel("SubTotal $")); p021.add(jtfSub = new JTextField(8)); p021.add(new JLabel("")); jtfSub.setEditable(false); p021.add(new JLabel("Reinforced $")); p021.add(jtfRein = new JTextField(8)); p021.add(new JLabel("")); jtfRein.setEditable(false); p021.add(new JLabel("Sealable $")); p021.add(jtfSeal = new JTextField(8)); p021.add(new JLabel("")); jtfSeal.setEditable(false); p021.add(new JLabel("One Colour $")); p021.add(jtf1Co = new JTextField(8)); p021.add(new JLabel("")); jtf1Co.setEditable(false); p021.add(new JLabel("Two Colors $")); p021.add(jtf2Co = new JTextField(8)); p021.add(new JLabel("")); jtf2Co.setEditable(false); p021.add(new JLabel("Total $")); p021.add(jtfTotal = new JTextField(8)); p021.add(new JLabel("")); p021.add(new JLabel("")); p021.add(new JLabel("")); p021.add(new JLabel("")); jtfTotal.setEditable(false); p021.setBorder(new TitledBorder("Price Detail")); p021.setBackground(Color.LIGHT_GRAY); JPanel p03=new JPanel(new GridLayout(1,1,20,20));; JPanel p2=new JPanel(new GridLayout(1,2)); p2.add(PA); p2.add(p03); cont.add(p2); p03.add(jtasummary = new JTextArea(10,10)); JScrollPane ScrollPaneSummary=new JScrollPane(jtasummary); p03.add(ScrollPaneSummary); jtasummary.setEditable(false); jtasummary.setToolTipText("Summary Order Details"); TitledBorder centerBorderSummary = BorderFactory.createTitledBorder("Order Detail"); centerBorderSummary.setTitleJustification(TitledBorder.CENTER); p03.setBorder(centerBorderSummary); p03.setBackground(Color.GRAY); JPanel p031=new JPanel(new FlowLayout(FlowLayout.CENTER)); p031.add(jbBack = new JButton("Back Main Page"));//2nd row jbBack.setToolTipText("Back to main Menu"); p031.add(jbconfirmorder=new JButton("Confirm Order"));//2nd row jbconfirmorder.setToolTipText("Confirm Your Order & Submit"); JPanel p3=new JPanel(new BorderLayout(5,5)); p3.add(p021); p3.add(p031,BorderLayout.SOUTH); cont.add(p3); jbBack.addActionListener(this); jbconfirmorder.addActionListener(this); jbtRec.addActionListener(this); jbtCirc.addActionListener(this); jbtTri.addActionListener(this); jcbRein.addActionListener(this); jcbSeal.addActionListener(this); jrbGrade1.addActionListener(this); jrbGrade2.addActionListener(this); jrbGrade3.addActionListener(this); jbtPrice.addActionListener(this); jcbquantity.addActionListener(this); jbtMore.addActionListener(this); jbtReset.addActionListener(this); } public void actionPerformed(ActionEvent e){ if (e.getSource() == jbtReset){ //Cancel jtfItem.setText(""); x=0;y=0;z=0; jcbquantity.setSelectedIndex(0); jcbRein.setSelectedIndex(-1); jcbSeal.setSelectedIndex(-1); jtfPrice.setText(null); jtfSub.setText(null); jtfTotal.setText(null); jtasummary.setText(null); subtotal=0; sealable=0; reinfcd=0; total=0; price=0; } if (e.getSource() == jbBack){//Back mainmenu frame = new mainmenu(); frame.setTitle("MAIN "); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500,500); frame.setVisible(true); frame.setResizable(true); frame.setLocationRelativeTo(null); this.dispose(); } //More if user want to add more item if(e.getSource()==jbtMore){ jcbquantity.setSelectedIndex(0); jtfPrice.setText(""); jtfItem.setText(""); } if (e.getSource() == jbtRec){ jtfItem.setText(("RECTANGULAR")); String a1 = JOptionPane.showInputDialog( "Enter the height" ); String b1 = JOptionPane.showInputDialog( "Enter the length" ); String c1 = JOptionPane.showInputDialog( "Enter the width" ); a = Double.parseDouble((String)a1); b = Double.parseDouble((String)b1); c = Double.parseDouble((String)c1); area = 2 * a * b + 2 * a * c + 2 * b * c ; items[x] = "Size of your box is :"+ df.format(area); cost[x] = area; } if (e.getSource() == jbtTri){ jtfItem.setText(("TRIANGULAR")); String a1 = JOptionPane.showInputDialog( "Enter the height" ); String b1 = JOptionPane.showInputDialog( "Enter the length" ); String c1 = JOptionPane.showInputDialog( "Enter the width" ); a = Double.parseDouble((String)a1); b = Double.parseDouble((String)b1); c = Double.parseDouble((String)c1); area = a * b + a * c + b * c + Math.sqrt(a * a + b * b) * c ; items[x] = "Size of your box is :"+df.format(area); cost[x] = area; } if (e.getSource() == jbtCirc){ jtfItem.setText(("CIRCULAR")); String b1 = JOptionPane.showInputDialog( "Enter the radius" ); String c1 = JOptionPane.showInputDialog( "Enter the height" ); b = Double.parseDouble((String)b1); c = Double.parseDouble((String)c1); area = 6.34 * b * b + 6.34 * b * c; items[x] = "Size of your box is :"+df.format(area); cost[x] = area; } //To display the price for selected item if (e.getSource() == jbtPrice){ if(jtfItem.getText().equalsIgnoreCase("") ){ jtfItem.requestFocus(); jtfPrice.setText(null); jtfSub.setText(null); jtfTotal.setText(null); jtasummary.setText(null); subtotal=0; total=0; price=0; JOptionPane.showMessageDialog(null,"Error, Please Enter Item First");//edit } else{ int r = jcbRein.getSelectedIndex(); int s = jcbSeal.getSelectedIndex(); if (r == 1 && s == 1){ calculateprice(); while(z Read More
Cite this document
  • APA
  • MLA
  • CHICAGO
(“Computer Programming Coursework Example | Topics and Well Written Essays - 1000 words”, n.d.)
Computer Programming Coursework Example | Topics and Well Written Essays - 1000 words. Retrieved from https://studentshare.org/information-technology/1595762-computer-programming
(Computer Programming Coursework Example | Topics and Well Written Essays - 1000 Words)
Computer Programming Coursework Example | Topics and Well Written Essays - 1000 Words. https://studentshare.org/information-technology/1595762-computer-programming.
“Computer Programming Coursework Example | Topics and Well Written Essays - 1000 Words”, n.d. https://studentshare.org/information-technology/1595762-computer-programming.
  • Cited: 0 times

CHECK THESE SAMPLES OF Computer Programming

Graph theory Applications in Computer programming

Graph theory Applications in Computer Programming Two applications of Graph theory in Computer Programming In computing, programs are designed to successfully handle large graphs that are encountered in form of networks such as transportation networks, electrical networks, flow networks, and PERT among others (Kasyanov & Evstigneev, 1994).... Use of Computer Programming graph theory in computer science In Computer Programming, Kasyanov & Evstigneev (2000) reveal that algorithms and graph-theoretical methods are applied in order to intuitively present situations defined to be complicated....
3 Pages (750 words) Essay

Computer, Programming,signal Processing

The electroencephalogram system consists of some connecting devices which are meant to connect with both the scalp of the individual and personal computer.... The scalp provides information to the small box attached to the computer system and the whole device after processing the information sent back to the user.... These reflections are passed in to the storage unit of the computer and the electrodes kept on the scalp region send signals of voltage variations to the amplifier....
4 Pages (1000 words) Essay

Computer Programming: The Advantages of Object Oriented Programming

C-Sharp (C#) language-based software developers having six months of Computer Programming expertise and experience are capable to obtain full-time jobs, contracting or consulting positions at any province, state or city.... One of the most excellent secrets of becoming a computer programmer is that we are able to learn Computer Programming at home as well as improve our abilities to a capable level without initially obtaining a programming job.... As it is figured out the total cost of investments of taking expertise and effective knowledge of C-sharp Computer Programming training would be small enough in comparison to how much we pay for studying law or medicine in college....
6 Pages (1500 words) Assignment

How Will Computer Information System Fit Into Your Professional Life

How Will Computer Information System Fit Into One's Professional Life Computer Programming languages There are many Computer Programming languages which perform different tasks for different industries.... Computer Programming for generating visual stimuli.... Concepts, techniques, and models of Computer Programming.... Python and Java are among these programming languages.... Python and Java are among these programming languages....
2 Pages (500 words) Essay

Career Profile - Computer Programmer

The writer of the essay "Career Profile - Computer Programmer" suggests that Computer Programming is an intriguing field to those with an interest in it.... When I thought of who I would interview about Computer Programming, Matt came to mind.... During his senior year in high school, he decided to pursue Computer Programming as a career.... Adams observes that as the world advances into more digital engagements, courses such as computer science, programming and engineering would be lucrative in the near future....
4 Pages (1000 words) Essay

Computer Programming Techniques

The author of the paper "Computer Programming Techniques" concerns a clear outline to the users of the program on technical problems solved, variables, and constants that they deal with, the guidelines recommend when carrying out the designing program tests, modern engineering practice description.... he variables used in programming include the inductive reactance, capacitive, complex impedance....
6 Pages (1500 words) Assignment

Teaching and Learning Computer Programming by Mayer

The R package aims to help the common citizen analyze the government's and The paper "Teaching and Learning Computer Programming by Mayer" is a delightful example of an article on information technology.... It is interesting to learn the efforts put in place by different governments throughout the world to encourage Computer Programming.... This article elaborates the importance and relationship of programming to other disciplines such as literature, arithmetic, and chemistry....
2 Pages (500 words) Assignment

The Magic Touch

This paper 'The Magic Touch " focuses on the fact that in hopes of pursuing (or at least appreciating) a career in Computer Programming in the United States, it is beneficial to understand the (I) education/training required, (II) great job options, and (III) the future outlook of the career.... Another quality career/job one can pursue through the likes of Computer Programming is a software application developer (Greer).... Lastly, one must consider the short-term and long-term outlook of the future of Computer Programming....
10 Pages (2500 words) Thesis Proposal
sponsored ads
We use cookies to create the best experience for you. Keep on browsing if you are OK with that, or find out how to manage cookies.
Contact Us