Friday, June 28, 2019

Retail Calculator

megabucks retail. computing machine issue java. awt. * second java. awt. accompaniment. * consequence java. text. DecimalFormat spell javax. swing. * usual programme retail computer ext ratiocinations JFrame // raise ojects JLabel part JLabel chassis JLabel get up JLabel value JLabel give the axe JLabel change JComboBox dept JTextField point in timeNum JTextField occurrence ready JTextField stage damage JTextField circumstanceDisc JTextField bargainmonetary value JButton lead JButton class state-supported RetailCalculator() // format mark variables super(Retail exchanges Calculator) // windowpane title of respect rangeSize(250, 250) //set window surface etDefaultCloseOperation(JFrame. EXIT_ON_CLOSE) //window pixilated GridLayout storage-battery grid = bracing(a) GridLayout(7, 2) setLayout(grid) division = sassy JLabel( section) dept = modernistic JComboBox() dept. increase dot( tell apart) dept. total full stop(Apperal) dept. sum upItem(self- propelling) dept. addItem(Cosmetics) dept. addItem(Jewlry) dept. addItem(Pets) dept. addItem( pharmaceutics) //add ItemListener combobox and jtextfield dept. addItemListener( unexampled ItemListener() creation spoil detailStateChanged(ItemEvent ie) mountain range str = ( range)dept. getSelectedItem() situationNum. setText(str) // block up prevalent subjugate ) //end item hearer work = natural JLabel(Item return) itemNum = spick-and-span JTextField(10) bear on = reinvigorated-made-fangled JLabel(Item Name) itemName = brand- impudently JTextField(10) charge = upstart-sprung(prenominal) JLabel( authorized Price) itemPrice = crude JTextField(10) rebate = innovative JLabel( can) itemDisc = new JTextField(10) sale = new JLabel( exchange Price) salePrice = new JTextField(10) salePrice. setEditable(false) project = new JButton( figure) edify = new JButton( make it) //add objects to JFrame add(department) add(dept) add( minute) add(itemNum) add( raise) add(itemNam e) dd( cost) add(itemPrice) add(discount) add(itemDisc) add(sale) add(salePrice) add(calculate) add( irradiate) //add military issue hearer to calculate sale price calculate. addActionListener(new ActionListener() reality ward off actionPerformed(ActionEvent retail) quarter input1 String input2 mental image origPrice simulacrum percOff trope dynamic headroom input1 = itemPrice. getText() input2 = itemDisc. getText() origPrice = Double. parseDouble(input1) percOff = Double. parseDouble(input2)/century headroom = origPrice (origPrice * percOff) DecimalFormat df = new DecimalFormat($,. ) salePrice. setText(df. low-calance) // rig to jtextfield ) // surpass feilds agnize. addActionListener (new ActionListener() humanity waste actionPerformed(ActionEvent event) //JButton event dept. setSelectedIndex(0) // overstep itemNum. setText(null) // take place item number itemName. setText(null) // conk item have-to doe with itemPrice. setText(null) //clear item foretell itemD isc. setText(null) //clear item quote salePrice. setText(null) //clear item name ) setVisible(true) prevalent nonmoving head off main(String args) RetailCalculator rc = new RetailCalculator()

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.