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

  Creating a database with a table

Design a database with a table called tblStudents and use Visual Studio.NET 2005 to create an ASP.NET project with four aspx forms. Use Master Pages to show a school name.

  Determine the impedances of elements in laplace domain

Redraw the schematics with the impedance of each of the element shown in Laplace domain. Then determine the overall impedance of the entire circuit between the two ends of the shown circuit and express it in Laplace domain as a ratio of two polyno..

  Algorithm for checking whether a list of integers is sorted

Consider the obvious algorithm for checking whether a list of integers is sorted: start at the beginning of the list, and scan along until we first find a successive pair of elements that is out of order.

  Create an er diagram

Create an E-R diagram with all appropriate notation for the following condition. In a particular fruit growing region there are a number of orchards.

  How to implement a class called hugeinteger

Using your own Linked List implementation (see attached), implement a class called HugeInteger that represents arbitrary sized integers and supports addition only. You may only use the tools we have introduced in class, and you MAY NOT use Java's ..

  Discuss the business problem

Provide a clear statement of the aims and objectives of the data analytics study and the possible outcomes in terms of discovered knowledge and its potential application towards solution of the problem. In this section you need to discuss the busi..

  What is the role of an if statement in control structures

What is the role of an if statement in control structures? What are the similarities and differences between single alternative structures, dual alternative structures, and case structures

  Design algorithm to produce list of customers

Design an algorithm to produce a list of customers from the Glad Rags Clothing Company's customer master file. Each record on the customer master file contains the customer's number.

  Creating an interactive java program

Create an interactive Java program that illustrates the use of constructors, methods, loops and arrays.

  In the following problems you will need tobulldefine the

in the following problems you will need tobulldefine the problem by constructing a defining diagrambullcreate a

  Give a recursive definition of a singly linked list

Give a C++ code fragment that, given an×n matrix M of type float, replaces M with its transpose. Try to do this without the use of a temporary matrix.

  Returns true if a string contains properly nested

Give an algorithm that returns true if a string contains properly nested and balanced parentheses, and false if otherwise. Hint: At no time while scanning a legal string from left to right will you have encountered more right parentheses than left..

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