SlideShare a Scribd company logo
1 of 13
Download to read offline
help me Java project
I put problem and my own code in the link
my code is long link : https://codeshare.io/YohNo
Solution
import javax.swing.*;
import java.awt.Font;
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Assignment21 {
/**
* @param args the command line arguments
*/
public static JFrame frame;
public static DecimalFormat fmt = new DecimalFormat ("0.00;(0.00)");
public static String message;
public static boolean firstTime = true;
public static boolean firstTime2 = true;
public static CheckingAccount CheckAcc;
public static Transaction newTrans;
public static void main(String[] args) {
// TODO code application logic here
frame = new JFrame ("Transaction Options");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
EOptionsPanel panel = new EOptionsPanel();
frame.getContentPane().add (panel);
frame.pack();
frame.setVisible(true);
}
public static int getTransCode()
{
String codeStr;
int code;
codeStr=JOptionPane.showInputDialog(" Here are the Transaction
Codes: 1)Checking 2)Depositing 0)Terminate");
code = Integer.parseInt(codeStr);
return code;
}
public static double getTransAmount(){
String tStr;
double tAmount;
tStr = JOptionPane.showInputDialog("Enter the trans amount: ");
tAmount = Double.parseDouble(tStr);
return tAmount;
}
public static double processCheck(double tAmount)
{
CheckAcc.setServiceCharge(0.15);
newTrans = new Transaction(CheckAcc.getTransCount(),3,0.15);
CheckAcc.addTrans(newTrans);
message += " Transaction : Check in Amount of $" + fmt.format(tAmount) +
" Current Balance : $ " + fmt.format(CheckAcc.getBalance()) +
" Service Charge : Check --- charge: $0.15";
if(CheckAcc.getBalance()<500 && firstTime2)
{
CheckAcc.setServiceCharge(5.00);
newTrans = new Transaction(CheckAcc.getTransCount(),3,5.00);
CheckAcc.addTrans(newTrans);
firstTime2=false;
message += " Service Charge : Balance under $500 -- Charge: $5.00";
}
if(CheckAcc.getBalance()<0)
{
CheckAcc.setServiceCharge(10.00);
newTrans = new Transaction(CheckAcc.getTransCount(),3,10.00);
CheckAcc.addTrans(newTrans);
message += " Service Charge : Overdfart Balance --- Charge: $10.00";
}
message += " Total ServiceCharge : $ " + fmt.format(CheckAcc.getServiceCharge());
JOptionPane.showMessageDialog(null, message);
return 0;
}
public static double processDeposit(double tAmount)
{
CheckAcc.setServiceCharge(0.10);
newTrans = new Transaction(CheckAcc.getTransCount(),3,0.10);
CheckAcc.addTrans(newTrans);
message += " Transaction : Deposit in Amount of $" + fmt.format(tAmount) +
" Current Balance : $ " + fmt.format(CheckAcc.getBalance()) +
" Service Charge : Check --- charge: $0.10"+
" Total ServiceCharge : $ " + fmt.format(CheckAcc.getServiceCharge());
JOptionPane.showMessageDialog(null, message);
return 0;
}
public static void inputTransactions()
{
// define local variables
String initialStr;
double initial, tAmount, check, deposit, amount=0;
int code, number=0, id=0;
// get initial balance from the user
if(firstTime)
{
initialStr = JOptionPane.showInputDialog ("Please enter the initial balance: ");
initial = Double.parseDouble (initialStr);
/*
instantiate CheckingAccount object
to keep track of account information
*/
CheckAcc = new CheckingAccount (initial);
firstTime=false;
}
newTrans = new Transaction (number, id, amount);
frame.setVisible(false);
//Loop continues transactions until trans code = 0
do
{
message = "";
code = getTransCode();
if (code != 0) //initially checks that trans code != 0
{
tAmount = getTransAmount();
CheckAcc.setBalance(tAmount, code);
//creating a new Transaction object
newTrans = new Transaction (CheckAcc.getTransCount(), code, tAmount);
CheckAcc.addTrans(newTrans);//inputs the new object in the array
if (CheckAcc.getBalance() < 50)
message = "WARNING: Balance below $50";
if (code == 1)
{
check = processCheck(tAmount);
}
if (code == 2)
{
deposit = processDeposit(tAmount);
}
}
}
while (code != 0);
// When loop ends show final balance to user.
message += "*****************" + " Transaction End"
+ " *****************" + " Current Balance: " + fmt.format(CheckAcc.getBalance())
+ " Total Service Charges: " + fmt.format(CheckAcc.getServiceCharge())
+ " Final Balance: " + fmt.format(CheckAcc.getFinal());
JOptionPane.showMessageDialog(null, message);
frame.setVisible(true);
}
public static void listTransactions()
{
JTextArea text = new JTextArea();
String message = "";
int num;
text.setOpaque(false);
text.setFont(new Font("Monospaced", Font.PLAIN, 14) );
text.setBorder(null);
message+="All Transactions  ";
message+="Number Type Amount($)  ";
for ( num=0; num < CheckAcc.getTransCount(); num++)
{
String word = "";
newTrans = CheckAcc.getTrans(num);
System.out.println(newTrans.getTransId());
//Case switch to convert transID to a trans type (string)
switch (newTrans.getTransId())
{
case 1: word = "Check ";
break;
case 2: word = "Deposit ";
break;
case 3: word = "Service Charge";
}
message += String.format("%3d %10s %10s  ",
newTrans.getTransNumber(), word, fmt.format(newTrans.getTransAmount()));
}
text.setText(message);
JOptionPane.showMessageDialog(null, text);
}
public static void listChecks()
{
JTextArea text = new JTextArea();
String message = "";
int num;
text.setOpaque(false);
text.setFont(new Font("Monospaced", Font.PLAIN, 14) );
text.setBorder(null);
message+="Checks Cashed  ";
message+="Number Amount($)  ";
for ( num=0; num < CheckAcc.getTransCount(); num++)
{
newTrans = CheckAcc.getTrans(num);
if (newTrans.getTransId() == 1)
{
message += String.format("%3d %10s  ",
newTrans.getTransNumber(), fmt.format(newTrans.getTransAmount()));
}
}
text.setText(message);
JOptionPane.showMessageDialog(null, text);
}
public static void listDeposits()
{
JTextArea text = new JTextArea();
String message = "";
int num;
text.setOpaque(false);
text.setFont(new Font("Monospaced", Font.PLAIN, 14) );
text.setBorder(null);
message+="Deposits Made  ";
message+="Number Amount($)  ";
for ( num=0; num < CheckAcc.getTransCount(); num++)
{
newTrans = CheckAcc.getTrans(num);
if (newTrans.getTransId() == 2)
{
message += String.format("%3d %10s  ",
newTrans.getTransNumber(), fmt.format(newTrans.getTransAmount()));
}
}
text.setText(message);
JOptionPane.showMessageDialog(null, text);
}
public static void listService_Charges()
{
JTextArea text = new JTextArea();
String message = "";
int num;
text.setOpaque(false);
text.setFont(new Font("Monospaced", Font.PLAIN, 14) );
text.setBorder(null);
message+="Service Charges  ";
message+="Number Amount($)  ";
for ( num=0; num < CheckAcc.getTransCount(); num++)
{
newTrans = CheckAcc.getTrans(num);
if (newTrans.getTransId() == 3)
{
message += String.format("%3d %10s  ",
newTrans.getTransNumber(), fmt.format(newTrans.getTransAmount()));
}
}
text.setText(message);
JOptionPane.showMessageDialog(null, text);
}
}
//-----------------CheckingAccount.java-------------------------------
package assignment2.pkg1;
import java.util.ArrayList;
public class CheckingAccount
{
private ArrayList transList;// keeps a list of Transaction objects for the account
private int transCount; // the count of Transaction objects and used as the ID for each transaction
private double currentbalance;
private double totalServiceCharge;
private double finalbalance;
public CheckingAccount(double initial)
{
transList = new ArrayList();
currentbalance = initial;
totalServiceCharge = 0;
finalbalance = 0;
}
public double getBalance()
{
return currentbalance;
}
public void setBalance(double tAmount, int transCode)
{
if(transCode == 1)
currentbalance -= tAmount;
else //if(transCode == 2)
currentbalance += tAmount;
}
public double getServiceCharge()
{
return totalServiceCharge;
}
public void setServiceCharge(double currentServiceCharge)
{
totalServiceCharge += currentServiceCharge;
}
public double getFinal()
{
finalbalance = currentbalance - totalServiceCharge;
return finalbalance;
}
public void addTrans(Transaction newTrans)// adds a transaction object to the transList
{
transList.add(newTrans);
transCount ++;
}
public int getTransCount()//returns the current value of transCount;
{
return transCount;
}
public Transaction getTrans(int i)// returns the i-th Transaction object in the list
{
return transList.get(i);
}
}
//---------------------------------EOptionsPanel.java-------------------------------------------
package assignment2.pkg1;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import assignment2.pkg1.Assignment21;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Color;
public class EOptionsPanel extends JPanel
{
private JLabel prompt;
private JRadioButton one, two, three, four, five;
//-----------------------------------------------------------------
// Sets up a panel with a label and a set of radio buttons
// that present options to the user.
//-----------------------------------------------------------------
public EOptionsPanel()
{
prompt = new JLabel ("Choose your input option:");
prompt.setFont (new Font ("Courier New", Font.BOLD, 24));
one = new JRadioButton ("Enter A Transaction");
one.setBackground (Color.red);
two = new JRadioButton ("List All Transactions");
two.setBackground (Color.GREEN);
three = new JRadioButton ("List All Checks");
three.setBackground (Color.Blue);
four = new JRadioButton ("List All Deposits");
four.setBackground (Color.yellow);
five= new JRadioButton ("List All Service Charges");
five.setBackground (Color.magenta);
ButtonGroup group = new ButtonGroup();
group.add (one);
group.add (two);
group.add (three);
group.add (four);
group.add (five);
EOptionListener listener = new EOptionListener();
one.addActionListener (listener);
two.addActionListener (listener);
three.addActionListener (listener);
four.addActionListener (listener);
five.addActionListener (listener);
// add the components to the JPanel
add (prompt);
add (one);
add (two);
add (three);
add (four);
add (five);
setBackground (Color.green);
setPreferredSize (new Dimension(400, 140));
}
//*****************************************************************
// Represents the listener for the radio buttons
//*****************************************************************
private class EOptionListener implements ActionListener
{
//--------------------------------------------------------------
// Calls the method to process the option for which radio
// button was pressed.
//--------------------------------------------------------------
public void actionPerformed (ActionEvent event)
{
Object source = event.getSource();
if (source == one)
Assignment21.inputTransactions();
else
if (source == two)
Assignment21.listTransactions();
else
if (source == three)
Assignment21.listChecks();
if (source == four)//list deposits
Assignment21.listDeposits();
if (source == five)
Assignment21.listService_Charges();
}
}
}
//------------------------------Transaction.java-----------------------------------
package assignment2.pkg1;
public class Transaction {
private int transNumber;
private int transId;
private double tAmount;
public Transaction(int number, int id, double amount)
{
transNumber = number;
transId = id;
tAmount = amount;
}
public int getTransNumber()
{
return transNumber;
}
public int getTransId()
{
return transId;
}
public double getTransAmount()
{
return tAmount;
}
}

