Concept explainers
(Implement the StringBuilder class) The StringBuilder class is provided in the Java library. Provide your own implementation for the following methods (name the new class MyStringBuilder1):
public MyStringBuilder1(String s);
public MyStringBuilder1 append(MyStringBuilder1 s);
public MyStringBuilder1 append(int i);
public int length( );
public char charAt(int index);
public MyStringBuilder1 toLowerCase();
public MyStringBuilder1 substring(int begin, int end);
public String toString();
Trending nowThis is a popular solution!
Chapter 10 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Problem Solving with C++ (9th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Java How To Program (Early Objects)
Starting Out with Java: Early Objects (6th Edition)
Starting Out With Visual Basic (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
- Please answer the question in the screenshot. The language used is Java. Please provide the code to the question with an explanation. Please use the below code as a starting point. import java.util.*; public class CoursePlanner {// this method prints out: whether it is possible to take all the given courses and// one possible schedule for the given coursespublic static void plan(int numberOfCourses, int[][] prerequisites) {return;} // this is a helper method for plan; it returns a boolean to indicate if a given series of courses can be possibly scheduledpublic static boolean check(int numberOfCourses, int[][] prerequisites) {// remove these two linesif (RightSolution.check(numberOfCourses, prerequisites)) return false;else return true;}}arrow_forwardMethod Overloading is a feature that allows a class to have two or more methods having same name, if their argument lists are different. Argument lists could differ in: 1. Number of parameters. 2. Data type of parameters. 3. Sequence of Data type of parameters. Write different version of method sum() that display the sum of the values received as parameter according to the following main method content: public static void main(String[] args) { sum ( 10, 10 ); sum ( 10, 10, 10 ); sum ( 10.0, 10.0 ); sum ( 10, 10.0 ); sum ( 10.0, 10); } You have to define five functions with the specified types. Then, demonstrate the Argument Promotion concept by reducing the number of method to two.arrow_forwardPlease fix errors for the java code below. The program is a t square fractal (image below) import javax.swing.*;import java.awt.*;import java.awt.geom.*; //main classpublic class SquareFractal { public static void main(String[] args) { FractalFrame tframe = new FractalFrame(); tframe.setTitle("T Square Fractal"); tframe.setVisible(true); }} //JFrame extended in fractal class class T_Fractal extends JFrame{ private JPanel panel; private int twidth, theight; private int x = 200; private int limit = 15; public T_Fractal() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //default height and width final int Width = 1000; final int Height = 1000; setSize(Width, Height); setLocation(200,50); panel = new JPanel(); Container t_content = getContentPane(); t_content.add(panel, "Center"); } public void paint(Graphics graphics) { super.paint(graphics); Graphics2D g2 = (Graphics2D) graphics; twidth = getWidth(); theight = getHeight();…arrow_forward
- Problem 2: Complete the seperateDuplicateChars () method in Seperate Duplicates.java as follows: The method takes a String str as a parameter and returns a new String. The returned String should be exactly like str, but any identical characters that appear in a consecutive way must be separated by hyphens "-". You may ONLY use the following methods from the String class: charAt(), substring() and length(). Other than uncommenting the code, do not modify the main method in Seperate Duplicates.java. Sample runs provided below. Argument String str "Hello" "Bookkeeper" "Yellowwood door" "Chicago Cubs" Return String "Hel-lo" "Bo-ok-ke-eper" "Yel-low-wo-od do-or" "Chicago Cubs"arrow_forwardPlease include a gui for the encryption and decryption java code. Example of the gui in the photos Java encryption and decryption code below import java.util.*; public class Main { //Inputs a one character string and returns True if the character is a letter (i.e. a to z or A to Z). Returns false if it is not. A function to check that the password or encryption key is valid. public static boolean isALetter(char letter){ if( (letter >= 'a' && letter = 'A' && letter =-32767 && encryptKeyarrow_forwardCode with comments and output screenshot. Thank you!! Write a java method that receives a string containing letters of the English alphabet and then prints the Letters having unique frequencies. Notes: 1) Ignore letter case; Uppercase and lowercase letters are considered the same. 2) Do not use methods from the Arrays class.arrow_forward
- import java.util.Scanner; public class TriangleArea { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Triangle triangle1 = new Triangle(); Triangle triangle2 = new Triangle(); // TODO: Read and set base and height for triangle1 (use setBase() and setHeight()) // TODO: Read and set base and height for triangle2 (use setBase() and setHeight()) System.out.println("Triangle with smaller area:"); // TODO: Determine smaller triangle (use getArea()) // and output smaller triangle's info (use printInfo()) }} public class Triangle { private double base; private double height; public void setBase(double userBase){ base = userBase; } public void setHeight(double userHeight) { height = userHeight; } public double getArea() { double area = 0.5 * base * height; return area; } public void printInfo() { System.out.printf("Base:…arrow_forwardFind the errors in the following program .6 public class WelcomeClass } (public static void main(String[] args ;int student num = 11 ;(System.out.printIn("Welcom to our java class (System.out.println("The number of students in the class is:" student_num { } (سؤال غير مجهول ) * (2 نقطة) .There is a total of 5 errors, you need to find 4 of them You can upload a file to show your answer 1 تحميل ملف أقصى حد مسموح به لعدد الملفات: 1 أقصى حد مسموح به لحجم الملف الواحد: 10MB أنواع الملفات المسموح بها: PDF, صورة إرسالarrow_forwardThe following class definition has errors. Explain what is wrong and why. Rewrite a correct version of the class. class Question2( public static main(String[] args){ int num1 = 10, num2 = 20, num3; (num2 / 2)--; num3 = (num1 + num2)/num3 System.out.printin( num3 );arrow_forward
- Complete the convert() method that casts the parameter from a double to an integer and returns the result.Note that the main() method prints out the returned value of the convert() method. Ex: If the double value is 19.9, then the output is: 19 Ex: If the double value is 3.1, then the output is: 3 code: public class LabProgram { public static int convert(double d){ /* Type your code here */ } public static void main(String[] args) { System.out.println(convert(19.9)); System.out.println(convert(3.1)); }}arrow_forwardWrite the following programs in Java: In the Converter class write the static method, bin2decimal(String bin). The parameter for this method is an unsigned (nonnegative) binary number represented by a string. The method returns the decimal equivalent for the binary parameter, as an integer.If the binary string is invalid (contains characters other than ‘0’ and ‘1’), the method returns -1. Convert from a binary (b) string with up to 16 digits to decimal (d) using the following formula:? = ?0 + ?1 × 2 + ?2 × 22 +⋯+ ?7 × 215where b0, b1, ?2, … ?7 are the binary digits in order of increasing significance. For example, 1101 is: 1 + 0×2 + 1×22 + 1×23 = 13 in decimal. Side note: You may NOT use the decode method of the Long wrapper class instead of this formula. In the Converter class write another static method, english2encrypted(String english). The parameter for this method is a word or sentence represented by a string. The word or sentence should only contain letters (no digits,…arrow_forwardString Builder In this lab, we learn how StringBuilder class works and why it is efficient. Type up the code below, run it and submit ONLY the output. import javax.swing.JOptionPane; public class StringBuilderDemo ( public static void main(String[] args) ( StringBuilder nameString = new StringBuilder ("Barbara"); int nameStringCapacity System.out.println("Capacity nameString.capacity(); nameStringCapacity); of nameString is " + StringBuilder addressString = null; addressString new StringBuilder ("6311 Hickory Nut Grove Road"); int addStringCapacity addressString.capacity(); System.out.println("Capacity of addressString is addStringCapacity); nameString.setLength (20); System.out.println("The name is " + nameString + "end"); addressString.setLength (20); System.out.println("The address is + addressString);arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education