Question

In: Computer Science

How do you post only up to 10 shingle pairs per line in java? Example output:...

How do you post only up to 10 shingle pairs per line in java?

Example output:

'Ho' 'w ' 'ar' 'e ' 'yo' 'u ' 'do' in' ' g' ' t'

'od' 'ay' '? '

Solutions

Expert Solution



I hope the following code demonstrates what you are looking for....
To indent code in eclipse , select code by pressing ctrl+a and then indent using ctrl+i
Please do rate the answer if it was helpful. Thank you

public class Print10 {
public static void main(String[] args) {
String s = "How are you doing today ?";
int count = 1;
int max_per_line = 10;
String substr;
for(int i = 0; i < s.length(); i+= 2)
{
if(i+1 < s.length())
substr = s.substring(i, i+2);
else
substr = s.substring(i, i + 1);
System.out.printf("'%s' ", substr);
if(count == max_per_line)
{
System.out.println();
count = 1;
}
else
count++;
}
}
}

output
-----
'Ho' 'w ' 'ar' 'e ' 'yo' 'u ' 'do' 'in' 'g ' 'to'
'da' 'y ' '?'


Related Solutions

How do you come up with the budgetary cost for the project for example health clinic...
How do you come up with the budgetary cost for the project for example health clinic and convenience outlet?
How do you calculate the consolidated Earnings per share with an example please
How do you calculate the consolidated Earnings per share with an example please
How do you post a general ledger
How do you post a general ledger
How do i make a point for line segment from p to infinite in java? in...
How do i make a point for line segment from p to infinite in java? in C++, it's Point p; Point extreme = {INF, p.y}; --------------------------------------------------------------------------------------------- boolean isInside(Point polygon[], int n, Point p) { // There must be at least 3 vertices in polygon[] if (n < 3) return false;    // Create a point for line segment from p to infinite //Point extreme = {INF, p.y};    p= Double.POSITIVE_INFINITY;    Point extreme = p.y; // Count intersections of the...
Post an example of an interaction you've experienced with someone from a group you do not...
Post an example of an interaction you've experienced with someone from a group you do not belong to (gender, sexual orientation, "race," ethnicity, religion, etc.).   Describe your meta-perceptions going into the interaction, and how those perceptions were confirmed, disconfirmed, or remained ambiguous.   
How do you do this? How do you set it up? One mole of a ideal...
How do you do this? How do you set it up? One mole of a ideal gas initially at temp To=0C undergoes an expansion at a constant pressure of 1atm to four times it original volume. (a) calculate the new temp Tf of the gas. (b) calulate the wok done by the gas during the expansion.
You have a vertical thick line representing a line source emitting 10^6 photons per second per...
You have a vertical thick line representing a line source emitting 10^6 photons per second per cm. With "P" at some distance away. A) Write the equation representing the DIFFERENTIAL contribution to the particle fluence rate at "P". B) Using the results for (A), determine the particle fluence rate if the vertical thick line is 240cm long. The upper segment is 160cm long and the lower is 80cm long. The point "P" is 200cm from the line source (at its...
What do you post in a general journal and how
What do you post in a general journal and how
How much time do you spend talking on your phone per day? Initial post by Wednesday...
How much time do you spend talking on your phone per day? Initial post by Wednesday at 11:59 PM: Guess the number of minutes you think you spend talking on the phone each day. This is your null hypothesis. Posting from Thursday to Sunday, 11:59 PM: Secure the data from your phone for the past month and conduct a one sample hypothesis test of the mean length of your phone calls per day. Be sure to show all your work...
How do I calculate the up-market Beta? Can you give me an example please? Can you...
How do I calculate the up-market Beta? Can you give me an example please? Can you give an examp;le of when it is was a good market timer and when it is a bad market timer
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT