This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Murach's Java Programming and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to combine two records in for loop - looping error  RSS feed

 
Prasheel Mishra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


I have a requirement that if a record has two different fee cat types  1 and 2,  then I want to check if a record has fee type 1 then fetch amount1, check if has feetype2 as well then fetch amount2 then add to the map as a single record with feetype1 and amount as (amount 1 + amount 2).

I have put the entire block of code to see the looping. The logic is in the first else block where flagfirst and secondset are set to true.Please help.


   
 
Norm Radder
Rancher
Posts: 2036
26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
looping error

Please copy the full text of the error message and paste it here. It has important info about the error.
 
Prasheel Mishra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no application error. Its a logical error. I want that if a record has feetype 1 then fetch amount1, check if has feetype2 as well then fetch amount2 then add to the map as a single record with feetype1 and amount as (amount 1 + amount 2).  My logic is not doing the desired. Can you please help.
 
Norm Radder
Rancher
Posts: 2036
26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My logic is not doing the desired

Can you post the results of what the code is doing now?
Add some comments that show what the desired results are.

Is this the correct logic?
 
Prasheel Mishra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have modified the code a bit now.  This is my updated code.  hfsLoanFeeCol has a list of loanids, I am iterating this mainlist, there is a second for loop feeCatTypeList, I am comparing if both feecattype is equal and then check if the reversal flag is true (-1), then check for fee cat type 1 and 2, and do the logic I mentioned. Eg below is the output I need. Please assist.

List of loan ids( hfsLoanFeeCol )
loanid feecatype amount
123    1             10
123   2              20
123   7             10

newbalvalue = X;

I want the fee type map to show output as (1, x-(10+20)) for fee type 1 and 2.
For Fee type 7, it should say X- 10;


 
Norm Radder
Rancher
Posts: 2036
26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you write some pseudo code like my last post that describes the logic you are trying to write code for?
Without a description of the logic for the code you are trying to write, it is very hard to know where the code is not following the logic.

below is the output I need.

Could you post the program's current output for comparison?
 
It runs on an internal combustion engine. This ad does not:
Thoughts on deprecation in Java
https://coderanch.com/t/683016/java/Deprecation-Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!