Results 1 to 2 of 2

Thread: PLEASE help create a quick program? No idea how.

  1. #1
    Join Date
    Mar 2011
    Posts
    1

    PLEASE help create a quick program? No idea how.

    hi everyone. i just registered on this site because i am totally new to the java world. i am in an object based programming class at school, but my dean placed me in it by accident. it is too advanced for what i previously know (which is nothing, by the way), and i'm trying to get a good grade because i'd have to take the class eventually. we have an assignment due tonight, and i was really hoping for some help. my professor is useless, i just left his office i think i actually understand even less.

    this is the assignment:

    Please write a Java class TotalInterest to complete following task:

    1. Given a principal, an annual compound interest rate, and two integer number m and n, compute the total interest from year m to n. Please note that the interests are calculated from beginning of year 1, i.e. the principal was deposited at the beginning of year 1. Please print your result as follows:

    The total interest from year m to n is nnnnnnn.nn.


    2. You need to replace m, n, and nnnnnnn.nn with the actual starting year m, ending year n, and calculated total interest in the above output.

    3. You need to write another testing program to test the Java class. You can create your own testing cases in the testing program. However, the TotalInterest class could produce the correct results for all other testing cases.

    4.Name the testing code file as TotalInterestTester.java and the class file as TotalInterest.java



    and i have this so far:

    [code]

    import java.util.Scanner;

    public class TotalInterest {

    public static void main(String[] args) {

    Scanner input = new Scanner( System.in );

    double principal;
    double totalAmount;
    double interestRate;
    double interestAccrued;
    double futureValue;
    int m;
    int n;

    System.out.println( "Enter Principal Amount" );
    principal = input.nextDouble ();
    System.out.println( "Enter Interest Rate" );
    interestRate = input.nextDouble ();
    System.out.println( "Enter Beginning Year" );
    m = input.nextInt ();
    System.out.println( "Enter Ending Year");
    n = input.nextInt ();

    futureValue = principal * ( 1 + Math.pow(1.0 + interestRate, )



    System.out.print( "The total interest from year [m] to year [n] is [interestAccrued]" );






    }

    }


    thanks in advance. i really need some help PLEASE

  2. #2
    Join Date
    May 2009
    Posts
    837

    Re: PLEASE help create a quick program? No idea how.

    As said by you that you need the code based on java and which computed the total interest then the below code is some what similar to yours so i want you to just go through it and built your program further on the same.

    Code:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class TotalInterest extends JFrame
    {
            TotalInterest(){
            JLabel lab1=new JLabel("Principal");
            final JTextField text1=new JTextField(20);
    
            JLabel lab2=new JLabel("Rate of Interest");
            final JTextField text2= new JTextField(20);
    
            JLabel lab3=new JLabel("Number of Months");
            final JTextField text3=new JTextField(20);
    
            JButton b=new JButton("Get");
            b.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                double p=Double.parseDouble(text1.getText());
                double r=Double.parseDouble(text2.getText())/100;
                double t=Double.parseDouble(text3.getText())/12;
    
                double interest=p*r*t;
                JOptionPane.showMessageDialog(null, "Total Interest is: "+interest);
    
                }
            });
               setLayout(null);
               lab1.setBounds(10,10,100,20);
               text1.setBounds(150,10,200,20);
               lab2.setBounds(10,40,100,20);
               text2.setBounds(150,40,200,20);
               lab3.setBounds(10,70,120,20);
               text3.setBounds(150,70,200,20);
               b.setBounds(150,110,70,20);
               add(lab1);
               add(text1);
               add(lab2);
               add(text2);
               add(lab3);
               add(text3);
               add(b);
               setVisible(true);
               setSize(400,200);
            }
        public static void main(String[] args) 
        {
        new TotalInterest();
            }
    }

Similar Threads

  1. Windows Vista: slow program start up from quick launch
    By dino88 in forum Operating Systems
    Replies: 4
    Last Post: 01-02-2011, 07:43 PM
  2. Idea how to ensure torrent client program integrity
    By Tanveer Joshi in forum Technology & Internet
    Replies: 6
    Last Post: 04-08-2010, 12:04 AM
  3. How to Create Macro in VBA program?
    By Bigga Lexx in forum Software Development
    Replies: 5
    Last Post: 23-01-2010, 06:22 PM
  4. Create a new toolbar in the Quick Launch bar
    By Preetish in forum Customize Desktop
    Replies: 3
    Last Post: 06-03-2009, 09:36 AM
  5. Replies: 3
    Last Post: 19-01-2009, 04:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,421,668.31243 seconds with 17 queries