473,379 Members | 1,191 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

I want to change this code to take just the keypress of

Expand|Select|Wrap|Line Numbers
  1. package main;
  2.  
  3. import java.awt.event.*;
  4. import javax.swing.*;
  5. import java.awt.*;
  6.  
  7. /**
  8.  * @author 16023
  9.  *
  10.  */
  11.  
  12. public class Calc implements KeyListener{
  13.     /**
  14.      * @param args
  15.      */
  16.     public static void main(String[] args) {
  17.         // TODO Auto-generated method stub
  18.  
  19.  
  20.  
  21.  
  22.            for (int repeat =1; repeat > 0; repeat++) {
  23.  
  24.             int total = 0;
  25.             String num = JOptionPane.showInputDialog("Enter the Number of Properties");
  26.  
  27.             if ( num.contentEquals("E"))
  28.                 System.exit(0);
  29.             else if (num.contentEquals("e"))
  30.                 System.exit(0);    
  31.  
  32.             int a = Integer.parseInt(num);
  33.             System.out.println(num);
  34.  
  35.             String tax = JOptionPane.showInputDialog("Enter the Tax Rate");
  36.  
  37.             if ( tax.contentEquals("E"))
  38.                 System.exit(0);
  39.  
  40.             else if (tax.contentEquals("e"))
  41.                 System.exit(0);    
  42.  
  43.             int b = Integer.parseInt(tax);
  44.             System.out.println(tax);
  45.  
  46.             for (int counter = 0; counter < a; counter++) {
  47.  
  48.             String pv = JOptionPane.showInputDialog("Enter the Property Value");
  49.  
  50.             if ( pv.contentEquals("E"))
  51.                 System.exit(0);
  52.  
  53.             else if (pv.contentEquals("e"))
  54.                 System.exit(0);    
  55.  
  56.             int c = Integer.parseInt(pv);
  57.             System.out.println(pv);
  58.  
  59.             int d = (b*c/100);
  60.             total = total + d;
  61.             }
  62.             JOptionPane.showMessageDialog(null,"The ToTal Tax Is " +total);
  63.             }
  64.  
  65.  
  66.     }
  67.  
  68.     public void keyTyped(KeyEvent e) {
  69.         // TODO Auto-generated method stub
  70.  
  71.     }
  72.  
  73.     public void keyPressed(KeyEvent e) {
  74.         // TODO Auto-generated method stub
  75.         if (e.getKeyCode()==KeyEvent.VK_E)  
  76.             System.exit(0);
  77.  
  78.     }
  79.     public void keyReleased(KeyEvent e) {
  80.         // TODO Auto-generated method stub
  81.  
  82.     //}
  83.  
  84. }
  85. }
Attached Files
File Type: docx package main.docx (14.5 KB, 72 views)
May 1 '20 #1
0 1767

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Adrian Enders | last post by:
I have something that I have never seen before in a MS development product. I have a pretty simple call to a network directory that looks something like this ... Dim dirFolder As...
2
by: Vayse | last post by:
I have read that it is possible to change code while debugging in VB2005, just like you could do in VB6. If so, how do you do it? Thanks Vayse
2
by: JM | last post by:
Hi, I used to chage my code during debugging with Visual Studio 2003 (I just stopped the code using a break point and VS2003 allowed me to change the code, and continue debugging), but now with...
4
by: osfar | last post by:
i want the code 2 make prgress bar 1 moving from 0% to 100% and i want it to take 200 second and after that finish i want msg box appear how please help me im very new
1
by: saravanatmm | last post by:
i want script code for the hover onn the text or images like this url http://www.istockphoto.com/file_search.php?action=file&lightboxID=2351475 Or double click on the text it shows the...
2
by: Benniit | last post by:
Hello, am using VB6 and i have a code in this format 0001. And I want the code to change the following day as 0002 and the next day 0003 in that order. I want it to change just like the system time....
1
by: nagendra padala | last post by:
i want cpp code for packet reordering
1
by: paulo91 | last post by:
hi , pls i want a code that prints product expiration days, months and years remaining, i want the code to serve as a count down timer starting from the day the product was registered to the day it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.