ITECH7410 Software Engineering Methodologies
12 Pages980 Words92 Views
Federation University Australia
Software Engineering Methodologies (ITECH7410)
Added on 2020-02-24
ITECH7410 Software Engineering Methodologies
Federation University Australia
Software Engineering Methodologies (ITECH7410)
Added on 2020-02-24
ShareRelated Documents
User AnalysisMathematics Learners and Scientists need to use this applicationDisplay Content AnalysisIn the quadratic equation, we need to display the type of the roots (equal, unequal or complex), two roots and format of quadratic equationInterface Design
Modelling of the ProblemFor example,a=1b=3c=2b^2-4ac=9 – 4 * 1 * 2 = 9 – 8 = 1-b+sqrt(b^2-4ac)=-3+1=-2-b-sqrt(b^2-4ac)=-3-1=--4If a=0, it is not a quadratic equationIf (b^2-4ac) is zero, roots are equalIf b^2-4ac) is greater than zero, roots are unequalIf (b^2-4ac) is less than zero, roots are complexDescription and Justification of Software Tools ChosenI choose Java Tool to design to solve the quadratic equation. It is an open source, platform independent, Robust, portability and easy to distribute.
CodeFile: Quadratic.javaimport java.awt.Color;import java.awt.Font;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.JTextField;publicclassQuadraticFormextends JFrame implements ActionListener {private JLabel lblTitle,lblA,lblB,lblC,lblResult,lblResultEqn;private JTextField txtA,txtB,txtC;private JButton btnCalc,btnClear,btnExit;private JTextArea txtResult;private JScrollPane scrPane;public QuadraticForm(){lblTitle=new JLabel("Quadratic Equation (ax^2+bx+c)");lblTitle.setBounds(125,30, 300, 30);lblTitle.setFont(new Font("Arial",Font.BOLD,18));lblTitle.setForeground(Color.BLUE);lblA=new JLabel("Value of a");lblA.setBounds(50,100, 100, 25);txtA=new JTextField("0");txtA.setBounds(250, 100, 150, 25);lblB=new JLabel("Value of b");lblB.setBounds(50,150, 100, 25);txtB=new JTextField("0");txtB.setBounds(250, 150, 150, 25);lblC=new JLabel("Value of b");lblC.setBounds(50,200, 100, 25);txtC=new JTextField("0");txtC.setBounds(250, 200, 150, 25);btnCalc=new JButton("Calculate");btnCalc.setBounds(50, 250, 100, 30);btnCalc.addActionListener(this);
btnClear=new JButton("clear");btnClear.setBounds(210, 250, 100, 30);btnClear.addActionListener(this);btnExit=new JButton("Exit");btnExit.setBounds(370, 250, 100, 30);btnExit.addActionListener(this);txtResult=new JTextArea();scrPane = new JScrollPane(txtResult);scrPane.setBounds(50, 300, 420, 150);add(lblTitle);add(lblA);add(txtA);add(lblB);add(txtB);add(lblC);add(txtC);add(btnCalc);add(btnClear);add(btnExit);add(scrPane);setLayout(null); setTitle("Quadratic Equation Solution"); setSize(550,600);setVisible(true);}@Overridepublicvoid actionPerformed(ActionEvent e) {if(e.getSource()==btnCalc){doublea,b,c,sqpart,root1,root2;try{a=Double.parseDouble(txtA.getText());b=Double.parseDouble(txtB.getText());c=Double.parseDouble(txtC.getText());if(a!=0){sqpart= Math.pow(b, 2) - 4 * a * c;if(sqpart==0){root1=-b/(2*a);root2=root1;txtResult.setText("Both roots are equal\n\nRoots are "+root1+","+root2+"\n\nEquations are "+a+"x^2+"+b+"x+"+c);}elseif(sqpart>0){root1=(-b+Math.sqrt(sqpart))/(2*a);
End of preview
Want to access all the pages? Upload your documents or become a member.