Results 1 to 6 of 6

Thread: Anyone figure out how to solve this? Java based prob

  1. #1
    Join Date
    Dec 2004
    Location
    Northampton, Pennsylvania
    Posts
    423
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Anyone figure out how to solve this? Java based prob

    Okay... So I've got like today and *possibly* tomorrow to finish up my labs for class, and I'm stuck with crappy subpar compilers... jGrasp & Netbeans (Netbeans is good though, so far). Thing is I have been using Visual Studio in class, and Have no idea why I haven't got the problems there. Here's the proggie I'm having trouble with:

    public class Lab9FileInterest
    {
    public static void main(String[] args)throws java.io.IOException
    {
    double Prin,mp,p,i,t;
    double Inter = 0.07;
    int Time;

    FileWriter fw = new FileWriter("Mortgage Table.txt");
    BufferedWriter bw = new BufferedWriter(fw);
    PrintWriter pw = new PrintWriter(bw);

    pw.print(" Wachovia");
    pw.print(" Manager: Linkinkampf19 ");
    pw.print(" Principle Interest Time Payment");

    for (Prin = 50000; Prin <= 100000; Prin++)
    {
    for(Time = 15; Time <= 30; Time++)
    {
    mp = computeMortgage(Prin, Inter, Time);
    DecimalFormat num = new DecimalFormat("$,###.00");
    if (Prin < 100000)
    pw.println(" " + num.format(Prin) + " " + Inter + " " + Time + " " + num.format(mp));
    else
    pw.println(" " + num.format(Prin) + " " + Inter + " " + Time + " " + num.format(mp));
    }
    }
    pw.close();
    }
    public static double computeMortgage(double Prin, double Inter, double Time) {
    double mp; //mp is mortgage payment
    DecimalFormat num = new DecimalFormat("$,###.00");
    mp = (Prin*(Inter/12)/(1-Math.pow((1)/(1+(Inter/12)),(Time*12))));

    return mp;


    }


    }
    So heres the deal, basically the lines for DecimalFormat num and the FileWriter, PrintWriter, and BufferedWriter are unrecognized in both NB and jGrasp, and I have no other way to figure out why this is not compiling properly, except that NB problably doesn't have the right packages installed to compile this app... Can anyone help me here on what I should do? From corrections to files I should download, please, this and teh next two programs I am almost finished depend on whether or not I pass basically (C or D). Please help!!! Rep to all who help in a significant way...

    Also, sorry if it's a little jagged, I just copied and pasted from Netbeans.

  2. #2
    Join Date
    Dec 2004
    Location
    Fantasy Dreamland
    Posts
    1,655
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default

    Hmm. Have you done some importing??

    Before Class write:

    import java.text.DecimalFormat;
    import java.io.*; //this should do for FileWriter, PrintWriter and BufferedWriter

    note: I'm working with JCreator when it goes to Java, but it should work.
    Good luck


  3. #3
    Join Date
    Dec 2004
    Location
    Northampton, Pennsylvania
    Posts
    423
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    OMG... I can't believe I forgot them! I automatically think they are in there sometimes, and then just go on with the rest of teh program! I thought the answer would've bee a little more obscure, but wow, I didn't think it was something as S&S as that. Thanks Mega! Rep to you!
    *bangs head against monitor...*

  4. #4
    Join Date
    Feb 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hey sorry i can't really help i've just failed my java test. but try the forums at java.sun.com they might have the answer. And you may wanna try importing? what Development kit and version of netbeans are you using?

  5. #5
    Join Date
    Dec 2004
    Location
    Fantasy Dreamland
    Posts
    1,655
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by linkinkampf19
    OMG... I can't believe I forgot them! I automatically think they are in there sometimes, and then just go on with the rest of teh program! I thought the answer would've bee a little more obscure, but wow, I didn't think it was something as S&S as that. Thanks Mega! Rep to you!
    *bangs head against monitor...*
    Anytime friend
    I was thinking about getting back to Java when
    I have a little more time.

    Good luck in your labs


  6. #6
    Join Date
    Feb 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    If your using the eclipse development kit it undelines mistakes (like in word) click on mistakes and for example if you didn't import a java util then the relevant prhase lets say ... a file writer is underlined then you double click on it and options come up in a list in there in this case would be import java.util etc. did you get the work to compile? which compiler did you use? i've been after one for a while. does it allow the program to run on other peoples computer without them needing to install java?

Similar Threads

  1. is moblie phone java emulated?
    By Morpheus in forum Everything Emulation
    Replies: 6
    Last Post: 5th-May-2004, 07:49
  2. Alright! I didn't fail Java!
    By Grim Reaper in forum Free 4 All
    Replies: 12
    Last Post: 10th-February-2004, 05:02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About Us

We are the oldest retro gaming forum on the internet. The goal of our community is the complete preservation of all retro video games. Started in 2001 as EmuParadise Forums, our community has grown over the past 18 years into one of the biggest gaming platforms on the internet.

Social