Project #58956 - Java

Joe's Automotive performs the following routine maintenance services: 

Oil Change- 26.00 

Lube Job - 18.00 

Radiator Flush - 30.00 

Transmission Flush - 80.00 

Inspection - 15.00 

Muffer Replacement - 100.00 

Tire Rotation - 20.00 

Joe also performs other nonroutine ervices and charges for parts and labor (20.00 per hour). Create a Gridlayout application that displays the total for a customers visit to Joe's.

 

(I have started (see below) but I think I’ll not be able to finish it by the dead line. Textfield must not accept char.) 

 

 

 

 

 

  import javax.swing.*;
  import java.awt.event.*; 
  import java.awt.*;
  import javax.swing.JTextField;
  
  
  
publicclass JoeAuto extends JFrame
  {
    
 10    privatefinalint WINDOW_WIDTH = 580;  // Window width
 11    privatefinalint WINDOW_HEIGHT = 260;  // Window height
 12    
 13 
 14 
 /** Constructor */
 15 
 16 
   public JoeAuto()  
 17    
 18   
 19    {
 20       // Set the title.
 21       
 22       setTitle("Joe's Auto");
 23       
 24       //set the size
 25       setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
 26       
 27 
 28 
      // close window.
 29       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 30 
 31 
      //Add Gridlayout Manager
 32       setLayout(new GridLayout(3, 4) );
 33       
 34       
 35       //Create buttons
 36       JButton button1 = new JButton("Button1");
 37       JButton button2 = new JButton("Button2");
 38       JButton button3 = new JButton("Button3");
 39       JButton button4 = new JButton("Button4");
 40       JButton button5 = new JButton("Button5");
 41       JButton button6 = new JButton("Button6");
 42       JButton button7 = new JButton("Button7");
 43       JButton button8 = new JButton("Button8");
 44       JTextField hoursTextField = new JTextField(5);
 45       JButton button9 = new JButton("Button9");
 46       
 47       //JButton button10 = new JButton("Button10");
 48       
 49       
 50       //Add buttons
 51       add(button1); // goes to row 1, column1 
 52       add(button2); // goes to row 1, column1
 53       add(button3); // goes to row 1, column1
 54       add(button4); // goes to row 1, column1
 55       add(button5); // goes to row 1, column1
 56       add(button6); // goes to row 1, column1
 57       add(button7); // goes to row 1, column1
 58       add(button8); // goes to row 1, column1
 59       add(hoursTextField);
 60       add(button9); // goes to row 1, column1
 61       //add(button10);// goes to row 1, columm1
 62 
 63 
      
 64      //Create label
 65      JLabel label1 = new JLabel("Oil change $ 26:00"); 
 66      JLabel label2 = new JLabel("Lube job $ 18:00"); 
 67      JLabel label3 = new JLabel("Radiator flush $ 30:00"); 
 68      JLabel label4 = new JLabel("Transmission flush $ 80:00"); 
 69      JLabel label5 = new JLabel("Inspection $ 15:00"); 
 70      JLabel label6 = new JLabel("Muffler replacement $ 100:00"); 
 71      JLabel label7 = new JLabel("Tire rotation $ 20:00"); 
 72      JLabel label8 = new JLabel("Nonroutine service");
 73      JLabel label9 = new JLabel("Total");
 74      //JLabel label1 = new JLabel("Oil change");
 75      
 76      //Create panels
 77      
 78      JPanel panel1 = new JPanel();
 79      JPanel panel2 = new JPanel();
 80      JPanel panel3 = new JPanel();
 81      JPanel panel4 = new JPanel();
 82      JPanel panel5 = new JPanel();
 83      JPanel panel6 = new JPanel();
 84      JPanel panel7 = new JPanel();
 85      JPanel panel8 = new JPanel();
 86      JPanel panel9 = new JPanel();
 87      
 88      //Add label to the panel
 89      panel1.add(label1);
 90      panel2.add(label2);
 91      panel3.add(label3);
 92      panel4.add(label4);
 93      panel5.add(label5);
 94      panel6.add(label6);
 95      panel7.add(label7);
 96      panel8.add(label8);
 97      panel9.add(label9);
 98 
 99 
    //Add button to the panel
100     
101      panel1.add(button1);
102      panel2.add(button2);
103      panel3.add(button3);
104      panel4.add(button4);
105      panel5.add(button5);
106      panel6.add(button6);
107      panel7.add(button7);
108      panel8.add(button8);
109      panel9.add(button9);
110 
111 
    //Add panels to the content pane
112     add(panel1); 
113     add(panel2);
114     add(panel3);
115     add(panel4);
116     add(panel5);
117     add(panel6);
118     add(panel7);
119     add(panel8);
120     add(panel9);
121     //add(panel1); 
122      
123       //Display the window
124       setVisible(true);
125       
126       
127     }
128     /**
129     Event han    */
130     /*
131     
132     private class ButtonListener implements ActionListener
133     {
134      public void actionPerformed(ActionEvent e)
135      {
136      String input;   
137      double nonRoutineCharge;
138      double subTotal = 0;
139      /*
140       if(button1.isSelected()) subTotal+= 26.00;
141       if(button2.isSelected()) subTotal+= 18.00;
142       if(button3.isSelected()) subTotal+= 30.00;
143       if(button4.isSelected()) subTotal+= 80.00;
144       if(button5.isSelected()) subTotal+= 15.00;
145       if(button6.isSelected()) subTotal+= 100.00;
146       if(button7.isSelected()) subTotal+= 20.00;
147       if(button8.isSelected())
148       
149       if(button9.isSelected())
150        input = hoursTextField.getText();
151        nonRoutineCharge = Double.parseDouble(input)*20;
152        subTotal +=nonRoutineCharge;
153       
154      
155      
156     */  
157    publicstaticvoid main(String[] args)
158    {
159      new JoeAuto();
160    }
161 }
162  // end class

Subject Computer
Due By (Pacific Time) 02/22/2015 11:00 pm
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy