Source code:-
--------------------
package com.challenges;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.Scanner;
class MovieRecord
{
String Title;
int Year;
String Studio;
public MovieRecord(String Title, int Year, String Studio)
{
this.Title=Title;
this.Year=Year;
this.Studio=Studio;
}
public String toString()
{
return "Record [Title=" + Title + ", Year=" + Year + ", Studio="+
Studio + "]";
}
public void print(MovieRecord movies, LinkedList<MovieRecord>
recordArray)
{
System.out.println("Title\tYear\tStudio");
for(MovieRecord record:recordArray)
{
System.out.println(record.Title+"\t"+record.Year+"\t"+record.Studio);
}
}
}
class SortbyTitle implements Comparator<MovieRecord>
{
public int compare(MovieRecord a, MovieRecord b)
{
return a.Title.compareTo(b.Title);
}
}
class SortbyStudio implements Comparator<MovieRecord>
{
public int compare(MovieRecord a, MovieRecord b)
{
return a.Studio.compareTo(b.Studio);
}
}
class SortbyYear implements Comparator<MovieRecord> {
public int compare(MovieRecord a, MovieRecord b)
{
return a.Year;
}
}
public class TestMovie
{
public static void main(String[] args) throws IOException
{
Scanner sc=new Scanner(System.in);
LinkedList<MovieRecord> recordArray = new
LinkedList<MovieRecord>();
System.out.println("*****************************");
System.out.println("All Records in File is");
File Moviesdata = new File
("F:\\Workspace_Luna\\Challenging_Tasks\\Moviedata.txt");
Scanner scanner = new Scanner (Moviesdata);
MovieRecord movies = null;
while(scanner.hasNextLine())
{
String Title = scanner.next();
int Year = scanner.nextInt();
String Studio=scanner.next();
movies=new MovieRecord(Title,Year,Studio);
recordArray.add(movies);
System.out.println(movies);
}
scanner.close();
while(true)
{
System.out.println("*** MENU *****");
System.out.println("1.Print the Records");
System.out.println("2.Sort by Title");
System.out.println("3.Sort by Year");
System.out.println("4.Sort by Studio");
System.out.println("5.Quit");
System.out.println("Please Select any Option");
int option=sc.nextInt();
switch(option)
{
case 1:
movies.print(movies,recordArray);
break;
case 2:
Collections.sort(recordArray, new SortbyTitle());
break;
case 3:
Collections.sort(recordArray, new SortbyYear());
break;
case 4:
Collections.sort(recordArray, new SortbyStudio());
break;
case 5:
System.out.println("End");
break;
default:
System.out.println("Invalid Option");
}
}
}
}
Java code com/extra/ThirdPartyProviders/FLVS/32959 AP CompSciv9_CA/module17/rtfmod17/17.03 Assig Assessment Instructions Instructions: For this assessment, you are going to...
Create a new class called DemoSortingPerformacne Create a private method called getRandomNumberArray. It returns an array of Integer and has 2 parameters: arraySize of type int and numberOfDigits of type int. This method should create an array of the specified size that is filled with random numbers. Each random numbers should have the same number of digits as specified in the second parameter In your main method (or additional private methods) do the following: Execute selection sort on quick sort...
Programming in java
In this part of this Lab exercise, you will need to create a new class named ArrayShiftMult. This class carries out simple manipulation of an array. Then you should add a main method to this class to check that your code does what it is supposed to do. 1. Create a BlueJ project named LAB06 as follows: a. Open the P drive and create a folder named Blue), if it does not exist already. Under this folder,...
Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What This Assignment Is About? Classes (methods and attributes) • Objects Arrays of Primitive Values Arrays of Objects Recursion for and if Statements Selection Sort Use the following Guidelines: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use upper case for constants. • Use title case (first letter is upper case) for classes. Use lower case with uppercase...
Design a program that allows you to experiment with different sort algorithms in Java. This program should allow you to easily plug-in new sort algorithms and compare them. Assume that input data is generated randomly and stored in a text file (have no less than 2000 items to sort). Do not restrict your program to only one data type, or to one ordering relationship. The data type, ordering relationship, and the sorting method must be input parameters for your program....
Objective: in Java Write a program that implements 3 sorting algorithms and times them in real time. These algorithms will sort Cylinders by their volume. First, download the driver and include it in your project. Write a class Cylinder with the following properties baseRadius: a non-negative number that corresponds to the Cylinder’s base’s radius. height: a non-negative number that corresponds to the Cylinder’s height. Next, write a class Sorter with the following bubbleSort: This static method takes in an array...
Write a C++ program that simulates playing the Powerball game. The program will generate random numbers to simulate the lottery terminal generated numbers for white balls and red Powerball. The user will have the option to self-pick the numbers for the balls or let the computer randomly generate them. Set the Grand Prize to $1,000,000,000.00 in the program. Project Specifications Input for this project: Game mode choice – self pick or auto pick Five numbers between 1 and 69 for...
//bubble sort implementation// Fig 6.15 with simplified
convention for the for loop.
#define _CRT_SECURE_NO_WARNINGS //for windows os only
#include <stdio.h>
#include <stdlib.h>
// Fig. 6.15: fig06_15.c
// Sorting an array's values into ascending order.
#include <stdio.h>
#define SIZE 10
// function main begins program execution
int main(void)
{
// initialize a
int a[SIZE] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37
};
printf("Data items in original order");
// output original array
for (int i = 0;...
Using Java
In this assignment we are working with arrays. You have to ask the user to enter the size of the integer array to be declared and then initialize this array randomly. Then use a menu to select from the following Modify the elements of the array. At any point in the program, if you select this option you are modifying the elements of the array randomly. Print the items in the array, one to a line with their...
Need help with program. I'm stuck
Objectives: In this assignment, we will
practice manipulating lists of data and arranging items in an
ascending/descending order. you will also explore storing
lists/arrays using different sorting algorithms including, the
selection sort, bubble sort, and insertion sort algorithm.
Comparison between the three algorithms are made based on the
number of comparisons and item assignments (basic operations) each
algorithms executes.
Background: Ordering the elements of a list is
a problem that occurs in many computer...
Your running times will probably be different than these. Please
do a better job with the snipping tool than I did.
Java program provided:
// Student Name Today's Date
import java.util.Arrays;
import java.util.Random;
public class SortTimer {
// Please expand method main() to meet the lab
requirements.
// You have the following sorting methods
available:
// insertionSort(int[] a);
// selectionSort(int[] a);
// mergeSort(int[] a);
// quickSort(int[] a);
// The array will be in sorted order after the
routines are called!
...