Provide the uml would be for the the program below

Assignment Help Data Structure & Algorithms
Reference no: EM13945378

Provide the UML would be for the the program below:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DecimalFormat;

/**
This program demonstrates a solution to the
Dorm and Meal Plan Calculator programming challenge.
*/

public class DormAndMealPlanCalc extends JFrame
{
// Array with dorm names
private String[] dormNames = { "Allen Hall",
"Pike Hall",
"Farthing Hall",
"University Suites" };

// Array with meal plan descriptions
private String[] mealPlans = { "7 meals per week",
"14 meals per week",
"Unlimited meals per week" };

private JComboBox dormCombo; // Combo box to display dorms
private JComboBox mealCombo; // Combo box to display meal plans

private JButton calcButton; // To calculate prices
private JButton exitButton; // To exit the application

private JPanel dormPanel; // Panel for dorm combo box
private JPanel mealPanel; // Panel for meal combo box
private JPanel buttonPanel; // Panel for the buttons

/**
Constructor
*/

public DormAndMealPlanCalc()
{
// Display a title.
setTitle("Dorm and Meal Plan Calculator");

// Specify what happens when the close button is clicked.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// Build the dorm panel.
buildDormPanel();

// Build the meal plan panel.
buildMealPanel();

// Build the button panel.
buildButtonPanel();

// Add the panels to the content pane.
add(dormPanel, BorderLayout.NORTH);
add(mealPanel, BorderLayout.CENTER);
add(buttonPanel, BorderLayout.SOUTH);

// Pack and display the window.
pack();
setVisible(true);
}

/**
The buildDormPanel method builds a panel allowing the user
to select a dorm from a combo box.
*/

private void buildDormPanel()
{
// Create a label prompting the user to select a dorm.
JLabel dormMsg = new JLabel("Select a Dorm.");

// Create the dorm combo box.
dormCombo = new JComboBox(dormNames);

// Put the components in a panel.
dormPanel = new JPanel();
dormPanel.add(dormMsg);
dormPanel.add(dormCombo);
}

/**
The buildMealPanel method builds a panel allowing the user
to select a meal plan from a combo box.
*/

private void buildMealPanel()
{
// Create a label prompting the user to select a meal plan.
JLabel mealMsg = new JLabel("Select a Meal Plan.");

// Create the meal plan combo box.
mealCombo = new JComboBox(mealPlans);

// Put the components in a panel.
mealPanel = new JPanel();
mealPanel.add(mealMsg);
mealPanel.add(mealCombo);
}

/**
The buildButtonPanel method builds a panel with calculate
and exit buttons.
*/

private void buildButtonPanel()
{
// Create a button to calculate the charges.
calcButton = new JButton("Calculate Charges");

// Add an action listener to the button.
calcButton.addActionListener(new CalcButtonListener());

// Create a button to exit the application.
exitButton = new JButton("Exit");

// Add an action listener to the button.
exitButton.addActionListener(new ExitButtonListener());

// Put the buttons in their own panel.
buttonPanel = new JPanel();
buttonPanel.add(calcButton);
buttonPanel.add(exitButton);
}

/**
CalcButtonListener is an action listener class for the
calcbutton component.
*/

private class CalcButtonListener implements ActionListener
{
/**
actionPerformed method
@param e An ActionEvent object.
*/

public void actionPerformed(ActionEvent e)
{
String selectedDorm; // To hold the selected dorm
String selectedMealPlan; // To hold the selected meal plan
double dormCharges; // Dorm charges
double mealCharges; // Meal plan charges
double totalCharges; // Total charges

// Create a DecimalFormat object to format output.
DecimalFormat dollar = new DecimalFormat("#,##0.00");

// Get the dorm charge.
selectedDorm = dormNames[dormCombo.getSelectedIndex()];
if (selectedDorm.equals("Allen Hall"))
dormCharges = 1500.0;
else if (selectedDorm.equals("Pike Hall"))
dormCharges = 1600.0;
else if (selectedDorm.equals("Farthing Hall"))
dormCharges = 1200.0;
else if (selectedDorm.equals("University Suites"))
dormCharges = 1800.0;
else
dormCharges = 0.0;

// Get the meal plan charge.
selectedMealPlan = mealPlans[mealCombo.getSelectedIndex()];
if (selectedMealPlan.equals("7 meals per week"))
mealCharges = 560.0;
else if (selectedMealPlan.equals("14 meals per week"))
mealCharges = 1095.0;
else if (selectedMealPlan.equals("Unlimited meals per week"))
mealCharges = 1500.0;
else
mealCharges = 0.0;

// Get the total charges
totalCharges = dormCharges + mealCharges;

// Display the message.
JOptionPane.showMessageDialog(null, "Total Charges per Semester: tiny_mce_markerquot; +
dollar.format(totalCharges));
}
} // End of inner class

/**
ExitButtonListener is an action listener class for the
exitButton component.
*/

private class ExitButtonListener implements ActionListener
{
/**
actionPerformed method
@param e An ActionEvent object.
*/

public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
} // End of inner class

/**
The main method creates an instance of the DormAndMealPlanCalc
class, causing it to display its window.
*/

public static void main(String[] args)
{
DormAndMealPlanCalc dmp = new DormAndMealPlanCalc();
}

Reference no: EM13945378

Questions Cloud

You work for a company that manufactures high tech : You work for a company that manufactures high tech electronic equipment. You are the project manager responsible for the development of a new type of Handset for 3G applications. The project life cycle is made up of the phases in the WBS below. Each ..
Company also has two bond issues outstanding : Dinklage Corp. has 7 million shares of common stock outstanding. The current share price is $73, and the book value per share is $8. The company also has two bond issues outstanding. Suppose the most recent dividend was $4.50 and the dividend growth ..
Broken down into eight psychosocial stages : The below assignment has been written by another student. Please read it very carefully and reply to it by providing at least 250 meaningful words, APA format, at least one in-text cite and from at least one academic resource. Textbook-Broderick, ..
Write paper about terrorism and parallel query optimization : CHOOSE ONE OF THE TOPICS AND TALK ABOUT IT. Terrorism, Cybersecurity, Privacy, Environmental Security, Security and Cryptography, Parallel Query Optimization and Cloud Computing: A new Era of IT Opportunity and Challenges.
Provide the uml would be for the the program below : Array with meal plan descriptions
What are the central beliefs of islam : What are the central beliefs of Islam, and how are they reflected in the "Five Pillars" (McInerney, 2003)? Which of the Five Pillars do you feel would be easiest to fulfill, and which would be the most challenging (McInerney, 2003)?
What is the amount of the break-even lease payment : Fargo North is considering the purchase of some new equipment costing $78,000. This equipment has a 2-year life after which time it will be worthless. The firm uses straight-line depreciation and borrows funds at a 8 percent rate of interest. The com..
Speaking aspect of english as second language : Is using blog tools technology can improve the speaking aspect of English as second language learning An analysis of literature review
Compared to that for an all-equity plan : Destin Corp. is comparing two different capital structures. Plan I would result in 12,000 shares of stock and $120,000 in debt. Plan II would result in 11,500 shares of stock and $140,000 in debt. The interest rate on the debt is 6 percent. Assuming ..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd