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

  Modify the stack example

Modify the stack example so that it stores characters instead of integers.

  Construct minimal avl trees of height

Construct minimal AVL trees of height 0, 1, 2, 3, and 4. you do not need to fill in the values, just draw the structure of the tree. Tip: Use the recursive definition for the number of nodes in a minimal AVL tree.

  Write forensic analysis for the windows 7 os

Download one of the forensic tools at http://forensiccontrol.com/fcresources.php, run it on Windows 7 OS, make up exercises that will test its capabilities and evaluate it. Write a one-page report on its potential use in forensic analysis for the ..

  Do you observe any changes in cluster memberships

Draw the graphic for the healthy set, representing the values, healthy and unhealthy and what is the degree of membership to the fuzzy set healthy of person B who has a BMI of 26.2? And to the fuzzy set unhealthy?

  Design a circular double linked list

Design a circular double linked list, for which the following operations should be implemented

  Explain the three types of relationships

Provide an example of a one to one relationship and an example of a many-to-many relationship in a newspaper, magazine, book, or everyday situation you encounter.

  What is the best algorithm for sorting

What is the best algorithm for sorting each of the following: general comparable objects, long character strings, double precision floating point numbers, 32-bit integers, and bytes? Justify your answer.

  Pseudocode for divide-and-conquer algorithm

Write a pseudocode for a divide-and-conquer algorithm for finding the position of the largest element in an array of n numbers.

  Writing a c program

Create a C program that has a declaration in main() to store the following numbers into an array named channels: 2, 4, 5, 7, 9, 11, 13. There should be a function call to display().

  Prove there exist no deterministic algo for election in ring

Prove that there exists no deterministic algorithm for election in rings of known, even size where communication is by synchronous message passzng.

  Array implementation of the queue

Assuming both integer and pointer occupies 4 bytes each, Array implementation of the queue requires Blank 1_______ bytes and the linked list implementation of the stack requires Blank 2_____bytes.

  System analystis you are required to analyse the

you are required to analyse the effectiveness of the qantas online air ticketing system. to do this you are required to

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