subject

The String class is provided in the Java library. Provide your own implementation for the following methods (name the new class MyString):

**DO NOT USE THE STRING OBJECT AND ITS METHODS. IMPLEMENT THEM ALL AGAIN YOURSELF!

**You can use char[] and Character object.

public MyString(char[] chars);

public char charAt(int index);

public int length();

public MyString substring(int begin, int end);

public MyString toLowerCase();

public boolean equals(MyString s);

public static MyString valueOf(int i);

public char[] toChars();

Use the following class driver with no modifications to it!

import java. util.*;
import java. lang.*;
import java. io.*;

class DriverMain{

public static void main(String[] args) {

MyString s1 = new MyString(new char[] {'A', 'B', 'C'});

System. out. println(s1.length());

System. out. println(s1.charAt(1));

MyString s2 = s1.substring(0,2);

System. out. println(s2.toLowerCase().equals(new MyString(new char[] {'a', 'b'})));

char[] chars = MyString. valueOf(345).toChars();

for (int i = 0; i < chars. length; i++) {

System. out. print(chars[i]);

}

}

}



---And use the following class that was refered to in main

class MyString {

public MyString(char[] chars){

}
public char charAt(int index){

}
public int length(){

}
public MyString substring(int begin, int end){

}
public MyString toLowerCase(){

}
public boolean equals(MyString s){

}
public static MyString valueOf(int i){

}
public char[] toChars(){

}

}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:20
Write a pseudocode solution for each of these problems. 1. design a while loop that lets that user enter a number. the number should be multiplied by 10, and the result stored in a variable named product. the loop should iterate as long as product contains a value less than 100. 2. design a do-while loop that asks the user to enter two numbers. the numbers should be added and the sum displayed. the loop should ask the user whether he or she wishes to perform the operation again. if so, the loop should repeat; otherwise it should terminate. 3. design a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 100. 4. design a nested loop that displays 10 rows of # characters. there should be 15 # characters in each row. 5. convert this for loop to a while loop. declare integer count for count = 1 to 50 display count end for 6. find the error in the following pseudocode. declare boolean finished = false declare integer value, cube while not finished display β€œenter a value to be cubed.” input value; set cube = value ^ 3 display value, β€œ cubed is β€œ, cube end while
Answers: 2
question
Computers and Technology, 23.06.2019 15:30
1. ask the user how many questions are in the quiz. 2. ask the user to enter the key (that is, the correct answers). there should be one answer for each question in the quiz, and each answer should be an integer. e.g., 34 7 13 100 81 3 9 10 321 12 might be the key for a 10-question quiz. you will need to store the key in an array. 3. ask the user to enter the answers for the quiz to be graded. there needs to be one answer for each question. note that these answers do not need to be stored; each answer can simply be compared to the key as it is entered. 4. when the user has entered all of the answers to be graded, print the number correct and the percent correct. 5. add a loop so that the user can grade any number of quizzes with a single key. after the results have been printed for each quiz, ask "grade another quiz? (y/n)." note: you only have one array (the key). you are not creating a new key for each set of quiz answers.
Answers: 3
question
Computers and Technology, 24.06.2019 10:20
Multiple choice project create a program with two multiple choice questions. 1. users have two attempts only, show attempt number each time. hint: while loop with break control. (20%) 2. only one correct answer for each question, use switch case for each question. (20%) 3. show total score after the two questions are answered. hint: . (20%) 4. user have options to answer the two questions again if first attempt score is not 100%. hint: if statment. (20%) 5. use string method .toupper() to allow users to enter with lowercase or uppercase letters. (20%) 1. where is the capital of the state of florida? a. orlando b. tallahassee c. miami d. tampa b 2. where is walt disney world park located in florida? a. orlando b. tallahassee c. miami d. tampa a
Answers: 1
question
Computers and Technology, 24.06.2019 10:30
You're programming an infinite loop. what must you include in your code to prevent crashes? in roblox
Answers: 2
You know the right answer?
The String class is provided in the Java library. Provide your own implementation for the following...
Questions
question
Social Studies, 26.06.2019 03:30
question
History, 26.06.2019 03:30
Questions on the website: 13722361