Results 1 to 20 of 34
- 09-25-2010, 11:52 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
-
Have you had a look athte BigDecimal API? If not, please do so, and in fact that should be the first place you should look before even asking here as the solution is right there in the constructor section: BigDecimal(double val) constructor.
Best of luck and HTH.
- 09-26-2010, 12:01 AM #3
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
I looked but i don't completely understand what its saying. Ive tried it but it didn't work
- 09-26-2010, 12:06 AM #4
Please explain and show the errors.it didn't work
-
Yep, yep. If you show what you've tried, we'll know what you are getting right and what you're getting wrong, and will be able to help you better. Cheers and much luck!
- 09-26-2010, 12:12 AM #6
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
can i give you my source code and you can look at it and see my errors?
-
Yep, that's the idea. Also, if you get any error messages, please post the actual messages and indicate which lines are causing them. If you do post code here though, please don't forget to use code tags so that your code retains its formatting and is readable.
To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.
Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:
Luck!Java Code:[code] // your code goes here // notice how the top and bottom tags are different [/code]
- 09-26-2010, 12:14 AM #8
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
it said something like it cant find method, but i imported everything, i know that
-
sent as a private message:
Nope. You have to post any pertinent code in the forum, not as a private message. I suggest that when you work to try to solve a problem such as this, create a separate new program whose goal is to solve this current problem and do nothing else. Then if you don't solve it, you can post it here and we don't have gobs of code to go through and you don't have to worry about posting all your homework here.
Originally Posted by s0meb0dy
Again, though, please use code tags (please see above).
- 09-26-2010, 12:21 AM #10
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
My Source code(Please don't publish or share)
this is the source code its not done but yeahJava Code:/** * @(#)DifAnalysis.java * * @https://sites.google.com/site/s0m3b0dysstuff/ * @Ryan Fabela * @version 1.00 2010/9/24 */ import java.util.*; import java.io.*; import java.lang.Math; import java.math.BigDecimal; public class DifAnalysis { public static void main(String[] Arguments){ Scanner oSciNote = new Scanner(System.in); String sSciNoteP1,sSciNoteP2,sTarget,sBase,sBaseminusTarget,sAnswer; BigDecimal SciNoteP1,Base,Target,SciNoteP2,BaseminusTarget,Answer;/* P1 Means out of 3.125 x 10^5 the 3.125 part. P2 means the 10^5 part. target is the target exponent, for example when trying to get to kilo- you would put 10^3. base is the metric prefixes exponetial value. answer should be self explanatory.*/ double dTen1 = 10,dTen2 = 10,dTen3 = 10; String oMetricPrefixes = "tera-, T, 10^12\ngiga-, G, 10^9\nmega-, M, 10^6\nkilo-, k, 10^3\ndeci-, d, 10^-1\ncenti-, c, 10^-2\nmilli-, m,10^-3\nmicro-, µ, 10^-6\nnano-, n, 10^-9\npico-, p, 10^-12\nFor base units use 10^0"; System.out.println(oMetricPrefixes); String oErrorMes; System.out.println(); System.out.println("Instruction:\nWhen it asks you for the digit term use the first set of numbers, for example in 3.125 x 10^5 you would put 3.125.\nWhen it asks for the exponential term put the last set of numbers, for exapmle you would put 5.\nWhen it asks for the base exponential value you would put the metric scientific notaion of the metric prefix, for example, when going from micrograms to kilograms you would put -6(refer to above chart)\nWhen it asks for the target exponential value you would use one of the above metric scientific notations, for example when trying to get to kilo- you would put 3./nMakesure to only put numbers and decimal points. No commas!"); System.out.println(); System.out.println("Please put enter the digit term:"); sSciNoteP1 = oSciNote.nextLine(); System.out.println("Please enter the exponential term:"); double dSciNoteP2 = oSciNote.nextDouble(); dTen1 = Math.pow(dTen1,dSciNoteP2); System.out.println("Please enter the base exponential value:"); double dBase = oSciNote.nextDouble(); dTen2 = Math.pow(dTen2,dBase); double dBase1 = dTen2; System.out.println("Please enter the target exponential value:"); double dTarget = oSciNote.nextDouble(); dTen3 = Math.pow(dTen3,dTarget); double dTarget1 = dTen3; double dTen4 = 10; double dBaseminusTarget = Math.abs(dTarget1 - dTen2); dBaseminusTarget = Math.pow(dTen4, dBaseminusTarget); if(dBase > dTarget){ Answer = SciNoteP1.multiply(dBaseminusTarget); System.out.println(answer); } if(dBase < dTarget){ answer = SciNoteP1 / dBaseminusTarget; System.out.println("The answer is: "+answer); } else{ System.out.println("You Messed Up..."); } } }Last edited by Fubarable; 09-26-2010 at 12:22 AM. Reason: moderate edit: quote tags changed to code tags
- 09-26-2010, 12:21 AM #11
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
The
Program is used to calculate Differential analysis
-
Again, please use code tags, not quote tags. I've edited your post and have made the changes.
So, do you in fact convert your double to a BigDecimal using the appropriate BigDecimal constructor before multiplying it to another BigDecimal?
For instance here:
is dBaseminusTarget a BigDecimal object or a double? It should be a BigDecimal object, and can easily be converted using the constructor I linked to above.Java Code:Answer = SciNoteP1.multiply(dBaseminusTarget);
- 09-26-2010, 12:27 AM #13
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
its a double d = double s= string i = int
i can only use double with the Math.pow(); method
- 09-26-2010, 12:30 AM #14
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
how do i convert it then
-
What does this have to do with the price of beer?
I have to wonder whether you should be using double when using BigDecimal in the first place. My own impression is that even if you fix your compile error by using the appropriate constructor, e.g.,
Java Code:BigDecimal bigDecimalA = new BigDecimal("4"); double myDouble = 8.0; BigDecimal result; result = bigDecimalA.multiply(myDouble); // no conversion so doesn't compile result = bigDecimalA.multiply(new BigDecimal(myDouble)); // conversion, so compiles
You'll still lower the accuracy of the result to the double's range with the use of a double. Rather, all numbers should perhaps begin with and stay BigDecimals here. Note that BigDecimal has it's own power method that you can use.
- 09-26-2010, 12:31 AM #16
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
convert dBaseminusTarget to a BigDecimal
- 09-26-2010, 12:32 AM #17
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
but i cant use scanner with a BigDecimal
-
- 09-26-2010, 12:33 AM #19
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
this has nothing to do with beer
-
Similar Threads
-
matrix multiply
By slixtrix in forum New To JavaReplies: 8Last Post: 09-13-2010, 06:50 AM -
multiply two matrixes
By smart princess in forum New To JavaReplies: 8Last Post: 12-06-2009, 06:43 PM -
BigDecimal question
By orchid in forum New To JavaReplies: 2Last Post: 08-12-2008, 01:44 PM -
convert a really big string (len 39) to bigdecimal
By coolsig in forum Advanced JavaReplies: 6Last Post: 06-14-2008, 02:48 AM -
BigDecimal - Help formulating if statments
By shinjitsunohana in forum New To JavaReplies: 5Last Post: 04-28-2008, 10:12 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks