Skip to content

Instantly share code, notes, and snippets.

View rr-codes's full-sized avatar

Richard Robinson rr-codes

View GitHub Profile
@rr-codes
rr-codes / Main.java
Last active August 27, 2018 04:24
EECS 1021 Lab Test 2 Practice
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
final int SAFE_DIST = 5; // declares main variable
Scanner fileName = new Scanner(System.in); // reads filename
System.out.print("Please enter the name of the input file: "); // output
Scanner inFile = new Scanner(new File(fileName.nextLine())); // reads file from filename
@rr-codes
rr-codes / Frequency.java
Created August 25, 2018 04:10
The Frequency program outputs the frequency of each word in input file sorted alphabetically, and outputs the word with greatest frequency
/*
* The Frequency program outputs the frequency of each word in input
* file sorted alphabetically, and outputs the word with greatest frequency
*/
import java.io.*;
import java.util.*;
public class Frequency {
public static void main(String[] args) throws Exception {
// Sample input: 1 5 2 5 3 -1 -> not distinct
// Terminate input with a negative integer and return key
import java.util.*;
public class DuplicateCheck {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean isDistinct = true; int num;
System.out.println("Enter sequence of numbers: ");
import java.io.*;
import java.util.*;
public class SafeOrbits {
public static void main(String[] args) throws Exception {
Scanner fileName = new Scanner(System.in);
System.out.println("Please enter filename: ");
Scanner inputFile = new Scanner(new File(fileName.nextLine()));
fileName.close();
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
float sum = 0;
int i = 0;
Map<Integer, Integer> map = new HashMap<>();
for (int num = 0; num >= 0;) {
import java.util.*;
public class Distance {
public static void main(String[] args) throws Exception {
int sum = 0;
int[][] arr = new int[2][10];
Scanner point = new Scanner(System.in);
System.out.print("Enter point: ");
for (int j = 0; point.hasNextInt(); j++) {
@rr-codes
rr-codes / Main.java
Created August 31, 2018 05:37
Different methods for arbitrary n-dimensional points in Java
package practice.eecs1021;
class Point {
private double[] coord;
Point (double... coord) { this.coord = coord; }
// get value from index
private double getValue(int index) { return coord[index]; }
// get size of array
@rr-codes
rr-codes / AwesomeNess.java
Last active August 31, 2018 06:16
Different methods for arbitrary n-dimensional points in Java
class Point {
public double[] coord;
Point (double... coord) { this.coord = coord; }
public double getValue(int index) { return coord[index]; }
public int getSize() { return coord.length; }
double getDistanceFrom(Point coordNew) {
double sum = 0;
import java.util.Objects;
/**
* A class that represents a circle. The circle is defined by its two-dimensional center point and its radius.
* The class allows circles to be compared using the radius of each circle. The class ensures that all circle objects will always have a radius greater than zero.
*/
public class Circle {
// ATTRIBUTES
#!/bin/bash
# —————————————————————————————————————————————————————————————————— #
# Question 1.1 #
# #
# Called via: script.sh filename1 filename2 ... #
# If number of files < 2, print "Error" and quit #
# Print which of filename1 and filename2 has larger size #
# —————————————————————————————————————————————————————————————————— #