More Related Content

Similar to help me Java projectI put problem and my own code in the linkmy .pdf

My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfadianantsolutions
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy codeShriKant Vashishtha
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxamrit47
 
Advanced Java - Practical File
Advanced Java - Practical FileAdvanced Java - Practical File
Advanced Java - Practical FileFahad Shaikh
 
This is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfThis is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfindiaartz
 
Program flowchart
Program flowchartProgram flowchart
Program flowchartSowri Rajan
 
csc 208
csc 208csc 208
csc 208priska
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in Csana shaikh
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek Kaczanowski
 
You are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfYou are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfdeepakangel
 
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdfsudhirchourasia86
 

Similar to help me Java projectI put problem and my own code in the linkmy .pdf (20)

My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdf
 
MaintainStaffTable
MaintainStaffTableMaintainStaffTable
MaintainStaffTable
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
java assignment
java assignmentjava assignment
java assignment
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
 
Advanced Java - Practical File
Advanced Java - Practical FileAdvanced Java - Practical File
Advanced Java - Practical File
 
5 Rmi Print
5  Rmi Print5  Rmi Print
5 Rmi Print
 
Spring Transaction
Spring TransactionSpring Transaction
Spring Transaction
 
Marcus Portfolio
Marcus  PortfolioMarcus  Portfolio
Marcus Portfolio
 
This is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfThis is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdf
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
 
csc 208
csc 208csc 208
csc 208
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
You are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfYou are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdf
 
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
 
Jason parsing
Jason parsingJason parsing
Jason parsing
 
C programs
C programsC programs
C programs
 

More from arihantmum

In 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdfIn 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdfarihantmum
 
In a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdfIn a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdfarihantmum
 
I need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdfI need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdfarihantmum
 
Heading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdfHeading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdfarihantmum
 
Explain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdfExplain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdfarihantmum
 
Explain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdfExplain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdfarihantmum
 
Couldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdfCouldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdfarihantmum
 
Consider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfConsider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfarihantmum
 
Describe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdfDescribe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdfarihantmum
 
classify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdfclassify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdfarihantmum
 
Compare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdfCompare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdfarihantmum
 
B. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdfB. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdfarihantmum
 
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdfAssume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdfarihantmum
 
Amon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdfAmon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdfarihantmum
 
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdfA box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdfarihantmum
 
As late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdfAs late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdfarihantmum
 
A bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdfA bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdfarihantmum
 
Xavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdfXavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdfarihantmum
 
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdfarihantmum
 
1. An important contribution of Fiedlers research on the contingen.pdf
1. An important contribution of Fiedlers research on the contingen.pdf1. An important contribution of Fiedlers research on the contingen.pdf
1. An important contribution of Fiedlers research on the contingen.pdfarihantmum
 

