I'm a newbie to Java and have to implement a solution at work to calculate cumulative difference. I am extracting data from a flat file using Informatica powercenter. One of the columns is total deductions for a department. The logic required to transform data in this column is below.
If Total deductions<=9999999.99, then display the value as is, ie 9999999.99
If Total deductions>9999999.99, then display 9999999.99 and in the next line display the difference between 9999999.99 and incoming value. For ex, if incoming value is 10000000.99, then display 9999999.99 1
If total deductions = 20000000.98 then display the below 9999999.99 9999999.99 1
I have the below code where I am hard coding values, and feel like this can be accomplished dynamically.
package day1.examples;
public class MedicalCenter {
public static void main(String[] args) {
double v=9999999.99;
double i=20000000.98;
if (i<v) {
System.out.println(i);
}
if (i>v && i<=9999999.99*2) {
System.out.println(9999999.99);
System.out.println(i-v);
}
if (i>v && i<=9999999.99*3) {
System.out.println(9999999.99);
System.out.println(9999999.99);
System.out.println(i-9999999.99*2);
};
}
}
Sample Output:
9999999.99
9999999.99
1.0