InvestmentCalculator.java
//import packages for GUI awt/swing and events
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
import javax.swing.*;
/*
InvestmentPanel class inherits from JPanel
add all components on it by providing
getter/setter methods for componet interface
*/
class InvestmentPanel extends JPanel
{
//declare textfields for customer name &
amount
private final JTextField customerName;
private final JTextField amount;
//declare combobox for type of investment
(moderate/aggressive)
private final JComboBox type;
//declare radio button for investment
years
private final JRadioButton term_5years;
private final JRadioButton term_10years;
private final JRadioButton term_15years;
//radio button group to hold each above radio
buttons
private final ButtonGroup group;
//vector types for adding investment types
private final Vector<Object> types = new
Vector<>();
//constructor
public InvestmentPanel(){
//create custome name
& amount textfields
customerName = new
JTextField(20);
amount = new
JTextField(20);
//add Moderate &
Aggressive string to types vector object
types.add("Moderate
");
types.add("Aggressive
");
//create combo box with
types
type = new
JComboBox(types);
//create radio
buttons
term_5years = new
JRadioButton("5 Years");
term_10years = new
JRadioButton("10 Years");
term_15years = new
JRadioButton("15 Years");
group = new
ButtonGroup();
}
//returns this object by adding each created
components
//to this panel object
public InvestmentPanel
createInvestmentPanel(){
//set default 5 years
radio button selected to true
term_5years.setSelected(true);
//add each radio button
to button group
group.add(term_5years);
group.add(term_10years);
group.add(term_15years);
//set flow layout for
all components on panel
setLayout(new
FlowLayout(10));
//add customer name text
field with label
add(new JLabel("
Customer Name: "));
add(customerName);
//add amount text field
with label
add(new JLabel(" Enter
Amount: "));
add(amount);
//add combobox with
label
add(new JLabel(" Select
Type: "));
add(type);
//add radio button group
with label
add(new JLabel(" Select
Term: "));
add(term_5years);
add(term_10years);
add(term_15years);
return this;
}
//getter methods
public String getCustomerName(){
return
customerName.getText();
}
public String getAmount(){
return
amount.getText();
}
public String getType(){
return
type.getSelectedItem().toString().trim();
}
public int getTerm(){
if(term_5years.isSelected())
return 5;
else
if(term_10years.isSelected())
return 10;
else
return 15;
}
//setter methods
public void setCustomerName(String s){
customerName.setText(s);
}
public void setAmount(String s){
amount.setText(s);
}
public void setType(int i){
type.setSelectedIndex(i);
}
}
/*
InvestmentFrame class inherits from JFrame
add InvestmentPanel on it
*/
class InvestmentFrame extends JFrame
{
//declare menubar and its menus File,
Tools
private final JMenuBar menuBar;
private final JMenu fileMenu;
private final JMenu toolsMenu;
//declare menu items File->Exit,
Tools->Calculate, Tools->Clear
private final JMenuItem file_exitMenuItem;
private final JMenuItem
tools_calculateMenuItem;
private final JMenuItem
tools_clearMenuItem;
//declare InvestmentPanel object
private InvestmentPanel investmentPanel;
//constructor
public InvestmentFrame(){
//initialize all above
declared objects
menuBar = new
JMenuBar();
fileMenu = new
JMenu("File");
toolsMenu = new
JMenu("Tools");
file_exitMenuItem = new
JMenuItem("Exit");
tools_calculateMenuItem
= new JMenuItem("Calculate");
tools_clearMenuItem =
new JMenuItem("Clear");
//add each menu item to
specific menu
fileMenu.add(file_exitMenuItem);
toolsMenu.add(tools_calculateMenuItem);
toolsMenu.add(tools_clearMenuItem);
menuBar.add(fileMenu);
menuBar.add(toolsMenu);
}
public void showFrame(){
//create investment
panel object
investmentPanel = new
InvestmentPanel();
//create MenuItemsAction
object by passing investmentPanel object to it
MenuItemsAction act =
new MenuItemsAction(investmentPanel);
//add action listener to
each menu item
file_exitMenuItem.addActionListener(act);
tools_calculateMenuItem.addActionListener(act);
tools_clearMenuItem.addActionListener(act);
//set frame
properties
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setJMenuBar(menuBar);
getContentPane().add(investmentPanel.createInvestmentPanel());
setTitle("Investment
Calculator");
setSize(420, 200);
setLocation(300,
200);
setVisible(true);
}
}
//action class that inherits ActionListener
class MenuItemsAction implements ActionListener
{
private InvestmentPanel investmentPanel;
//get the InvestmentPanel object for accessing
its
//properties like customer name, amount
public MenuItemsAction(InvestmentPanel
panel){
investmentPanel =
panel;
}
@Override
public void actionPerformed(ActionEvent
evt){
if(evt.getSource()
instanceof JMenuItem){
//perform action according to the menu item selected
String item = evt.getActionCommand().trim();
switch(item){
//File->Exit menu item action
case "Exit" : System.exit(0); break;
//Tools->Calculate menu item action
case "Calculate" :
calculate();
break;
//Tools->Clear menu item action
case "Clear" :
clear();
break;
}
}
}
//calculate investment amount
private void calculate(){
//get amount from
customer name text field
double amount =
Double.parseDouble(investmentPanel.getAmount());
//get intereset rate
from type
double interest =
10.0;
String type =
investmentPanel.getType();
if(type.equals("Moderate"))
interest = 10.0;
else
if(type.equals("Aggressive"))
interest = 15.0;
//get investment
years
int years =
investmentPanel.getTerm();
double investment =
amount * Math.pow(1 + (interest / 12), 12 * years);
double compound_interest
= investment - amount;
String str = "INVESTMENT
REPORT\n"
+ "\nCUSTOMER NAME: " + investmentPanel.getCustomerName()
+ "\nORIGINAL AMOUNT: " + investmentPanel.getAmount()
+ "\nYEARS Invested: " + years
+ "\nFINAL AMOUNT: R " + investment;
//show message box with
all the details
JOptionPane.showMessageDialog(null, str);
}
//clear all text fields
private void clear(){
investmentPanel.setCustomerName("");
investmentPanel.setAmount("");
investmentPanel.setType(0);
}
}
//main class
public class InvestmentCalculator
{
public static void main(String[] args) {
//create investment
frame and show frame
InvestmentFrame invf =
new InvestmentFrame();
invf.showFrame();
}
}
Question 1 (Marks: 50 Develop a Java GUI application that will produce an investment report based...
QUESTION 1 : (15 Marks) Adanna Ghany is the founder and manager of Ceramics Unlimited. Adanna has approached the local bank for a loan to expand her business. As part of the loan application, Adanna was asked to prepare Financial Statements for the business. She prepared the following balance sheet and income statement based on the first month of operations (see below). Ceramics Unlimited. BALANCE SHEET November 30, 2019 Cash $ 1,400 Equity $ 1,400 $ 1,400 $ 1,400 Ceramics...
AutoSave Off HD Unit 1 Project Fall 2020 (2) - Protected View - Excel guada gucci GG File Home Insert Draw Page Layout Formulas Data Review View Help O Search Share Comments i PROTECTED VIEW Be careful—files from the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View. Enable Editing X H16 fox 1 J к L N O P P Q R S т U A B с D E F G...
It is based on the multiple-choice question pasted below. Use the current 21 percent tax rate. (28) in the current year, Acom, Inc., had the following items of income and expense! Sales $500,000 Cost of sales 250,000 Dividends received 25,000 The dividends were received from a corporation of which Acom owns 30%. In Acom's current yoar income tax rotum, what amount should be reported as income before special deductions? A. $525.000 B. $508,750 C. $275,000 D. $250.000 The correct answer...
10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...
And there was a buy-sell arrangement which laid out the conditions under which either shareholder could buy out the other. Paul knew that this offer would strengthen his financial picture…but did he really want a partner?It was going to be a long night. read the case study above and answer this question what would you do if you were Paul with regards to financing, and why? ntroductloh Paul McTaggart sat at his desk. Behind him, the computer screen flickered with...
Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...
CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant "E" slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm...
Case: Enron: Questionable Accounting Leads to CollapseIntroductionOnce upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant “E,” slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm laid off 4,000...
I have this case study to solve. i want to ask which type of case study in this like problem, evaluation or decision? if its decision then what are the criterias and all? Stardust Petroleum Sendirian Berhad: how to inculcate the pro-active safety culture? Farzana Quoquab, Nomahaza Mahadi, Taram Satiraksa Wan Abdullah and Jihad Mohammad Coming together is a beginning; keeping together is progress; working together is success. - Henry Ford The beginning Stardust was established in 2013 as a...