Any ideas of how an input or output file could be included in this program in a useful way? Also how would it be executed? | Cheap Nursing Papers

Any ideas of how an input or output file could be included in this program in a useful way? Also how would it be executed?

Any ideas of how an input or output file could be included in this program in a useful way? Also how would it be executed?

package SizeConverterArray;

import java.awt.*;

import java.awt.event.*;

import java.applet.*;

import javax.swing.*;

public class SizeConverterArray extends Frame implements ItemListener, ActionListener

{

 private String[] Item = {“Nike”, “Adidas”, “Balenciaga(EU)”, “Puma”, “Timberland(Boots)”}; // array

 JComboBox convertFrom, convertTo;

 JTextField txtFrom, txtTo;

 JButton compute, exit;

 JLabel from, to;

 JLabel lblFrom, lblTo;

 JPanel mainPanel = new JPanel();

 double input = 0;

 double result = 0;

 public SizeConverterArray() {

  super(“Shoe Size Converter”);

  setSize(420,300);

  setLayout(null);

  setBackground(Color.lightGray);

  lblFrom = new JLabel(“From:”);

  lblFrom.setBounds(30,45,250,30);

  lblFrom.setForeground(Color.RED);

  add(lblFrom);

  convertFrom = new JComboBox();

  convertFrom.setBounds(30,70,150,30);

  for (String x:Item)    // convertFrom field

  {

    convertFrom.addItem(x);

  }

  add(convertFrom);

  lblTo = new JLabel(“To:”);

  lblTo.setBounds(230,45,250,30);

  lblTo.setForeground(Color.RED);

  add(lblTo);

  convertTo = new JComboBox();

  convertTo.setBounds(230,70,150,30);

  for (String x:Item)  // convertTo field

  {

    convertTo.addItem(x);

  }  

  add(convertTo);

  from = new JLabel(“Enter Size to Convert:”);

  from.setBounds(50,110,300,30);

  add(from);

  txtFrom = new JTextField(15);

  txtFrom.setBounds(50,140,300,30);

  add(txtFrom);

  compute = new JButton(“Convert”);

  compute.setBounds(100,250,100,30);

  add(compute);

  to = new JLabel(“Size Converted:”);

  to.setBounds(50,170,300,30);

  add(to); 

  txtTo = new JTextField(15);

  txtTo.setBounds(50,200,300,30);

  txtTo.setEditable(false);

  txtTo.setForeground(Color.RED);

  add(txtTo);

  exit = new JButton(“Exit”);

  exit.setBounds(210,250,100,30);

  add(exit);

  convertFrom.addItemListener(this);

  convertTo.addItemListener(this);

  compute.addActionListener(this);

  txtFrom.addActionListener(this);

  exit.addActionListener(this);

    addWindowListener(new WindowAdapter() {

    public void windowClosing(WindowEvent e) {

     exit();

    }

   });

 }

 public void exit(){

  setVisible(false);

  dispose();

  System.exit(0);

 }

 public static void main(String args[]) {

  SizeConverterArray w = new SizeConverterArray();

  w.setVisible(true);

 }

// GetSize() function

public double GetSize(String x) {

  switch(x)

  {

   case “Nike”: {

      if(convertTo.getSelectedItem()==”Nike”)

      {

       result = (input);

        txtTo.setText(“”+result);

      }

      else if(convertTo.getSelectedItem()==”Adidas”)

      {

       result = (input – 0.5);

       txtTo.setText(“”+result);

      }

      else if(convertTo.getSelectedItem()==”Balenciaga(EU)”)

      {

       result = (input + 32);

       txtTo.setText(“”+result);

      }

      else if(convertTo.getSelectedItem()==”Puma”)

      {

       result = (input * 1.0);

       txtTo.setText(“”+result);

      }

      else if(convertTo.getSelectedItem()==”Timberland(Boots)”)

      {

       result = (input – 1.0);

       txtTo.setText(“”+result);

      }

    }

    break;

   case “Adidas”:{

         if(convertTo.getSelectedItem()==”Nike”)

         {

          result = (input + 0.5);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Adidas”)

         {

          result = (input);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Balenciaga(EU)”)

         {

          result = (input + 31);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Puma”)

         {

          result = (input + 0.5);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Timberland(Boots)”)

         {

          result = (input – 0.5);

          txtTo.setText(“”+result);

         }

   }

   break;

   case “Balenciaga(EU)”:{

           if(convertTo.getSelectedItem()==”Nike”)

           {

            result = (input – 32);

            txtTo.setText(“”+result);

           }

           else if(convertTo.getSelectedItem()==”Adidas”)

           {

            result = (input – 32);

            txtTo.setText(“”+result);

           }

           else if(convertTo.getSelectedItem()==”Balenciaga(EU)”)

           {

            result = (input);

            txtTo.setText(“”+result);

           }

           else if(convertTo.getSelectedItem()==”Puma”)

           {

            result = (input – 32);

            txtTo.setText(“”+result);

           }

           else if(convertTo.getSelectedItem()==”Timberland(Boots)”)

           {

            result = (input – 33);

            txtTo.setText(“”+result);

           }

   }

   break;

   case “Puma”:{

         if(convertTo.getSelectedItem()==”Nike”)

         {

          result = (input * 1.0);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Adidas”)

         {

          result = (input – 0.5);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Balenciaga(EU)”)

         {

          result = (input + 32);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Puma”)

         {

          result = (input);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Timberland(Boots)”)

         {

          result = (input – 1.0);

          txtTo.setText(“”+result);

         }

   }

   break;

   case “Timberland(Boots)”:{

         if(convertTo.getSelectedItem()==”Nike”)

         {

          result = (input + 1.0);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Adidas”)

         {

          result = (input + 0.5);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Balenciaga(EU)”)

         {

          result = (input + 33);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Puma”)

         {

          result = (input + 1.0);

          txtTo.setText(“”+result);

         }

         else if(convertTo.getSelectedItem()==”Timberland(Boots)”)

         {

          result = (input);

          txtTo.setText(“”+result);

         }

       }   

  }

   return result;

}

 public void actionPerformed(ActionEvent e) {

  input = Double.parseDouble(txtFrom.getText());

  String msg = txtFrom.getText();

  if(e.getSource()==compute)

  {

    for (String x:Item) 

    {

     if(convertFrom.getSelectedItem()==x)

       GetSize(x);     

      txtTo.setText(“”+result);

    }

  }

  else

  {

   int choice = JOptionPane.showConfirmDialog(null,”Are You Sure?”,”Exit”,JOptionPane.YES_NO_OPTION);

   if(choice==0) {

    dispose();

    System.exit(0);

   }

  }

 }

 public void itemStateChanged(ItemEvent e)

 {

 }

}

"Get 15% discount on your first 3 orders with us"
Use the following coupon
FIRST15

Order Now

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp