SlideShare a Scribd company logo
1 of 4
Download to read offline
Design a Windows Desktop application and write the code that will execute according to the
program requirements in Figure 4-108. Before designing the user interface, create a Use Case
Definition. Before writing the code, create an event-planning document for each event in the
program.
Solution
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
public class IncomeTaxCalculator extends Applet implements ActionListener,WindowListener{
private Label label,label1,label2,label3;
private JTextField txt,txt1,txt3,txt4;
private JButton btn1,btn2;
public void init(){
Frame f=new Frame();
Frame f1=new Frame();
f.setLayout(new BorderLayout());
f.setSize(1000, 300);
Panel p=new Panel();
Panel pc1=new Panel();
f.add(pc1,"South");
f.add(p,"North");
label=new Label("Enter Income :");
label1=new Label("Tax To Be Paid :");
label2=new Label("Cess");
label3=new Label("Income Tax");
txt1=new JTextField(10);
txt3=new JTextField(10);
txt4=new JTextField(10);
txt=new JTextField(10);
p.add(label);
p.add(txt);
p.add(label3);
p.add(txt4);
p.add(label2);
p.add(txt3);
p.add(label1);
p.add(txt1);
btn1= new JButton("SUBMIT");
btn2= new JButton("EXIT");
pc1.add(btn1);
pc1.add(btn2);
f.setVisible(true);
btn1.addActionListener(this);
btn2.addActionListener(this);
}
public static void main(String args[]){
new IncomeTaxCalculator().init();
}
@Override
public void actionPerformed(ActionEvent e) {
JButton btn=(JButton)e.getSource();
if(btn==btn1){
double a=Integer.parseInt(txt.getText());
double tax=0,b=0;
if(a>0 && a<=160000){
txt1.setText("0");
txt4.setText("0");
txt3.setText("0");
}else if(a>160000 && a<=300000){
a=a-160000;
tax=0.1*a;
txt4.setText(String.valueOf(tax));
txt3.setText(String.valueOf(tax*.03));
tax+=tax*.03;
txt1.setText(String.valueOf(tax));
}else if(a>300000 && a<=500000){
a=a-300000;
tax=0.2*a+14000;
txt4.setText(String.valueOf(tax));
txt3.setText(String.valueOf(tax*.03));
tax+=tax*.03;
txt1.setText(String.valueOf(tax));
}else if(a>500000){
a=a-500000;
tax=0.3*a+54000;
txt4.setText(String.valueOf(tax));
txt3.setText(String.valueOf(tax*.03));
tax+=tax*.03;
txt1.setText(String.valueOf(tax));
}
}else if(btn==btn2){
System.exit(0);
}
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowOpened(WindowEvent e) {
}
}

More Related Content

Similar to Design a Windows Desktop application and write the code that will exe.pdf

Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
udit652068
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
nidhileena
 
(java) eclipse PleaseDevelop an application that implements a pro.pdf
(java) eclipse PleaseDevelop an application that implements a pro.pdf(java) eclipse PleaseDevelop an application that implements a pro.pdf
(java) eclipse PleaseDevelop an application that implements a pro.pdf
aroraopticals15
 

Similar to Design a Windows Desktop application and write the code that will exe.pdf (20)

Java awt
Java awtJava awt
Java awt
 
Hack2the future Microsoft .NET Gadgeteer
Hack2the future Microsoft .NET GadgeteerHack2the future Microsoft .NET Gadgeteer
Hack2the future Microsoft .NET Gadgeteer
 
GNURAdioDoc-8
GNURAdioDoc-8GNURAdioDoc-8
GNURAdioDoc-8
 
GNURAdioDoc-8
GNURAdioDoc-8GNURAdioDoc-8
GNURAdioDoc-8
 
Lecture 09 high level language
Lecture 09 high level languageLecture 09 high level language
Lecture 09 high level language
 
Advance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWTAdvance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWT
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
(java) eclipse PleaseDevelop an application that implements a pro.pdf
(java) eclipse PleaseDevelop an application that implements a pro.pdf(java) eclipse PleaseDevelop an application that implements a pro.pdf
(java) eclipse PleaseDevelop an application that implements a pro.pdf
 
Notification android
Notification androidNotification android
Notification android
 
Local Notification Tutorial
Local Notification TutorialLocal Notification Tutorial
Local Notification Tutorial
 
Java Programming Projects
Java Programming ProjectsJava Programming Projects
Java Programming Projects
 
Java Programming Assignment
Java Programming AssignmentJava Programming Assignment
Java Programming Assignment
 
CORE JAVA-2
CORE JAVA-2CORE JAVA-2
CORE JAVA-2
 
Practical
PracticalPractical
Practical
 
ch20.pptx
ch20.pptxch20.pptx
ch20.pptx
 
Controller
ControllerController
Controller
 
Session4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) EventsSession4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) Events
 
Lecture 08 virtual machine ii
Lecture 08 virtual machine iiLecture 08 virtual machine ii
Lecture 08 virtual machine ii
 

More from Footageetoffe16

Why was the frontier important in American historySolutionFro.pdf
Why was the frontier important in American historySolutionFro.pdfWhy was the frontier important in American historySolutionFro.pdf
Why was the frontier important in American historySolutionFro.pdf
Footageetoffe16
 
What are the types of nonverbal communication used by President John.pdf
What are the types of nonverbal communication used by President John.pdfWhat are the types of nonverbal communication used by President John.pdf
What are the types of nonverbal communication used by President John.pdf
Footageetoffe16
 
The owner of a small business is planning on expanding his business. .pdf
The owner of a small business is planning on expanding his business. .pdfThe owner of a small business is planning on expanding his business. .pdf
The owner of a small business is planning on expanding his business. .pdf
Footageetoffe16
 
scene from American Samoa Paradise Lost •How does power, both form.pdf
scene from American Samoa Paradise Lost •How does power, both form.pdfscene from American Samoa Paradise Lost •How does power, both form.pdf
scene from American Samoa Paradise Lost •How does power, both form.pdf
Footageetoffe16
 
Problems2. This is a map for a diploid plantR--------35-------.pdf
Problems2. This is a map for a diploid plantR--------35-------.pdfProblems2. This is a map for a diploid plantR--------35-------.pdf
Problems2. This is a map for a diploid plantR--------35-------.pdf
Footageetoffe16
 

More from Footageetoffe16 (20)

Why did the defendants fight jurisdiction in the United States in th.pdf
Why did the defendants fight jurisdiction in the United States in th.pdfWhy did the defendants fight jurisdiction in the United States in th.pdf
Why did the defendants fight jurisdiction in the United States in th.pdf
 
Why was the frontier important in American historySolutionFro.pdf
Why was the frontier important in American historySolutionFro.pdfWhy was the frontier important in American historySolutionFro.pdf
Why was the frontier important in American historySolutionFro.pdf
 
What is the multiplication principle Also, provide example.Solu.pdf
What is the multiplication principle Also, provide example.Solu.pdfWhat is the multiplication principle Also, provide example.Solu.pdf
What is the multiplication principle Also, provide example.Solu.pdf
 
What were the three primary goals of the FASB in developing the Codi.pdf
What were the three primary goals of the FASB in developing the Codi.pdfWhat were the three primary goals of the FASB in developing the Codi.pdf
What were the three primary goals of the FASB in developing the Codi.pdf
 
What is the difference between public relations and public affairs.pdf
What is the difference between public relations and public affairs.pdfWhat is the difference between public relations and public affairs.pdf
What is the difference between public relations and public affairs.pdf
 
What is Network Chatter and how does it affect performanceSolut.pdf
What is Network Chatter and how does it affect performanceSolut.pdfWhat is Network Chatter and how does it affect performanceSolut.pdf
What is Network Chatter and how does it affect performanceSolut.pdf
 
What are the elements types to add video and audio and give some att.pdf
What are the elements types to add video and audio and give some att.pdfWhat are the elements types to add video and audio and give some att.pdf
What are the elements types to add video and audio and give some att.pdf
 
What are the types of nonverbal communication used by President John.pdf
What are the types of nonverbal communication used by President John.pdfWhat are the types of nonverbal communication used by President John.pdf
What are the types of nonverbal communication used by President John.pdf
 
The owner of a small business is planning on expanding his business. .pdf
The owner of a small business is planning on expanding his business. .pdfThe owner of a small business is planning on expanding his business. .pdf
The owner of a small business is planning on expanding his business. .pdf
 
The government safety net creates an adverse selection problem and m.pdf
The government safety net creates an adverse selection problem and m.pdfThe government safety net creates an adverse selection problem and m.pdf
The government safety net creates an adverse selection problem and m.pdf
 
Syntrophy often involvesA. hydrogenB.OxygenC. fermentation by.pdf
Syntrophy often involvesA. hydrogenB.OxygenC. fermentation by.pdfSyntrophy often involvesA. hydrogenB.OxygenC. fermentation by.pdf
Syntrophy often involvesA. hydrogenB.OxygenC. fermentation by.pdf
 
scene from American Samoa Paradise Lost •How does power, both form.pdf
scene from American Samoa Paradise Lost •How does power, both form.pdfscene from American Samoa Paradise Lost •How does power, both form.pdf
scene from American Samoa Paradise Lost •How does power, both form.pdf
 
QUESTION 25 Chris Korda, an advocate of a certain religion, publishes.pdf
QUESTION 25 Chris Korda, an advocate of a certain religion, publishes.pdfQUESTION 25 Chris Korda, an advocate of a certain religion, publishes.pdf
QUESTION 25 Chris Korda, an advocate of a certain religion, publishes.pdf
 
Problems2. This is a map for a diploid plantR--------35-------.pdf
Problems2. This is a map for a diploid plantR--------35-------.pdfProblems2. This is a map for a diploid plantR--------35-------.pdf
Problems2. This is a map for a diploid plantR--------35-------.pdf
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdf
 
PLEASE PLEASE use you own words, do not copy and paste !!!This is .pdf
PLEASE PLEASE use you own words, do not copy and paste !!!This is .pdfPLEASE PLEASE use you own words, do not copy and paste !!!This is .pdf
PLEASE PLEASE use you own words, do not copy and paste !!!This is .pdf
 
List the limitations of the GDP. Which one is most importantSol.pdf
List the limitations of the GDP. Which one is most importantSol.pdfList the limitations of the GDP. Which one is most importantSol.pdf
List the limitations of the GDP. Which one is most importantSol.pdf
 
Information is given about a polynomial f(x) whose coefficients are r.pdf
Information is given about a polynomial f(x) whose coefficients are r.pdfInformation is given about a polynomial f(x) whose coefficients are r.pdf
Information is given about a polynomial f(x) whose coefficients are r.pdf
 
I need to create two binary search trees in Ruby. One using recursio.pdf
I need to create two binary search trees in Ruby. One using recursio.pdfI need to create two binary search trees in Ruby. One using recursio.pdf
I need to create two binary search trees in Ruby. One using recursio.pdf
 
I am studying gut flora and had a few questions.Can you discribe a.pdf
I am studying gut flora and had a few questions.Can you discribe a.pdfI am studying gut flora and had a few questions.Can you discribe a.pdf
I am studying gut flora and had a few questions.Can you discribe a.pdf
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

Design a Windows Desktop application and write the code that will exe.pdf

  • 1. Design a Windows Desktop application and write the code that will execute according to the program requirements in Figure 4-108. Before designing the user interface, create a Use Case Definition. Before writing the code, create an event-planning document for each event in the program. Solution import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.applet.*; public class IncomeTaxCalculator extends Applet implements ActionListener,WindowListener{ private Label label,label1,label2,label3; private JTextField txt,txt1,txt3,txt4; private JButton btn1,btn2; public void init(){ Frame f=new Frame(); Frame f1=new Frame(); f.setLayout(new BorderLayout()); f.setSize(1000, 300); Panel p=new Panel(); Panel pc1=new Panel(); f.add(pc1,"South"); f.add(p,"North"); label=new Label("Enter Income :"); label1=new Label("Tax To Be Paid :"); label2=new Label("Cess"); label3=new Label("Income Tax"); txt1=new JTextField(10); txt3=new JTextField(10); txt4=new JTextField(10); txt=new JTextField(10); p.add(label); p.add(txt); p.add(label3);
  • 2. p.add(txt4); p.add(label2); p.add(txt3); p.add(label1); p.add(txt1); btn1= new JButton("SUBMIT"); btn2= new JButton("EXIT"); pc1.add(btn1); pc1.add(btn2); f.setVisible(true); btn1.addActionListener(this); btn2.addActionListener(this); } public static void main(String args[]){ new IncomeTaxCalculator().init(); } @Override public void actionPerformed(ActionEvent e) { JButton btn=(JButton)e.getSource(); if(btn==btn1){ double a=Integer.parseInt(txt.getText()); double tax=0,b=0; if(a>0 && a<=160000){ txt1.setText("0"); txt4.setText("0"); txt3.setText("0"); }else if(a>160000 && a<=300000){ a=a-160000; tax=0.1*a; txt4.setText(String.valueOf(tax)); txt3.setText(String.valueOf(tax*.03)); tax+=tax*.03; txt1.setText(String.valueOf(tax));
  • 3. }else if(a>300000 && a<=500000){ a=a-300000; tax=0.2*a+14000; txt4.setText(String.valueOf(tax)); txt3.setText(String.valueOf(tax*.03)); tax+=tax*.03; txt1.setText(String.valueOf(tax)); }else if(a>500000){ a=a-500000; tax=0.3*a+54000; txt4.setText(String.valueOf(tax)); txt3.setText(String.valueOf(tax*.03)); tax+=tax*.03; txt1.setText(String.valueOf(tax)); } }else if(btn==btn2){ System.exit(0); } } @Override public void windowActivated(WindowEvent e) { } @Override public void windowClosed(WindowEvent e) { } @Override public void windowClosing(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } @Override
  • 4. public void windowDeiconified(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowOpened(WindowEvent e) { } }