Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
In netbeans, Write a method named findLastTwoLetters that is passed a String parameter and that prints the last two letters of the string. For example, “ta” is returned if the parameter is “Roberta”. You are guaranteed as a precondition that the parameter will have a length greater than 1. This method can be completed using substring().
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
Knowledge Booster
Similar questions
- Implement the copy assignment operator= for the StringVar class using the options given on the right side window. Place the code into the left side using the arrows. It is possible to get the test case correct but not complete NOTE: Be careful! There are decoys! The this pointer is used extensively.. Assume that StringVar.h has the following declaration: #include <iostream> class StringVar {public:StringVar() : max_length(20) { // Default constructor size is 20value = new char[max_length+1];value[0] = '\0';}StringVar(int size); // Takes an int for sizeStringVar(const char cstr[]); // Takes a c-string and copies itStringVar(const StringVar& strObj); // Copy Constructor~StringVar(); // Destructorint size() const { return max_length; } // Access capacityconst char* c_str() const { return value; } // Access valueint length() const { return strlen(value); } // Access lengthStringVar& operator= (const StringVar& rightObj);std::istream& operator>>…arrow_forwardWrite a java code for this. Strings Read the paragraph and encrypt the content using the following rules; "The String, StringBuffer, and StringBuilder classes are defined in java.lang. Thus, they are available to all programs automatically. All are declared final, which means that none of these classes may be subclassed. This allows certain optimizations that increase performance to take place on common string operations. All three implement the CharSequence interface." RULES The words ‘the’, ‘and’, and ‘for’ should be replaced by their reverse strings in upper case letters (use predefined functions reverse() and toupper()) The first occurrence of the word ‘are’ should be replaced by ‘AREERA’ and the last occurrence of the word ‘of’ to be replaced by ‘123’.arrow_forwardPlease answer in python Write a method called add_racer which takes in a Boat object and adds it to the end of the racers list. The function does not return anything. Write a method called print_racers which loops through racers and prints the Boat objects. This function takes in no parameters (other than self) and returns nothing. Write a method called count that returns the number of racers. Write a method called race. The race function calls the move function for all of the racers in the BoatRace. Once all the racers have moved, call the print_racers method to display information about the progress of each boat. Then, check if any of the racer’s current_progress is greater than or equal to the race’s distance. If so, then return a list of all of the racers whose current_progress is greater than or equal to distance. If no racer has finished the race then repeat the calls to move and check until at least one racer has finished the race. Examples: Copy the following if…arrow_forward
- There is an error for type in ProgramNode.java. Please fix the error and show the fixed code for ProgramNode.java with the screenshot of the working code.arrow_forwardJava allows for methods to be chained together. Consider the following message from the captain of a pirate ship: String msg1 = " Maroon the First Mate with a flagon of water and a pistol! "; We want to change the message to read the message msg1: String msg2= “Maroon the Quartermaster with a flagon of water.” Three changes need to be made to adjust the string as desired: Trim the leading and trailing whitespace. Replace the substring First Mate with Quartermaster. Remove "and a pistol!" Add a period at the end of the sentence. A “chaining1” method which will apply in sequence 4 operations to perform the above. We will use the trim, replace, and substring methods, in this order. Thus the chaining1 method will receive a string msg1 and return a string msg2. Make sure msg2 is printed. A “chaining2” method which will apply the 4 operations above in one single statement. Thus the chaining2 method will receive a string msg1 and return as string msg2. Make sure msg2 is printedarrow_forwardThe play method in the Player class of the craps game plays an entire game without interaction with the user. Revise the Player class so that its user can make individual rolls of the dice and view the results after each roll. The Player class no longer accumulates a list of rolls, but saves the string representation of each roll after it is made. Add new methods rollDice, getNumberOfRolls, isWinner, and isLoser to the Player class. The last three methods allow the user to obtain the number of rolls and to determine whether there is a winner or a loser. The last two methods are associated with new Boolean instance variables (winner and loser respectively). Two other instance variables track the number of rolls and the string representation of the most recent roll (rollsCount and roll). Another instance variable (atStartup) tracks whether or not the first roll has occurred. At instantiation, the roll, rollsCount, atStartup, winner, and loser variables are set to their appropriate…arrow_forward
- Hello! I am having a problem trying to code a addNode method implementation to my program. I am trying to only get it to sort the lines alphabetically and then the categories will be sorted from the way it is first read in the input text file.So an input file would look like this: Name Clovis Bagwell Interesting The quick brown fox jumped over the lazy dog. Interesting Shake rattle and roll. Name Archibald Beechcroft and the output file should look like this: Name Archibald Beechcroft Clovis Bagwell Interesting Shake rattle and roll. The quick brown fox jumped over the lazy dog. My addNode code keeps organizing all of the categories and the lines in alphabetical order when categories is supposed to be organized by the way they are first read in the text file, and the lines under it are alphabetical.arrow_forward"000" is a string commonly found in weak passwords. Count the number of occurrences of "000" in keyWord and remove all instances of "000" from keyword. Ex: If the input is 000kgnklv$L#x000, then the output is: Number of violations: 2 Remaining string: kgnklv$L#X Note: string.find(item) returns the index of the first occurrence of item in string. If no occurrence is found, then the function returns string:npos. • string.replace(indx, num, subStr) replaces characters at indices indx to indx+num-1 with a copy of subStr. 3 using namespace std; 4 5 int main() { 6 7 8 9 10 11 count = 0; 218H15 16 18 19 string keyword; int count; int index; 12 index = 0; 13 cin >> keyword; 17 14 /* Your code goes here */ cout << "Number of violations: " << count << endl; cout << "Remaining string: " << keyword << endl; return 0; Darrow_forwardComputer Programming Java Write a method named FirstHalf that receives a String parameter named word and then returns the first half of the string. You are guaranteed as a precondition that word has an even length greater than 1.arrow_forward
- Implement a “To Do” list. Tasks have a priority between 1 and 9, and a description (which you can come up with on your own, say, “wash dishes”). The program is going to prompt the user to enter the tasks by running the method add_priority_description, the program adds a new task and prints the current list with priority 1 tasks on the top, and priority 9 tasks at the bottom. The program will continue to ask the user if they want to add another tasks, and repeat the add_priority_description method, or enters Q to run the quit method to quit the program. Sample output (not limited to) 1. Study for the final 1. Take the final 2. Watch Justice League with friends 3. Play ball 9. Wash Dishes 9. Clean room. There is a possibility of two tasks having the same priority. If so, the last task that was entered gets to be printed first. Use HEAP in your solution.arrow_forward!Java on Eclpisearrow_forwardA person has a name (just a first name for simplicity)/and friends. Store the string, separated by spaces. Provide a constructor that constructs a person with a given name and no friends. Provide methodsarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY