# Thread: My program has a logical error but i cant find problem

1. Member
Join Date
Sep 2010
Posts
42
Rep Power
0

## My program has a logical error but i cant find problem

Java Code:
```/**
* @(#)DifAnalysis.java
*
* @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.

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());

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){
}
if(Base.compareTo(Target)<0){
}

}

}```
i keep getting zero. It's supposed to solve differential Analysis problems but its not working...

2. Member
Join Date
Sep 2010
Posts
42
Rep Power
0
i think it has something to do with the if statements

3. Member
Join Date
Sep 2010
Posts
42
Rep Power
0
I found my error, i forget to reset the Base Variable

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.

#### Posting Permissions

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