Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » I need help with this code folks
I need help with this code folks [message #1496772] Wed, 03 December 2014 08:57 Go to next message
Nick Boris Schwartz is currently offline Nick Boris SchwartzFriend
Messages: 1
Registered: December 2014
Junior Member
Need help with basic java code

Hi guys. I need some help on this code. It compiles and I can get results when I run it on Netbeans but I always get RuntimeException.
I found out on Javadocs that this is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtual Machine. How can I get rid of it? Any thoughts? Thanks!


        // i++
        float Etplus, TrueEplus, TrueVplus, fplus1=0;
        //  Summation from i=1 to 10000
        for (int i=1;i<=10000;i++){
            fplus1 +=(float) 1/(Math.pow(i,4));
        }
        TrueVplus = (float) ((Math.pow(Math.PI, 4)) / 90);
        TrueEplus = (float) TrueVplus - fplus1;
        Etplus = (float)(TrueEplus/TrueVplus)*100;
   
        JOptionPane.showMessageDialog (null,"Ft(i++) = "+TrueVplus + "\n\nFa(i++) = " +fplus1 + "\n\nEt(i++) = ("+Etplus+ ")%","Results for i++ (Float)", JOptionPane.INFORMATION_MESSAGE);
       
        // i--
        float Etminus, TrueEminus, TrueVminus, fminus1=0;

        //  Summation from i=10000 to 1
        for (int j=10000;j>=1;j--){
            fminus1 += (double) 1/(Math.pow(j, 4));
        }

        TrueVminus = (double) (Math.pow((Math.PI), 4))/90;
        TrueEminus = (double) TrueVminus - fminus1;
        Etminus = (double) (TrueEminus/TrueVminus)*100;
        
        JOptionPane.showMessageDialog (null, "Ft(i--) = "
+TrueVminus + "\n\nFa(i--) = " +fminus1 + "\n\nEt(i--) = (" +Etminus+")%","Results for i--(Float)", JOptionPane.INFORMATION_MESSAGE);

 }

}
Re: I need help with this code folks [message #1500783 is a reply to message #1496772] Sat, 06 December 2014 07:21 Go to previous message
George Maravich is currently offline George MaravichFriend
Messages: 7
Registered: December 2014
Junior Member
Try changing all float into double. This is maybe due to lossy conversion. Also pls can you give the full stack trace for this?
Previous Topic:Ok, I give up. How do I change the color of the package explorer window, and console pane, etc...
Next Topic:Cant run eclipse
Goto Forum:
  


Current Time: Sun Nov 29 08:30:29 GMT 2020

Powered by FUDForum. Page generated in 0.02080 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top