
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
![import java.util.LinkedList;
import java.util.Scanner;
import java.util.Arrays;
import java.io. File;
import java.io.FileNotFoundException;
public class Ch6Lab{
public static void main(String[] args) throws FileNotFoundException{
LinkedList<Integer> numbers = new LinkedList<Integer>();
Scanner fileIn = new Scanner (new File("input.txt"));
while (fileIn.hasNextInt()){
int x = fileIn.nextInt();
numbers.add(x);
}
public static void sort(Linkedlist<Integer> 1){
; //TODO: Write a sort method that sorts the linked list
}
public static Integer min(LinkedList<Integer> 1){
return e; //TODO0: Write a method that returns the minimum value from the linked 1ist
}
public static Integer max(LinkedList<Integer> 1){
return 0; //TODO: Write a method that returns the maximum value from the linked list
public static double mean (LinkedList<Integer> 1){
return 0.0; //TODO: Write a method that returns the mean of the values from the linked list
}
public static double median(LinkedList<Integer> 1){
return 0.0;](https://content.bartleby.com/qna-images/question/a50218e1-9020-47a4-b189-6a79dd77425b/e74814e4-29b1-4a63-b55e-4ab1462e1005/46m9ljd_thumbnail.png)
Transcribed Image Text:import java.util.LinkedList;
import java.util.Scanner;
import java.util.Arrays;
import java.io. File;
import java.io.FileNotFoundException;
public class Ch6Lab{
public static void main(String[] args) throws FileNotFoundException{
LinkedList<Integer> numbers = new LinkedList<Integer>();
Scanner fileIn = new Scanner (new File("input.txt"));
while (fileIn.hasNextInt()){
int x = fileIn.nextInt();
numbers.add(x);
}
public static void sort(Linkedlist<Integer> 1){
; //TODO: Write a sort method that sorts the linked list
}
public static Integer min(LinkedList<Integer> 1){
return e; //TODO0: Write a method that returns the minimum value from the linked 1ist
}
public static Integer max(LinkedList<Integer> 1){
return 0; //TODO: Write a method that returns the maximum value from the linked list
public static double mean (LinkedList<Integer> 1){
return 0.0; //TODO: Write a method that returns the mean of the values from the linked list
}
public static double median(LinkedList<Integer> 1){
return 0.0;
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 4 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Java Program ASAP Please modify Map<String, String> morseCodeMap = readMorseCodeTable("morse.txt"); in the program so it reads the two text files and passes the test cases. Down below is a working code. Also dont add any import libraries in the program just modify the rest of the code so it passes the test cases. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.HashMap;import java.util.Map;import java.util.Scanner;public class MorseCodeConverter { public static void main(String[] args) { Map<String, String> morseCodeMap = readMorseCodeTable("morse.txt"); Scanner scanner = new Scanner(System.in); System.out.print("Please enter the file name or type QUIT to exit:\n"); do { String fileName = scanner.nextLine().trim(); if (fileName.equalsIgnoreCase("QUIT")) { break; } try { String text =…arrow_forwardUSING THE FOLLOWING METHOD SWAP CODE: import java.util.*; class ListIndexOutOfBoundsException extends IndexOutOfBoundsException { public ListIndexOutOfBoundsException(String s) { super(s); } } class ListUtil { public static int maxValue(List<Integer> aList) { if(aList == null || aList.size() == 0) { throw new IllegalArgumentException("List cannot be null or empty"); } int max = aList.get(0); for(int i = 1; i < aList.size(); i++) { if(aList.get(i) > max) { max = aList.get(i); } } return max; } public static void swap(List<Integer> aList, int i, int j) throws ListIndexOutOfBoundsException { if(aList == null) { throw new IllegalArgumentException("List cannot be null"); } if(i < 0 || i >= aList.size() || j < 0 || j >= aList.size()) { throw new ListIndexOutOfBoundsException("Index out…arrow_forwardFix the Java code below, make sure it can make the same outputs as the sample: import java.util.ArrayList;import java.util.Scanner; class Main{ //Returns index of name if found otherwise -1 public static int findName(ArrayList<String> arr, String name) { for(int i = 0; i < arr.size(); i++) if(arr.get(i).equals(name)) return i; return -1;//Name not found } //Deletes a name from ArrayList public static void deleteName(ArrayList<String> arr, String name) { int index = findName(arr, name);//Get index of name to be deleted for(int i = index; i < arr.size() - 1; i++){ arr.set(i, arr.get(i + 1)); } arr.remove(arr.size() - 1);//Remove last element } public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter number of students(upto 10): "); int n = scan.nextInt(); ArrayList<String> arr = new…arrow_forward
- A student record system uses an ArrayList object called studrecs tomaintain a collection of student details where each student is anobject defined by the Student class. The student class has accessormethods getName() and getRegNo()Write a for-each loop that iterates through the studrecs collectionwriting out each student’s name and registration number.arrow_forwardHow do I match the output? Code: import java.io.File; import java.util.ArrayList; import java.util.Scanner; public class Assignment08 { public static void main(String[] args) throws Exception { File inputData = new File("input05.txt"); Scanner input = new Scanner(inputData); int totalNumber = input.nextInt(); Friend.friends = new Friend[totalNumber]; input.nextLine(); for (int i = 0; i < totalNumber; i++) { String name = input.nextLine(); String phone = input.nextLine(); String age = input.nextLine(); int ageNum = Integer.parseInt(age); Friend.friends[i] = new Friend(name, phone, ageNum); } printContacts(Friend.friends); Friend.showTotalFriendAge(); ManageDuplicate(Friend.friends); printContacts(Friend.friends); Friend.showTotalFriendAge(); } public static void printContacts(Friend[] contacts) {…arrow_forwardJAVA PROGRAM MODIFY THIS PROGRAM SO IT READS THE TEXT FILES IN HYPERGRADE. I HAVE PROVIDED THE INPUTS AND THE FAILED TEST CASE AS A SCREENSHOT. HERE IS THE WORKING CODE TO MODIFY: import java.io.*;import java.util.*;public class NameSearcher { private static List<String> loadFileToList(String filename) throws FileNotFoundException { List<String> namesList = new ArrayList<>(); File file = new File(filename); if (!file.exists()) { throw new FileNotFoundException(filename); } try (Scanner scanner = new Scanner(file)) { while (scanner.hasNextLine()) { String line = scanner.nextLine().trim(); String[] names = line.split("\\s+"); for (String name : names) { namesList.add(name.toLowerCase()); } } } return namesList; } private static Integer searchNameInList(String name, List<String> namesList) {…arrow_forward
- import javax.swing.*; import java.util.ArrayList; import java.util.Collections; import java.util.Random; import java.awt.*; import java.awt.event.*; public class memory extends JFrame implements ActionListener { private JButton[] cards; private ImageIcon[] icons; private int[] iconIDs; private JButton firstButton; private ImageIcon firstIcon; private int numMatches; public memory() { setTitle("Memory Matching Game"); setSize(800, 600); setLayout(new BorderLayout()); JPanel boardPanel = new JPanel(new GridLayout(4, 4)); add(boardPanel, BorderLayout.CENTER); icons = new ImageIcon[8]; for (int i = 1; i <= 8; i++) { icons[i-1] = new ImageIcon("image" + i + ".png"); } iconIDs = new int[16]; for (int i = 0; i < 8; i++) { iconIDs[2*i] = i; iconIDs[2*i+1] = i; } Random rand = new Random(); for (int i = 0; i < 16;…arrow_forwardGiven main() and an IntNode class, complete the IntList class (a linked list of IntNodes) by writing the insertInDescendingOrder() method to insert new IntNodes into the IntList in descending order. Ex. If the input is: 3 4 2 5 1 6 7 9 8 -1 the output is: 9 8 7 6 5 4 3 2 1 import java.util.Scanner; public class SortedList { public static void main (String[] args) {Scanner scnr = new Scanner(System.in);IntList intList = new IntList();IntNode curNode;int num; num = scnr.nextInt(); while (num != -1) {// Insert into linked list in descending order curNode = new IntNode(num);intList.insertInDescendingOrder(curNode);num = scnr.nextInt();}intList.printIntList();}}arrow_forwardPlease fill in all the code gaps if possible: (java) public class LinkedList { privateLinkedListNode head; **Creates a new instance of LinkedList** public LinkedList () { } public LinkedListNode getHead() public void setHead (LinkedListNode head) **Add item at the front of the linked list** public void insertFront (Object item) **Remove item at the front of linked list and return the object variable** public Object removeFront() }arrow_forward
- import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int n = scnr.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = scnr.nextInt(); } for (int i = n - 1; i >= 0; i--) { System.out.print(arr[i]); if (i > 0) { System.out.print(","); } } }}arrow_forwardGiven main() and an IntNode class, complete the IntList class (a linked list of IntNodes) by writing the insertInAscendingOrder() method that inserts a new IntNode into the IntList in ascending order. Ex. If the input is: 8 3 6 2 5 9 4 1 7 -1 the output is: 1 2 3 4 5 6 7 8 9 import java.util.Scanner; public class SortedList {public static void main (String[] args) {Scanner scnr = new Scanner(System.in);IntList intList = new IntList();IntNode curNode;int num;num = scnr.nextInt();// Read in until -1while (num != -1) {// Insert into linked listcurNode = new IntNode(num);intList.insertInAscendingOrder(curNode);num = scnr.nextInt();}intList.printIntList();}}arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- 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

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education