G U I ( I need to add a gui) please help

I am trying to design an implement a GUI for this program. This program should let the user input the interest rate, principle, and period, and should accumalate value of interest.
* File: CDInterest.java
* Tamar Thompson
* Description: This application program illustrates the use of Java library
* classes to perform certain useful calculations.
* It uses the java.lang.Math class to calculate the principal of a
* Certificate of Deposit (CD) invested at a certain interest rate for a certain
* time period. It uses the java.text.NumberFormat class to format the numerical results
* which represent dollar amounts and percentages.
import java.io.*; // Import the Java I/O Classes
import java.text.NumberFormat; // For formatting as $nn.dd or n%
public class CDInterest {
private BufferedReader input = new BufferedReader // Handles console input
(new InputStreamReader(System.in));
private String inputString; // Stores the input
private double principal; // The CD's initial principal
private double rate; // CD's interest rate
private double years; // Number of years to maturity
private double cdAnnual; // Accumulated principal with annual compounding
private double cdDaily; // Accumulated principal with daily compounding
* convertStringTodouble() converts a String of the form "54.87" into
* its corresponding double value (54.87).
* @param s -- stores the string to be converted
* @return A double is returned
private double convertStringTodouble(String s) {
Double doubleObject = Double.valueOf(s) ;
return doubleObject.doubleValue();
* getInput() handles all the input required by the program. It inputs
* three Strings and converts each to a (double) number, storing them
* in instance variables (principal, rate, and years).
private void getInput() throws IOException {
// Prompt the user and get the input
System.out.println("This program compares daily and annual compounding for a CD.");
System.out.print(" Input the CD's initial principal, e.g. 1000.55 > ");
inputString = input.readLine();
principal = convertStringTodouble(inputString);
System.out.print(" Input the CD's interest rate, e.g. 6.5 > ");
inputString = input.readLine();
rate = (convertStringTodouble(inputString)) / 100.0;
System.out.print(" Input the number of years to maturity, e.g., 10.5 > ");
inputString = input.readLine();
years = convertStringTodouble(inputString);
} //getInput()
* calcAndReportResults() handles all the interest calculations and reports
* the program's results. Note the use of Math.pow() to calculate the CD's
* value, and the use of the NumberFormat.format() methods for making the output
* look pretty.
private void calcAndReportResult() {
// Calculate and output the result
NumberFormat dollars = NumberFormat.getCurrencyInstance(); // Set up formats
NumberFormat percent = NumberFormat.getPercentInstance();
percent.setMaximumFractionDigits(2);
cdAnnual = principal * Math.pow(1 + rate, years); // Calculate interest
cdDaily = principal * Math.pow(1 + rate/365, years*365);
// Print the results
System.out.println("The original principal is " + dollars.format(principal));
System.out.println("The resulting principal compounded daily at " +
percent.format(rate) + " is " + dollars.format(cdDaily));
System.out.println("The resulting principal compounded yearly at " +
percent.format(rate) + " is " + dollars.format(cdAnnual));
} // calcAndReportResult()
* main() creates an instance of the CDInterest object and then invokes
* its methods to calculate the interest for a CD using values input by
* the user.
public static void main( String args[] ) throws IOException {
CDInterest cd = new CDInterest();
cd.getInput();
cd.calcAndReportResult();
} // main()
} // Interest

Then you are going to have to do a lot of rewriting, because GUI programs don't actively "get" input. (At least they shouldn't.) They passively wait until somebody keys some input into a field or clicks on a button. Have you looked at the Swing tutorial?

Similar Messages

  • I can't get Firefox 10.0 to recognize 1password 3.8.15. The extension doesn't stay as an add-on. Please help!

    I can't get Firefox 10.0 to recognize 1password 3.8.15. The extension doesn't stay as an add-on. Please help!

    1passowrd team released support for Firefox 10 already. Do an autometic update and check.See:
    * http://support.agilebits.com/discussions/1password-for-windows/487-firefox-100-doesnt-support-1password

  • How to add fingerprint to 5s? I can`t press add a fingerpint please HELP ios 8,0,2

    How to add fingerprint to 5s? I can`t press add a fingerpint please HELP ios 8,0,2

    Hi, SillDeividas.  
    Thank you for visiting Apple Support Communities. 
    Here is an article that I would recommend taking a look at for this issue.  
    Get help with Touch ID
    Make sure that you're using the latest version of iOS.
    Make sure that your fingers and the Home button are clean and dry.*
    Cover the Home button completely. Don't tap too quickly, don't press down hard, and don't move your finger while Touch ID is scanning. Make sure that your finger touches the metal ring around the Home button.
    If you're using a case or screen protector, make sure it doesn't cover the Home button or the surrounding ring. If it does, remove the case or screen protector and try again.
    Tap Settings > Touch ID & Passcode and make sure that iPhone Unlock or iTunes & App Store is on. Also make sure that you've enrolled one or more fingerprints.
    Try enrolling a different finger.
    If you can't enroll any of your fingers, take your device to an Apple Retail Store, Apple Authorized Service Provider, or contact AppleCare for help.
    * Moisture, lotions, sweat, oils, cuts, or dry skin might affect fingerprint recognition. Certain activities can also temporarily affect fingerprint recognition, including exercising, showering, swimming, cooking, or other conditions or changes that affect your fingerprint.
    iPhone 5s: Using Touch ID
    http://support.apple.com/kb/HT5883
    Cheers,
    Jason H.

  • PLEASE HELP ME.  Some important emails have gone to an archive mail box and i really need them.  Can someone please help me with how to view the archive email box and the emails that are in there?

    PLEASE HELP ME.  Some important emails have gone to an archive mail box and i really need them.  Can someone please help me with how to view the archive email box and the emails that are in there?

    http://kb.mozillazine.org/Recovering_deleted_mail_accounts

  • HT201328 my iphone 4G buy from japan, i need to use in indonesian, please help me, i spent much money for this phone.....

    my iphone 4G buy from japan, i need to use in indonesian, please help me, i spent much money for this phone.....

    froggy_vic wrote:
    so even if your phone is unlocked you wouldn't be able to use it anywhere else.
    Absolutely not true. There is no difference, spec wise, between the iPhone sold in Japan & the GSM iPhone sold everywhere else. iPhones in Japan use UMTS 2100.

  • Our iTunes will not open.  It reads that we need the English version? Please help.

    Our iTunes will not open.  It reads that we need the English version? Please help. 
    If I download a new iTunes will I lose everything we have?

    Same issue for me.  Was running 10.5.3 due to the bug in 10.6 with Apple TV.  Upgraded to 10.6.1 since it was supposed to solve the issues.  ANd no I can;t open iTunes at all.
    Annoyed that 10.6 was shipped with the bug with the Apple TV sortting of titles.
    Really p*ssed off that 10.6.1 which was supposed to fix this has totally borken iTunes for me.
    Time to try to revert to 10.5.3 again.
    Apple, what's happened with Q/A.
    (My setup - latest patched Lion, upgraded via Automatic update; so nothing out of the ordinary.)

  • My i phone 4 cannot charge continously. it will charge then after few seconds its off then charge again. I cannot open it because it runs out of battery do i need a new battery?please help.

    my i phone 4 cannot charge continously. it will charge then after few seconds its off then charge again. I cannot open it because it runs out of battery do i need a new battery?please help.

    You could always check to make sure itunes is updated to 10.7 but im sure gdgmacdude is
    right.
    thanks
    gdgmacdude
    Hey dude
    are there anymore hardware failure errors u know of
    im kinda a novice apple man and could use all the help i can get
    capp

  • Hi! I'm in the middle of updating the softwear and its not moved and it's been over half an hour. Will it load as I need it for work! Please help!!

    Hi! I'm in the middle of updating the softwear and its not moved and it's been over half an hour. Will it load as I need it for work! Please help!

    hold down the home/sleep button together until you see the apple logo and then releaswe.

  • Hot to erase icloud accounts? i have free, but I need only one... please help.tynly one i nide

    hot to erase icloud accounts? i have free, but I need only one... please help.

    all different... i want save just dis one [email protected]

  • HT201303 My ipad has been disabled.  I need to enable it.  Please help!

    Hello, my ipad has been disabled for sometime and I need to enable it.  Please Help!

    FORCE IPAD INTO RECOVERY MODE
    1. Turn off iPad
    2. Turn on computer and launch iTunes (make sure you have the latest version of iTune)
    3. Plug USB cable into computer's USB port
    4. Hold Home button down and plug the other end of cable into docking port. Do not release button until you see picture of iTunes and plug (very important)
    5. Release Home button.
    ON COMPUTER
    6. iTunes has detected iPad in recovery mode. You must restore this iPad before it can be used with iTunes.
    7. Select "Restore iPad"...
    Note: Data will be lost

  • My iPod won't turn on even when I plug it into my charger. I don't want to spend too much fixing it but I need to use it. Please help!!

    My iPod won't turn on even when I plug it into my charger. I don't want to spend too much fixing it but I need to use it. Please help!!

    Try:                                               
    - iOS: Not responding or does not turn on           
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try another cable              
    - Try on another computer                                                       
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar                                     

  • I need answers about the iCloud - Please help

    Hi guys, well I have a few iOS devices, 2 ipads, and an iphone. Well, I got a few questions to ask.
    1. Ok, on my iphone on settings on the icloud bit, I have my iphone back up aswell as the 2 ipads. What will happen if I delete the back up for 1 of the ipads. Like, I don't know whats on the back up. And If I want a new back up for the ipad, how to I create 1?
    2. On the icloud section with all 3 ios devices, my 5gb of storage is full, and each device has a bit of storage used up by it. The iphone - 1.7gb, ipad 1 - 600 mb... And it all adds up to around 5gb. But what I don't understand is, on 1 of the ipads it says I've used up 17gb of storage (not icloud), so why has the icloud only stored 600 mb of it? Shouldn't it store like the whole 5gb? I really don't know... I need all the info about the icloud. And yes I've read all of it on this website but none of it helps.
    3. Since it say the icloud storage is full, how do i get more storage, should I just buy more, or is there another way?
    All I know is, if I have icloud set up on all 3 of my devices, what ever i buy on 1 devices it goes on the other 3.
    And that, i have a back up with all my music n stuff in, just incase something goes wrong. Please help! Thanks!

    iCloud Support
    http://www.apple.com/support/icloud/
    iCloud Help
    http://help.apple.com/icloud/?lang=en

  • I need to create Buttons dynamically Please Help

    I am currently developing a card game. I represent my cards as buttons. But as the player draws more cards from the deck I have to generate buttons dynamically at run-time. I could use arrays of buttons and store new buttons inside that arrays of buttons. But the only problem is I need ActionListener for each of my buttons. How do you create ActionListener for each different dynamically created buttons? Please Help.

    Here is my code. I just do not understand how to create those functions dynamically that functions different each time.
    Here is my code please take a look.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class run108{
    JButton setbutton;
    JButton ButtonUp;
    JButton ButtonDeal;     
    JButton slot1;
    JButton slot2;
    JButton slot3;
    JButton slot4;
    JButton slot5;
    JButton slot6;
    JButton slot7;
    cards[] card = new cards[55];
    public static void main(String[] argv)
         run108 startgui = new run108();
         startgui.createframe();     
    void createframe()
         //Standard of way of creating Frame
         JFrame frame = new JFrame("108");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.setLocation(300,200);// Tells the startup position;
         //Adding Panels to the framework
         JPanel panelA = new JPanel();
         panelA.setBackground(Color.white);
         panelA.setLayout(new BoxLayout(panelA,BoxLayout.Y_AXIS));
         JPanel panelB = new JPanel();
         JPanel panelC = new JPanel();
         //Adding buttons with card images
         JLabel label1 = new JLabel("       Set of Cards");
         panelA.add(label1);
         ImageIcon pic1 = new ImageIcon("cards/backd.png");
         setbutton = new JButton(pic1);          
        panelA.add(setbutton);
        ImageIcon picdeal = new ImageIcon("cards/deal.png");
         ButtonDeal = new JButton(picdeal);
         panelA.add(BorderLayout.CENTER, ButtonDeal);
        ButtonDeal.addActionListener(new DealListener());
         JLabel label2 = new JLabel("       Your Target");
         panelA.add(label2);
         ButtonUp = new JButton(pic1);          
        panelA.add(BorderLayout.CENTER, ButtonUp);
        frame.add(BorderLayout.WEST,panelA);
        // Adds 7 initial card slots.
         ImageIcon pic2 = new ImageIcon("cards/backc.png");
         slot1 = new JButton(pic2);
        panelB.add(slot1);          
        slot1.addActionListener(new Slot1Listener());
        slot2 = new JButton(pic2);
        panelB.add(slot2);
        slot2.addActionListener(new Slot2Listener());
         slot3 = new JButton(pic2);
        panelB.add(slot3);
        slot3.addActionListener(new Slot3Listener());
         slot4 = new JButton(pic2);
        panelB.add(slot4);
        slot4.addActionListener(new Slot4Listener());
         slot5 = new JButton(pic2);
        panelB.add(slot5);
        slot5.addActionListener(new Slot5Listener());
         slot6 = new JButton(pic2);
        panelB.add(slot6);
        slot6.addActionListener(new Slot6Listener());
         slot7 = new JButton(pic2);
        panelB.add(slot7);
        slot7.addActionListener(new Slot7Listener());
        frame.add(BorderLayout.CENTER,panelB);
        // This has to be added @ the end to show the components
        //that were added after on. If it is placed before the components
        //the components shall not appear since they sit on the frame
         frame.setSize(600,500);
         frame.setVisible(true);
    class DealListener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot1Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot2Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot3Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot4Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot5Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot6Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    class Slot7Listener implements ActionListener
         public void actionPerformed(ActionEvent event){}
    }

  • -How to change the Alternate Apple ID? My account has an alternate address which is NOT MINE and I need to change it. Please, help!

    -On iCloud, how can I change the Alternate Apple ID? My account has an alternate address which is NOT MINE and I need to change it ASAP. Please, help!

    Read here >  How do I change my alternate Apple ID

  • How to use webdynpro abap? need separate software? or please help me.. :-)

    How to use webdynpro abap? need any separate software? if no, please help me with Transaction Codes..
    Thanks in Advance
    -Parthi
    Moderator message: please search for available information/documentation.
    Edited by: Thomas Zloch on Oct 19, 2011 8:18 PM

    I don't think you quite understand how hibernation mode works.
    "The state of a computer is stored into its main memory, which is also called RAM. When a
    computer is powered off, the contents of this memory are irremediably wiped out. Hiberna-
    tion works in the following way: before being powered off, the computer saves all the con-
    tents of the memory to a file on the hard disk drive. On wake up, data stored in this file is
    read out and restored to the memory. Therefore, the RAM contents are the same before
    and after the hibernation process, and the state of the computer is also the same. The
    saved file is named sleepimage, and is located in the /private/var/vm directory. Hi-
    bernation is sometimes also called “software suspend” or “suspend to disk”.
    The default suspension feature of Mac OS X, called sleep works in a different way. When
    entering sleep, every subsystem of the computer is shut down, except the main memory
    which is still powered. This process preserves the contents of the memory, and allows the
    computer to wake up quickly. However, a sleeping computer still consumes a small
    amount of power. Sleep is sometimes also called “hardware suspend” or “suspend to
    RAM”.
    Apple introduced the safe sleep feature in Mac OS X 10.4.3 for the Powerbook HD line of
    laptops. This feature is a variation of the default suspension behavior. The main memory is
    still powered during the sleep, but the contents of the memory are also saved to the disk at
    the beginning of the operation. The saved file will only be used if the laptop runs out of bat-
    tery power while sleeping, in order to restore the original state of the computer.
    This safe sleep feature is what makes hibernation possible in Mac OS X 10.4.3 and above."
    Quoted from *Deep Sleep v. 0.7 documentation*
    Matthieu Beaumel, 10/03/2006

Maybe you are looking for

  • Yoga 2 Pro - trackpad does not disable in tablet mode

    How do i set the trackpad to disable in table mode? I cannot use it as a tablet as the trackpad is still active.

  • Uploading of Open Process orders

    Hi, I have a requirement in my project to upload the Open Process orders with the legacy number range. Please let me know how this is possible . Regards Sudhakar

  • ITunes Server on a NAS...I don't get it...please help!

    Hello, I currently have all my iTunes files (including the library file) on a small network drive. iTunes is set to point there for storing music and the library file, so any computer on my network can access the same library and info. All is well. R

  • WRT160N won't connect to tv

    I'm having an issue getting my tv to start connecting again to the wireless router. Have tried pin setup (timed out & didn't connect...attempted at least 10 times in this fashion) Have tried entering the password (router seems to refuse the connectio

  • Simlpe java probbie

    import javax.servlet.*; brings up the error cannot resolve symbol servlet (on ".servlet). I have j2sdk1.4.1_01 and jwsdp-1.1 I guess I just don't have any/all the javax package; so what should I download (I've a 56K modem atm so small downloads...) T