Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this lab Here's the copy-pastable code: /** * CharArrayProject */ public class CharArrayProject { private char[] array; public CharArrayProject( char[] arr

I need help with this lab

image text in transcribed

image text in transcribed

Here's the copy-pastable code:

/** * CharArrayProject */ public class CharArrayProject { private char[] array; public CharArrayProject( char[] arr ) { } /** * This method deletes the element at position pos. * When an element in the array is removed the * subsequent elements in the array shift down */ public void deleteElementAtPosition( int pos ) { } public static void main( String args[] ) { char a[] = { 'n','e','w','p','o','r','t','h','a', 'r','b','o','r','h','i','g','h', 's','c','h','o','o','l' }; CharArrayProject hello = new CharArrayProject( a ); System.out.print( hello ); System.out.println(); hello.deleteElementAtPosition( 20 ); System.out.println(); System.out.print( hello ); System.out.print( " -------------------------" + "-----------------------" ); hello.deleteElementAtPosition( 14 ); System.out.println(); System.out.print( hello ); System.out.print( " -------------------------" + "-----------------------" ); hello.deleteElementAtPosition( 9 ); System.out.println(); System.out.print( hello ); System.out.print( " -------------------------" + "-----------------------" ); hello.deleteElementAtPosition( 5 ); System.out.println(); System.out.print( hello ); } }

2. Complete the class CharArrayProject to produce the output shown. Keep in mind that I have other private helper methods and instance variables that are not shown, and that YOU have to figure out! Chararray Project public class Charhrray Project private char[arraya public CharArray Project(char[] arr> * This method deletes the element at position pos. # When an element in the array is removed the subsequent elements in the array shift down public void deleteElementat Position int pos) public static void main(String args[]) char al = { 'n', 'e','w', 'p','o', 'r', 't', 'h','a', 'r','b', 'o', 'r','h', 'i','g','h', 's', 'c','h','o', 'o', 'l' }; CharArray Project hello = new CharArrayProject ( a ); System.out.print( hello ); System.out.println(); hello.deleteElementAt Position( 20 ); System.out.println(); System.out.print( hello ); System.out.print(" ----------------- hello.deleteElementAt Position ( 14 ); System.out.println(); System.out.print( hello ); System.out.print(" ----------- hello.deleteElementAt Position ( 9 ); System.out.println(); System.out.print( hello ); System.out.print(" - --- + hello.deleteElementat Position ( 5 ); System.out.println(); System.out.print( hello ); newportharborhighschool 01234567890123456789012 The element at position 20 will be deleted. newportharborhighschol 0123456789012345678901 The element at position 14 will be deleted. newportharborhghachol 012345678901234567890 The element at position 9 will be deleted. newporthaborhghschol 01234567890123456789 The element at position 5 will be deleted. newpothaborhghschol 0123456789012345678

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

Students also viewed these Databases questions