More from arihantmum (20)

In 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdfIn 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdf
 
In a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdfIn a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdf
 
I need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdfI need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdf
 
Heading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdfHeading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdf
 
Explain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdfExplain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdf
 
Explain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdfExplain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdf
 
Couldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdfCouldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdf
 
Consider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfConsider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdf
 
Describe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdfDescribe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdf
 
classify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdfclassify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdf
 
Compare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdfCompare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdf
 
B. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdfB. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdf
 
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdfAssume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
 
Amon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdfAmon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdf
 
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdfA box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
 
As late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdfAs late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdf
 
A bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdfA bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdf
 
Xavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdfXavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdf
 
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
 
1. An important contribution of Fiedlers research on the contingen.pdf
1. An important contribution of Fiedlers research on the contingen.pdf1. An important contribution of Fiedlers research on the contingen.pdf
1. An important contribution of Fiedlers research on the contingen.pdf
 

Recently uploaded

KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 

Recently uploaded (20)

KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 

help me Java projectI put problem and my own code in the linkmy .pdf

  • 1. help me Java project I put problem and my own code in the link my code is long link : https://codeshare.io/YohNo Solution import javax.swing.*; import java.awt.Font; import javax.swing.JOptionPane; import java.text.DecimalFormat; import java.util.Scanner; public class Assignment21 { /** * @param args the command line arguments */ public static JFrame frame; public static DecimalFormat fmt = new DecimalFormat ("0.00;(0.00)"); public static String message; public static boolean firstTime = true; public static boolean firstTime2 = true; public static CheckingAccount CheckAcc; public static Transaction newTrans; public static void main(String[] args) { // TODO code application logic here frame = new JFrame ("Transaction Options"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); EOptionsPanel panel = new EOptionsPanel(); frame.getContentPane().add (panel); frame.pack(); frame.setVisible(true); } public static int getTransCode() { String codeStr; int code;
  • 2. codeStr=JOptionPane.showInputDialog(" Here are the Transaction Codes: 1)Checking 2)Depositing 0)Terminate"); code = Integer.parseInt(codeStr); return code; } public static double getTransAmount(){ String tStr; double tAmount; tStr = JOptionPane.showInputDialog("Enter the trans amount: "); tAmount = Double.parseDouble(tStr); return tAmount; } public static double processCheck(double tAmount) { CheckAcc.setServiceCharge(0.15); newTrans = new Transaction(CheckAcc.getTransCount(),3,0.15); CheckAcc.addTrans(newTrans); message += " Transaction : Check in Amount of $" + fmt.format(tAmount) + " Current Balance : $ " + fmt.format(CheckAcc.getBalance()) + " Service Charge : Check --- charge: $0.15"; if(CheckAcc.getBalance()<500 && firstTime2) { CheckAcc.setServiceCharge(5.00); newTrans = new Transaction(CheckAcc.getTransCount(),3,5.00); CheckAcc.addTrans(newTrans); firstTime2=false; message += " Service Charge : Balance under $500 -- Charge: $5.00"; } if(CheckAcc.getBalance()<0) { CheckAcc.setServiceCharge(10.00); newTrans = new Transaction(CheckAcc.getTransCount(),3,10.00); CheckAcc.addTrans(newTrans);
  • 3. message += " Service Charge : Overdfart Balance --- Charge: $10.00"; } message += " Total ServiceCharge : $ " + fmt.format(CheckAcc.getServiceCharge()); JOptionPane.showMessageDialog(null, message); return 0; } public static double processDeposit(double tAmount) { CheckAcc.setServiceCharge(0.10); newTrans = new Transaction(CheckAcc.getTransCount(),3,0.10); CheckAcc.addTrans(newTrans); message += " Transaction : Deposit in Amount of $" + fmt.format(tAmount) + " Current Balance : $ " + fmt.format(CheckAcc.getBalance()) + " Service Charge : Check --- charge: $0.10"+ " Total ServiceCharge : $ " + fmt.format(CheckAcc.getServiceCharge()); JOptionPane.showMessageDialog(null, message); return 0; } public static void inputTransactions() { // define local variables String initialStr; double initial, tAmount, check, deposit, amount=0; int code, number=0, id=0; // get initial balance from the user if(firstTime) { initialStr = JOptionPane.showInputDialog ("Please enter the initial balance: "); initial = Double.parseDouble (initialStr); /* instantiate CheckingAccount object to keep track of account information
  • 4. */ CheckAcc = new CheckingAccount (initial); firstTime=false; } newTrans = new Transaction (number, id, amount); frame.setVisible(false); //Loop continues transactions until trans code = 0 do { message = ""; code = getTransCode(); if (code != 0) //initially checks that trans code != 0 { tAmount = getTransAmount(); CheckAcc.setBalance(tAmount, code); //creating a new Transaction object newTrans = new Transaction (CheckAcc.getTransCount(), code, tAmount); CheckAcc.addTrans(newTrans);//inputs the new object in the array if (CheckAcc.getBalance() < 50) message = "WARNING: Balance below $50"; if (code == 1) { check = processCheck(tAmount); } if (code == 2) { deposit = processDeposit(tAmount); } } }
  • 5. while (code != 0); // When loop ends show final balance to user. message += "*****************" + " Transaction End" + " *****************" + " Current Balance: " + fmt.format(CheckAcc.getBalance()) + " Total Service Charges: " + fmt.format(CheckAcc.getServiceCharge()) + " Final Balance: " + fmt.format(CheckAcc.getFinal()); JOptionPane.showMessageDialog(null, message); frame.setVisible(true); } public static void listTransactions() { JTextArea text = new JTextArea(); String message = ""; int num; text.setOpaque(false); text.setFont(new Font("Monospaced", Font.PLAIN, 14) ); text.setBorder(null); message+="All Transactions "; message+="Number Type Amount($) "; for ( num=0; num < CheckAcc.getTransCount(); num++) { String word = ""; newTrans = CheckAcc.getTrans(num); System.out.println(newTrans.getTransId()); //Case switch to convert transID to a trans type (string) switch (newTrans.getTransId()) { case 1: word = "Check "; break; case 2: word = "Deposit "; break; case 3: word = "Service Charge"; }
  • 6. message += String.format("%3d %10s %10s ", newTrans.getTransNumber(), word, fmt.format(newTrans.getTransAmount())); } text.setText(message); JOptionPane.showMessageDialog(null, text); } public static void listChecks() { JTextArea text = new JTextArea(); String message = ""; int num; text.setOpaque(false); text.setFont(new Font("Monospaced", Font.PLAIN, 14) ); text.setBorder(null); message+="Checks Cashed "; message+="Number Amount($) "; for ( num=0; num < CheckAcc.getTransCount(); num++) { newTrans = CheckAcc.getTrans(num); if (newTrans.getTransId() == 1) { message += String.format("%3d %10s ", newTrans.getTransNumber(), fmt.format(newTrans.getTransAmount())); } } text.setText(message); JOptionPane.showMessageDialog(null, text); } public static void listDeposits() { JTextArea text = new JTextArea(); String message = ""; int num; text.setOpaque(false);
  • 7. text.setFont(new Font("Monospaced", Font.PLAIN, 14) ); text.setBorder(null); message+="Deposits Made "; message+="Number Amount($) "; for ( num=0; num < CheckAcc.getTransCount(); num++) { newTrans = CheckAcc.getTrans(num); if (newTrans.getTransId() == 2) { message += String.format("%3d %10s ", newTrans.getTransNumber(), fmt.format(newTrans.getTransAmount())); } } text.setText(message); JOptionPane.showMessageDialog(null, text); } public static void listService_Charges() { JTextArea text = new JTextArea(); String message = ""; int num; text.setOpaque(false); text.setFont(new Font("Monospaced", Font.PLAIN, 14) ); text.setBorder(null); message+="Service Charges "; message+="Number Amount($) "; for ( num=0; num < CheckAcc.getTransCount(); num++) { newTrans = CheckAcc.getTrans(num); if (newTrans.getTransId() == 3) { message += String.format("%3d %10s ", newTrans.getTransNumber(), fmt.format(newTrans.getTransAmount())); } } text.setText(message);
  • 8. JOptionPane.showMessageDialog(null, text); } } //-----------------CheckingAccount.java------------------------------- package assignment2.pkg1; import java.util.ArrayList; public class CheckingAccount { private ArrayList transList;// keeps a list of Transaction objects for the account private int transCount; // the count of Transaction objects and used as the ID for each transaction private double currentbalance; private double totalServiceCharge; private double finalbalance; public CheckingAccount(double initial) { transList = new ArrayList(); currentbalance = initial; totalServiceCharge = 0; finalbalance = 0; } public double getBalance() { return currentbalance; } public void setBalance(double tAmount, int transCode) { if(transCode == 1) currentbalance -= tAmount; else //if(transCode == 2) currentbalance += tAmount; } public double getServiceCharge()
  • 9. { return totalServiceCharge; } public void setServiceCharge(double currentServiceCharge) { totalServiceCharge += currentServiceCharge; } public double getFinal() { finalbalance = currentbalance - totalServiceCharge; return finalbalance; } public void addTrans(Transaction newTrans)// adds a transaction object to the transList { transList.add(newTrans); transCount ++; } public int getTransCount()//returns the current value of transCount; { return transCount; } public Transaction getTrans(int i)// returns the i-th Transaction object in the list { return transList.get(i); } } //---------------------------------EOptionsPanel.java------------------------------------------- package assignment2.pkg1; import javax.swing.*; import java.awt.*;
  • 10. import java.awt.event.*; import assignment2.pkg1.Assignment21; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.Color; public class EOptionsPanel extends JPanel { private JLabel prompt; private JRadioButton one, two, three, four, five; //----------------------------------------------------------------- // Sets up a panel with a label and a set of radio buttons // that present options to the user. //----------------------------------------------------------------- public EOptionsPanel() { prompt = new JLabel ("Choose your input option:"); prompt.setFont (new Font ("Courier New", Font.BOLD, 24)); one = new JRadioButton ("Enter A Transaction"); one.setBackground (Color.red); two = new JRadioButton ("List All Transactions"); two.setBackground (Color.GREEN); three = new JRadioButton ("List All Checks"); three.setBackground (Color.Blue); four = new JRadioButton ("List All Deposits"); four.setBackground (Color.yellow); five= new JRadioButton ("List All Service Charges"); five.setBackground (Color.magenta); ButtonGroup group = new ButtonGroup(); group.add (one); group.add (two);
  • 11. group.add (three); group.add (four); group.add (five); EOptionListener listener = new EOptionListener(); one.addActionListener (listener); two.addActionListener (listener); three.addActionListener (listener); four.addActionListener (listener); five.addActionListener (listener); // add the components to the JPanel add (prompt); add (one); add (two); add (three); add (four); add (five); setBackground (Color.green); setPreferredSize (new Dimension(400, 140)); } //***************************************************************** // Represents the listener for the radio buttons //***************************************************************** private class EOptionListener implements ActionListener { //-------------------------------------------------------------- // Calls the method to process the option for which radio // button was pressed. //-------------------------------------------------------------- public void actionPerformed (ActionEvent event) { Object source = event.getSource(); if (source == one)
  • 12. Assignment21.inputTransactions(); else if (source == two) Assignment21.listTransactions(); else if (source == three) Assignment21.listChecks(); if (source == four)//list deposits Assignment21.listDeposits(); if (source == five) Assignment21.listService_Charges(); } } } //------------------------------Transaction.java----------------------------------- package assignment2.pkg1; public class Transaction { private int transNumber; private int transId; private double tAmount; public Transaction(int number, int id, double amount) { transNumber = number; transId = id; tAmount = amount; } public int getTransNumber() { return transNumber; }
  • 13. public int getTransId() { return transId; } public double getTransAmount() { return tAmount; } }