CSC248 Assessment1
CSC248 Assessment1
CSC248 Assessment1
Assessment #1
You are required to create a complete JAVA program to sort an array list of an objects with
multiple attributes, and to search a specific element in the list.
The following are the processes of the program that you need to develop.
1. Repeatedly, READ the input from the users into an ArrayList named alTemp until
user terminates with a sentinel.
5. SORT the ArrayList location values by using Bubble Sort algorithm in ASCENDING
order.
import java.util.ArrayList;
import java.util.Scanner;
public class myTemperature {
private String loc; //location
private float temp; //temperature
// Repeatedly, READ the input from the users into an ArrayList named alTemp
// until user terminates with a sentinel.
...
...
// DISPLAY the ArrayList values before sorting.
...
...
// SORT the ArrayList based on temperature in ASCENDING order.
...
...
// DISPLAY the ArrayList values after sorting.
...
...
// SORT the ArrayList based on location in ASCENDING order.
...
...
// DISPLAY the ArrayList values after sorting.
...
...
// Request search key and perform the binary search.
...
...
}
}
CSC248 OCT22
New sorted List : [Alor Setar 31.2, Georgetown 30.2, Ipoh 30.4,
Johor Bahru 29.7, Kangar 30.1, Kota Bharu 29.2, Kuala Lumpur 29.4, Kuala
Terengganu 29.3, Kuantan 29.5, Melaka 29.7, Seremban 29.6]
Search Location : Kota Bharu
Element is found at index: 5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thank You and See You Again!
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: