CSS/562: Programming Concepts

 CSS/562: Programming Concepts

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Wk 2 Assignment: GUI and Input, Output, and Variable [due Mon]

Wk 2 Assignment: GUI and Input, Output, and Variable [due Mon]

Assignment Content

  1. In your position as the leader of a programming team, sometimes you need to take on tasks when the team is overloaded with work. Your team is currently busy, so you are taking on a customer request to create a business application that allows the user to determine an approximate cost for a business trip. The customer will add functionality and features to the application throughout the development process. You will continue to modify this application throughout the remainder of the course.

    Create a Java™ travel authorization request graphical user interface (GUI) application via NetBeans to calculate the cost of a business trip.

    Include the following functionality:

    Traveler name (text field)
    Airfare cost (text field)
    Food cost (text field)
    Hotel cost (text field)
    Car cost (text field)
    Shuttle cost (text field)
    Summary: Display request total in label (must use a variable to store each item and calculate totals)
    Button
    The user will enter the name of the traveler and the cost of each item for a trip request. When the user clicks the calculate button, 10% of the total amount will be added to the trip total and be displayed in the Summary field. The use of variables are required to store the costs of the individual items.

    Save Time On Research and Writing
    Hire a Pro to Write You a 100% Plagiarism-Free Paper.
    Get My Paper

    Submit your assignment as follows the Netbeans project file (export/zip file), cut/paste the source to a MS Word document and a screen shoot of the output. Also, let me know if you are using a Mac or a PC platform.

/*

*

To change this template, choose Tools | Templates

* and open the template in the editor.

*/

package travelapp;

import java.util.InputMismatchException;

import javax.swing.JOptionPane;

/**

*

* @author sysadmin

*/

public class Traveller extends javax.swing.JFrame {

/**

* Creates new form Traveller

*/

public Traveller() {

initComponents();

setTitle(“Travel Authorization”);

}

/**

* This method is called from within the constructor to initialize the form.

* WARNING: Do NOT modify this code. The content of this method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings(“unchecked”)

//

private void initComponents() {

jTextField3 = new javax.swing.JTextField();

jLabel7 = new javax.swing.JLabel();

traveller_name = new javax.swing.JTextField();

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

food_cost = new javax.swing.JTextField();

jLabel3 = new javax.swing.JLabel();

airfare_cost = new javax.swing.JTextField();

jLabel4 = new javax.swing.JLabel();

jLabel5 = new javax.swing.JLabel();

jLabel6 = new javax.swing.JLabel();

hotel_cost = new javax.swing.JTextField();

shuttle_cost = new javax.swing.JTextField();

car_cost = new javax.swing.JTextField();

jLabel8 = new javax.swing.JLabel();

summary = new javax.swing.JLabel();

jButton1 = new javax.swing.JButton();

jLabel7.setText(“Shuttle Cost”);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setText(“Traveller Name”);

jLabel2.setText(“Airfare Cost”);

jLabel3.setText(“Food Cost”);

jLabel4.setText(“Hotel Cost”);

jLabel5.setText(“Car Cost”);

jLabel6.setText(“Shuttle Cost”);

jLabel8.setText(“Summary”);

jButton1.setText(“Calculate”);

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

}

});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(19, 19, 19)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addComponent(jLabel5)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(car_cost, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addComponent(jLabel4)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(hotel_cost, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel2)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(airfare_cost, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addComponent(jLabel1)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 147, Short.MAX_VALUE)

.addComponent(traveller_name, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addComponent(jLabel3)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(food_cost, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel6)

.addComponent(jLabel8)

)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(shuttle_cost, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)

.addComponent(jButton1)

.addComponent(summary, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))

.addGap(51, 51, 51))

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)

.addGap(30, 30, 30))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addComponent(traveller_name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addGroup(layout.createSequentialGroup()

.addComponent(airfare_cost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(food_cost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel3))))

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addComponent(jLabel4)

.addComponent(hotel_cost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(21, 21, 21)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)

.addComponent(car_cost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)

.addComponent(shuttle_cost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(15, 15, 15)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8)

.addComponent(summary, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(9, 9, 9)

.addComponent(jButton1)

.addContainerGap(29, Short.MAX_VALUE))

);

pack();

}//

public boolean checkForValidation() {

if (traveller_name.getText().equals(“”) || airfare_cost.getText().equals(“”) || food_cost.getText().equals(“”) || hotel_cost.getText().equals(“”) || car_cost.getText().equals(“”) || shuttle_cost.getText().equals(“”)) {

JOptionPane.showMessageDialog(rootPane, “Please fill all the details”);

return false;

} else {

return true;

}

}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

boolean valid = checkForValidation();

double total_cost=0,airCost=0,foodCost=0,hotelCost=0,carCost=0,shuttleCost=0;

if(valid)

{

String travllerName=traveller_name.getText();

try{

airCost=Double.parseDouble(airfare_cost.getText());

foodCost=Double.parseDouble(food_cost.getText());

hotelCost=Double.parseDouble(hotel_cost.getText());

carCost=Double.parseDouble(car_cost.getText());

shuttleCost=Double.parseDouble(shuttle_cost.getText());

}

catch(Exception ie)

{

JOptionPane.showMessageDialog(rootPane, “Invalid input please try again”);

}

total_cost=airCost+foodCost+hotelCost+carCost+shuttleCost;

double tax=total_cost*0.10;

total_cost=total_cost+tax;

summary.setText(String.valueOf(total_cost));

}

}

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */

//

/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.

* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {

if (“Nimbus”.equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

}

}

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Traveller.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Traveller.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Traveller.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Traveller.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}

//

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new Traveller().setVisible(true);

}
});
}

// Variables declaration – do not modify

private javax.swing.JTextField airfare_cost;

private javax.swing.JTextField car_cost;

private javax.swing.JTextField food_cost;

private javax.swing.JTextField hotel_cost;

private javax.swing.JButton jButton1;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel7;

private javax.swing.JLabel jLabel8;

private javax.swing.JTextField jTextField3;

private javax.swing.JTextField shuttle_cost;

private javax.swing.JLabel summary;

private javax.swing.JTextField traveller_name;

// End of variables declaration

}

Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
4.9
Sitejabber
4.6
Trustpilot
4.8
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.

Order your essay today and save 30% with the discount code ESSAYHELP