/** * Adds letterGuessed to the current String updateLetterBoard * @param usedLetterBoard * @param letterGuessed * @param first * @return updateLetterBoard with letterGuess appended. */ public static String updateLetterBoard(String usedLetterBoard, char letterGuessed, boolean first) {
Q: public class CustomString { String myString; boolean isSet; public CustomString()…
A: Step 1 : Start. Step 2 : Create a class named CustomString.java. Step 3 : Create a method to input…
Q: Word Separator Write a program that accepts as input a sentence in which all of the words are run…
A: The objective is to write a program code that accepts as input a sentence in which all of the words…
Q: The result of the following is __. string str = "jlo@testmail.com"; string newStr = ""; string[]…
A: Given that The result of the following is __. string str = "jlo@testmail.com";string newStr =…
Q: Returns a lowercase version of a user-entered letter * @param kbd * @return lowercase version of…
A: In Java, Scanner class is used to accept input from user Scanner class has various methods like…
Q: public static void main(String[] args) throws IOException{ BufferedReader b=new BufferedReader(new…
A: Answer: The given program accepts the instructor's salary and its academic rank then it prints the…
Q: public static String reverseVowels(String text) Given a text string, create and return a new string…
A: Given data is shown below:
Q: void addSpouse(string m, string A method that takes the names of the member and spouse, searches for…
A: Explanation here we will discuss a c++ code to do the above task of finding a particular member and…
Q: def get_time() -> tuple: Returns a tuple that contains the date and time e.g. (date, time) Date and…
A: ALGORITHM:- 1. Create a tuple. 2. Insert the today's date object and current time object in it. 3.…
Q: first: String initial : char last i String • Name () void • Name (String arirst, char aninitial,…
A: Name.java
Q: Book 1 Author -name: String -author:Author -price:double -name: String -email: String -gender: char…
A: UML stands for Unified Model Language.UML tool is used to design the class diagrams. The name of the…
Q: Write a switch statement that checks origLetter. If 'a' or 'A', print "Alpha". If 'b' or 'B', print…
A: Programing Approach: Import all packages required. Declaring the ConvertToGreek class Defining the…
Q: I have problem in java 2 code: lease.setApartmentNumber(sc.nextLine()); melt:String cannot be…
A: Scanner class is used to accept input from user nextLine() will return the input in string format…
Q: nethod. ) Method 1: - Takes 1 String parameter - Prints out "Hello" + the String argument ) Method…
A: GIVEN: Create a Java program for the above-given question.
Q: Returns currentGuess with BLANK replaced by letterGuessed everywhere letterGuessed appears in…
A: We create a array of character and put in the letterGuessed in it at places where it comes in…
Q: bool isSubsetOf(const IntSet& otherIntSet) const // Pre: (none) // Post: True is returned…
A: Function Description: Loop through each of the elements in the data and check the following: Use…
Q: void Secret (char txti[], char txt2[]) ( if(stramp (txt1, txt2)) strepy (txt2, "golf"); else strepy…
A: I provide the output screenshot for each condition.
Q: #include #include using namespace std; class Students { protected: string firstName; string…
A: C++ is and object oriented programming language.
Q: What does the following code produce? new String("Cheggers2019"); String myStr = new…
A: Answer : In above code, String class the 'Cheggers2019' is defined. Print function will print the…
Q: What is displayed after executing the following code: public static boolean isEmpty( String testStr…
A: Actually, java is an object oriented programming language.
Q: A pedometer treats walking 2,000 steps as walking 1 mile. Write a steps_to_miles() function that…
A: The Answer is
Q: #include #include using namespace std; int index1(char *T,char *P) { int t=0,p=0,i,j,r;…
A: To remove function, use all statements outside the function and remove the function header. instead…
Q: this is my code and the question need to be continued. #include using namespace std; class…
A: As per the given requirement Implemented the addMember, removeMember and display member functions…
Q: void removeString(char* string, char*& stringNew) { for (int i = 0; string[i] != '\0'; i++) {…
A: Yes , we can rewrite the code without strncat ,if we change the name of program function name then…
Q: public static void methodl (int i, int num) { for (int j System.out.print num = 2; 1; j <= i; j++) {…
A: The given code is written in Java.
Q: public static void main(String[] args) { // create two circle objects Circle circlel - new Circle();…
A: The complete Java code is as follows:
Q: include #include using namespace std; int index1(char *T,char *P) { int t=0,p=0,i,j,r; t =…
A: Please find the answer below :
Q: Write a method that returns the longest common prefix of two strings. For example, the longest…
A: Program description: s1 and s2 are the user input string variables that take 2 string inputs from…
Q: ingVar() i max_length(20) value - new char(max_length+1]; value(0) - '\0': Default constructor $ize…
A: //source code in C++ #include<iostream> #include<memory> #include<string>…
Q: String remove, String revers
A: mport java.util.Scanner; public class Exercise_11_3 { public static String reverseString(String…
Q: Write a method that finds the number of occurrences of a specified character in a string using the…
A: import java.util.Scanner;//to read inputpublic class Main{ //method to find number of occurrences…
Q: public class CustomString { String myString; boolean isSet; public…
A: ANSWER: public class Custom String { String String; boolean isSet; public Custom String() { // TODO…
Q: hen we use the new operator to produce a String, where does it go? a. Stack b. String storage…
A: Introduction: When we use the new operator to generate a String, the Java compiler will construct a…
Q: Modify the code so that it reads a file named city.txt into starray, then do the linear search…
A: Add both the java files into a package. Create a city.txt file there. Here, the files have been…
Q: problem3 replace Write a method that accepts a String as a parameter and returns a String where…
A: In given question, we need to replace the exact word “are” with “are not”. The replaceAll()…
Q: o) implement the ReplaceExClanmationg fuiction. Replac haracter in the string with a character.…
A: string ShortenSpace(string sample_text){ int len = sample_text.length(); int i = 0; string…
Q: Modify catchsignal.c to only allow user to break the program when they use Ctrl-C twice. Modify…
A: Program Approach: 1- I have checked your program line by line, you have used SIGINT. 2- SIGINT,…
Q: the code is given below can you change the code to interface imроrt jаvа.util.Sсаnner; сlаss…
A: imроrt jаvа.util.Sсаnner; сlаss Person { String nаme; int age; рubliс person() { this(" ",…
Q: Find the error in each of the following program segments. If the error can be corrected, explain…
A: e) short *numPtr, result;void *genericPtr = numPtr;result = *genericPtr + 7; Explanation: A void…
Q: (a) Find the errors in the following also explain what causes the error class Student int getid()…
A: In the above code, List of errors generated by code: 1. In class Student, static int…
Q: /** * Returns a new string that is filled with length number of BLANK characters (e.g., initGuess(5,…
A: Solution: 1. Implementation of public static String initGuess(int length, char BLANK): public…
Q: I keep getting these errors when I run the code below
A: #include<string>#include<vector>#include<iostream> using namespace std; class…
Q: Write a switch statement that checks origLetter. If 'a' or 'A', print "Alpha". If 'b' or 'B', print…
A: // Import the required the packageimport java.util.Scanner; public class ConvertToGreek{ public…
Q: 2. TestScores Class Custom Exception Write an exception class named InvalidTestScore. Modify the…
A: Java is a programming language originally developed by James Gosling at Sun Microsystems (which is…
Q: Write the countVowels function which counts the number of vowels using the string class as follows:…
A: Program: Programs perform the actions and the tasks according to the instructions given by the…
Q: Find errors in this code also: internalstatdchkPalindrome(string str) { for(int i = 0, j =…
A: To find the errors in given code.
Q: #include #include #include using namespace std; struct movies_t { string title; int year; } mine,…
A: The given program has a structure named movies_t mine and yours are 2 structure variables of type…
Q: Repeating String Write a method that takes a String and an int and return a String that is the…
A: Programs: Programs are used to provide instructions to the computer system. It is used to solve…
Q: FirstName_LastName_SerialNumber Clas: The First_Last_SerialNumber class is used by the Home Software…
A: 1. Create a class file called SerialNumber.java and save the content as: package…
Q: Write a method that returns a sorted string using thefollowing header:public static String…
A: Program code: import java.util.Scanner; //define a class public class Main { //define main method…
/**
* Adds letterGuessed to the current String updateLetterBoard
* @param usedLetterBoard
* @param letterGuessed
* @param first
* @return updateLetterBoard with letterGuess appended.
*/
public static String updateLetterBoard(String usedLetterBoard, char letterGuessed, boolean first) {
Step by step
Solved in 3 steps with 1 images
- }/*** Adds letterGuessed to the current String updateLetterBoard* @param usedLetterBoard* @param letterGuessed* @param first* @return updateLetterBoard with letterGuess appended. */public static String updateLetterBoard(String usedLetterBoard, char letterGuessed, boolean first) {return "";}Please help me with this task. Thank you! public class CustomString { String myString; boolean isSet; public CustomString() { this.myString = null; this.isSet = false; } /** * Returns a new string version of the current string where the alphabetical characters specified in the given arg, are removed. * * The alphabetical characters to be removed are case insensitive. * All non-alphabetical characters are unaffected. * If the current string is null, empty, or has not been set to a value, this method should return an empty string. * * Example(s): * - For a current string "my lucky numbers are 6, 8, and 19.", calling remove("ra6") would return "my lucky numbes e 6, 8, nd 19." * - For a current string "my lucky numbers are 6, 8, and 19.", calling remove("6,.") would return "my lucky numbers are 6, 8, and 19." * - For a current string "my lucky numbers are 6, 8, and 19.", calling remove("") would return "my…public String cleanNumber(String phoneNumber) { int digit=0; String result = ""; String number= ""; for (int i = 0; i < phoneNumber.length(); i++) { char ch = phoneNumber.charAt(i); if (Character.isDigit(ch)) { number = number + ch; digit++; } } if(digit == 10) System.out.println("("+phoneNumber.substring(1,3)+")"+"-"+phoneNumber.substring(4,6)+phoneNumber.substring(7,10)); else result = "Error"; return result; }} Argument "(444) 999-1234" Actual (44)-) 99- "" Expected "(444) 999-1234" "4449991234" (44)-99234 "" "(444) 999-1234" "444.999.1234" (44)-99.12 "" "(444) 999-1234" What am doing wrong? How can I make the actual look like the expected? What do I have to change?
- The countSubstring function will take two strings as parameters and will return an integer that is the count of how many times the substring (the second parameter) appears in the first string without overlapping with itself. This method will be case insensitive. For example: countSubstring(“catwoman loves cats”, “cat”) would return 2 countSubstring(“aaa nice”, “aa”) would return 1 because “aa” only appears once without overlapping itself. public static int countSubstring(String s, String x) { if (s.length() == 0 || x.length() == 0) return 1; if (s.length() == 1 || x.length() == 1){ if (s.substring(0,1).equals(x.substring(0,1))){ s.replaceFirst((x), " "); return 1 + countSubstring(s.substring(1), x); } else { return 0 + countSubstring(s.substring(1), x); } } return countSubstring(s.substring(0,1), x) + countSubstring(s.substring(1), x); } public class Main { public static void main(String[] args) { System.out.println(Recursion.countSubstring("catwoman loves cats","cat"));…/*** Returns a lowercase version of a user-entered letter* @param kbd* @return lowercase version of user-entered letter*/public static char getNewGuess(Scanner kbd) {String str = kbd.nextLine();str=str.toLowerCase();return str.charAt(0);} this is what i have but it doesn't seem to be correct completely, it says that the return value needs to be the first letter entered at the beginning of a line/*** Returns a new string that is filled with length number of BLANK characters (e.g., initGuess(5, "$") would return the String "$$$$$""* @param length* @param BLANK* @return a new string that is filled with length number of blank characters* */public static String initGuess(int length, char BLANK) {return "string";}
- this is my code and the question need to be continued. #include <iostream>using namespace std; class Course{private: string name; string *studentList; int size, capacity=10;public: Course(){ name = "TBD"; size = 0; studentList = new string[capacity]; }Course(string s){ name = s; size = 0; studentList = new string[capacity]; }void setName(string s){ name = s; }getter/accessor for variable name string getName(){ return name; }}; int main(){ Course a, b("Yankee"); cout << a.getName() << endl; a.setName("Mets"); cout << a.getName() << endl; cout << b.getName() << endl; return 0;} this is the Question:: Continue with Team class: a) Copy the previous program to a new file.b) Implement the addMember, removeMember and…Write a method that returns a sorted string using thefollowing header:public static String sort(String s)For example, sort("acb") returns abc.Write a test program that prompts the user to enter a string and displays the sortedstring.C++ Need help with part 8 This is what i have so far #include <iostream>#include <string> using namespace std; int GetNumOfNonWSCharacters(const string text); int GetNumOfWords(const string text); int FindText(string text, string sample_text); string ReplaceExclamation(string text);string ShortenSpace(string text); char PrintMenu(string sample_text){ char option;cout << "\nMENU"<<endl;cout << "c - Number of non-whitespace characters"<<endl;cout << "w - Number of words"<<endl;cout << "f - Find text"<<endl;cout << "r - Replace all !'s"<<endl;cout << "s - Shorten spaces"<<endl;cout << "q - Quit"<<endl; cout<<endl;cout << "Choose an option:"<<endl;cin >> option; if(option == 'c'){ int nonWSCharacters = GetNumOfNonWSCharacters(sample_text); cout << "Number of non-whitespace characters: "<<nonWSCharacters<<endl; }else if(option == 'w'){ int numOfWords =…
- In the following program skeleton, replace the < insert code here> line with theappropriate code. The resulting program should display the initial list of songs,prompt the user for a string of text to be replaced and then prompt for new text toreplace it. After making the replacement, it should display the updated list of songs.import java.util.Scanner;public class UpdateSongs{public static void main ( String [] args){Scanner stdIn = new Scanner(System.in);String songs =“ 1. Welcome to Your Life – Grouplove\n” +“ 2. Sedona – Houndmouth\n” +“3. Imagine – John Lennon\n” +“4. Bohemian Rhapsody –Queen\n”;String oldText, newText;< insert code here>}}Sample Session:1. Welcome to Your Life – Grouplove”2. Sedona – Houndmouth3. Imagine – John Lennon4. Bohemian Rhapsody –QueenEnter text to replace: LennonEnter new text: Dean1. Welcome to Your Life – Grouplove”2. Sedona – Houndmouth3. Imagine – John Dean4. Bohemian Rhapsody –Queenimport static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Set; import static java.util.stream.Collectors.toSet; /** * In this assignment, you will implement a simple class called CustomString. This class represents a more customizable version * of a String, with additional attributes and methods. * For example, the CustomString class has a “reverse” method which returns a new string version of the current string where the * capitalization is reversed (i.e., lowercase to uppercase and uppercase to lowercase) for the alphabetical characters specified * in the given arg. For CustomString “abc, XYZ; 123.”, calling reverse("bcdxyz@3210.") will return "aBC, xyz; 123.". * * The CustomString class also has a “remove” method which returns a new string version of the current string where the alphabetical * characters specified in the given arg, are removed. For CustomString "my lucky numbers are 6, 8, and 19.", calling remove("ra6") * will return "my…#include <iostream> using namespace std; class Player { private: int id; static int next_id; public: int getID() { return id; } Player() { id = next_id++; } }; int Player::next_id = 1; int main() { Player p1; Player p2; Player p3; cout << p1.getID() << " "; cout << p2.getID() << " "; cout << p3.getID(); return 0; } Execute and provide screenshot of output.