Results 1 to 4 of 4
 09262010, 06:16 AM #1Member
 Join Date
 Sep 2010
 Posts
 42
 Rep Power
 0
My program has a logical error but i cant find problem
Java 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; import java.math.*; public class DifAnalysis { public static void main(String[] Arguments){ Scanner oSciNote = new Scanner(System.in); BigDecimal SciNoteP1,Base,Target,SciNoteP2,BaseminusTarget,Answer,BaseminusTargetpow;/* 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.*/ 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"; String oErrorMes; System.out.println(oMetricPrefixes); 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:"); SciNoteP1 = new BigDecimal(oSciNote.nextLine()); System.out.println("Please enter the exponential term:"); SciNoteP2 = new BigDecimal(oSciNote.nextLine()); System.out.println("Please enter the base exponential value:"); Base = new BigDecimal(oSciNote.nextLine()); System.out.println("Please enter the target exponential value:"); Target = new BigDecimal(oSciNote.nextLine()); Base = Base.subtract(Target); Base = Base.abs(); if(Base.compareTo(Target)>0){ Answer = SciNoteP1.multiply(Base); System.out.println(Answer); } if(Base.compareTo(Target)<0){ Answer = SciNoteP1.divide(Base); System.out.println("The answer is: "+Answer); } } }
 09262010, 06:18 AM #2Member
 Join Date
 Sep 2010
 Posts
 42
 Rep Power
 0
i think it has something to do with the if statements
 09262010, 06:23 AM #3Member
 Join Date
 Sep 2010
 Posts
 42
 Rep Power
 0
I found my error, i forget to reset the Base Variable
 09262010, 07:29 AM #4
Thanks for sharing your solution. You can also select "Mark thread solved" from the Tools menu at the top of the thread to show others that it has been solved.
Similar Threads

Error: Could Not Find Main Class. Program Will Exit
By silvia in forum New To JavaReplies: 2Last Post: 09222011, 10:48 PM 
I need help with an error! Cannot find symbol error!
By ambria1975 in forum New To JavaReplies: 2Last Post: 07072010, 02:37 AM 
Some Logical problem
By MuslimCoder in forum New To JavaReplies: 4Last Post: 03012010, 09:12 AM 
could not find main class, the program wil exit error in jar file
By nishant.4545 in forum Advanced JavaReplies: 1Last Post: 07032009, 09:41 PM 
Logical JDBC problem
By nick2price in forum Advanced JavaReplies: 3Last Post: 10032008, 12:34 AM
Bookmarks