Is it possible to make CHKDSK print the files that are affected?

Make this java program as less complicated as possible. input a no. and print how many times each no. appears.?

  • like if i print 123; it print 1-1 2-1 3-1 3432 prints 2-1 3-2 4-1

  • Answer:

    you can iterate over the string by turning it to char array then check if it is 0 - 9 and add or increment the ammount then print only the one those that are not 0 let say int[] amt = int[10] ; // an array of int for the appearances from 0 - 9 there are only no. right ;) char[] ca = input.toCharArray ; // iterate the characters of the input for ( int x = 0 ; ca.length > x ; x++) // note x++ is a shortcut for x = x + 1 { switch (ca[x]) // im using switch because its much shorter but if you want to if-then-else go ahead { case '0' : amt[0] = amt[0]++; break; case '1' : amt[1] = amt[1]++; break; case '2' : amt[2] = amt[2]++; break; } } String out = new String(); // the output string for ( int y = 0 ; y >= amt.length ; y++) { if ( amt[y] > 0 ) { out.append( y + "-" + amt[y] + ' \n ') ; // the format should be the same like your example // but im not sure if \n is the correct newline character } } System.out.print(out);

Aranya at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.