“name1 = stdin.next();name2 = stdin.next();name3 = stdin.next();System.out.println(name1 + “”, “” + name2 + “” and “” + name3);System.out.println(name1 + “”, “” + name3 + “” and “” + name2);System.out.println(name2 + “”, “” + name1 + “” and “” + name3);System.out.println(name2 + “”, “” + name3 + “” and “” + name1);System.out.println(name3 + “”, “” + name2 + “” and “” + name1);System.out.println(name3 + “”, “” + name1 + “” and “” + name2);”,”Three business partners are forming a company whose name will be of the form “”Name1, Name2 and Name3″”. However, they can’t agree whose name should be first, second or last. Help them out by writing code that reads in their three names and prints each possible combination exactly once, on a line by itself (that is, each possible combination is terminated with a newline character ). Assume that name1, name2 and name3 have already been declared and use them in your code. Assume also that stdin is a variable that references a Scanner object associated with standard input. For example, if your code read in “”Larry””, “”Curly”” and “”Moe”” it would print out “”Larry, Curly and Moe””, “”Curly, Larry and Moe””, etc.

Average Rating 0 out of 5 stars. 0 votes.You must log in to submit a review.“name1 = stdin.next();name2 = stdin.next();name3[…]

Read more

“”””” + firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0)”,”Given three String variables that have been declared and given values , firstName, middleName, and lastName, write an expression whose value is the initials of the three names : the first letter of each, joined together. So if firstName, middleName, and lastName, had the values “”John””, “”Fitzgerald””, and “”Kennedy””, the expression ‘s value would be JFK””. Alternatively, if firstName, middleName, and lastName, had the values “”Franklin””, “”Delano””, and “”Roosevelt””

Average Rating 0 out of 5 stars. 0 votes.You must log in to submit a review.“”””” + firstName.charAt(0) + middleName.charAt(0)[…]

Read more

“pos = line.indexOf(‘,’);clause = line.substring(0,pos);”,”Write a sequence of statements that finds the first comma in the String line, and assigns to the variable clause the portion of line up to, but not including the comma. You may assume that an int variable pos, as well as the variables line and clause

Average Rating 0 out of 5 stars. 0 votes.You must log in to submit a review.“pos = line.indexOf(‘,’);clause = line.substring(0,pos);”,”Write[…]

Read more

“int start = sentence.indexOf(“” “”);int end = sentence.indexOf(“” “”, 0);firstWord = sentence.substring(0,sentence.indexOf(‘ ‘));”,”Assume that sentence is a variable of type String that has been assigned a value . Assume furthermore that this value is a String consisting of words separated by single space characters with a period at the end. For example: “”This is a possible value of sentence.””Assume that there is another variable declared , firstWord, also of type String . Write the statements needed so that the first word of the value of sentence is assigned to firstWord. So

Average Rating 0 out of 5 stars. 0 votes.You must log in to submit a review.“int start = sentence.indexOf(“” “”);int[…]

Read more