联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2018-11-18 09:08

Lab 12

CSE 110: Principles of Programming

Arizona State University

Topics

● Linear Search.

● Bubble Sort.

Lab 12 - Arrays

1. Please copy the following code into your IDE and ensure it compiles.

public class Lab12

{

public static void main(String[] args)

{


String[] array = {“John”,”Thomas”,”Alex”,”Tyler”,”Elizabeth”};

}

}

2. Make a method to print a String array that accepts the array as a parameter.

3. Create a method which accepts a String array, and a string to search for as parameters,

which returns the index of the first occurrence of the given string as an integer.

4. Create a boolean method which accepts a sorted string array in alphabetical order. The

method either confirms that the array is sorted and returns true or returns false if the array

wasn’t sorted.

5. Create a bubbleSort method which takes an array of Strings and sorts it in place. The

bubble sort algorithm works by comparing each element in the array to the next element

and swapping them if the first is higher than the next one. Remember, String has a

compareTo method which will be helpful here.

6. Please upload your Lab12.java file to the Lab 12 assignment under the Labs tab on

Blackboard. Make sure you talk to your lab TA before you leave to ensure they marked

you as present.


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp