how to extract data from a file in java and format it properly -


i trying extract data file , calculate totals of persons income. file looks exactly:

mark 20 mike 25 mary 50 mink 5 

the has this:

who     total1  total2  total3 mark     -        -        - mike     -        -        - mary     -        -        - mink     -        -        - combined total total 3: average total 3: 

the "-" lines data show when program calculates it. if first total >10, total multiplied 10. 2nd , 3rd same multiplied 20 , 30 respectively. how can take data file , calculate format shown above? wrote out of code 1 calculation test out, doesn't seem working right. getting several error messages on line of code: error: illegal start of expression public static void calc(double totalone) code:

import java.util.scanner; import java.io.*;  public class income {     public static void main(string[] args) throws ioexception     {      scanner keyboard = new scanner(system.in);      int = 0;       string name = keyboard.nextline();     file file = new file("income.txt");      scanner input = new scanner(file);          system.out.println();         system.out.println("who     total1  total2  total3");      while (input.hasnext())     {         string name = input.nextline();         i++;         system.out.println(name);         double totalone;         calc(totalone);     }     input.close();      public static void calc(double totalone)     {             int money;             if(input.hasnext())             {                 input.nextline();                 int money = input.nextline;             }                 if (money > 10)                 system.out.println(money*10);     } } } 

thanks in advanced!

you trying declare method inside of method. take public static void calc() {...} block out of public static void main() method.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -