Adding doubles from a file to get total in java -
i have text file looks this:
jacob andrews 8159 rose ct mill city or 97322 5552127879 64.00 ryan perkins 7546 prince ave las vegas nv 87126 5553451989 13.00 joshua gilbert 9278 monroe dr corvallis ca 97330 5552832656 95.00 miles crain 4578 chester dr corvallis or 97331 5552345678 1544.00 butch cassidy 5498 sutton pl gresham az 97380 5416565797 1798.56 perry winkle 8185 shaver ave las vegas nv 87126 5553812346 195.66 everything separated tabs.
my while loop this:
while(filescan.hasnextline()) { string currentline = filescan.nextline(); string[]dataset = currentline.split("\t"); string firstname = dataset[0]; string lastname = dataset[1]; string address = dataset[2] +(' '); address += dataset[3] +(' '); address += dataset[4]; string city = dataset[5]; string state = dataset[6]; string zip = dataset[7]; string phone = dataset[8]; string donation = dataset[9]; int zip = integer.parseint(zip); double donation = double.parsedouble(donation); as can see made donation read double, question how donation total? need write code add , total donations cannot figure out. advice great.
before loop:
double totaldonation = 0.0; inside loop, @ end:
totaldonation += donation;
Comments
Post a Comment