Skip to content

Instantly share code, notes, and snippets.

@gitaficionado
gitaficionado / RangeTester.py
Created March 11, 2021 16:36
Prompt the user for a number from 1 to 100. Using a while loop, if they entered an invalid number, tell them the number entered is invalid and then prompt them again for a number from 1 to 100. If they enter a valid number - thank them for their input.
'''
1. Prompt the user for a number from 1 to 100. Using a while loop, if they entered an invalid number, tell them the number entered is invalid and then prompt them again for a number from 1 to 100. If they enter a valid number - thank them for their input.
Prompt the user for a number from 1 to 100
While that number is less than 1 or that number is more than 100
Output that they entered an invalid number
Prompt them again for a number from 1 to 100
Output to the user, thanking them for their input
'''
@gitaficionado
gitaficionado / NumStatsArray.java
Last active March 9, 2021 21:29
Use the following java file to begin your NumStatsArray class.
public class NumStatsArray{
//Create a private array as a double as final
________________________________________
public NumStatsArray(double[] a){
arr = a;
}
/* Iterate through and cancatenate all values except last and follow each with a comma.
@gitaficionado
gitaficionado / StringStatsArray.java
Created March 9, 2021 20:34
Beginning code for StringStatsArray class
import java.util.Scanner;
public class StringStatsArray{
private final String[] arr;
public StringStatsArray(String[] a){
arr = a;
}
@gitaficionado
gitaficionado / NumStatsArray.java
Created March 9, 2021 20:13
Beginning structure of NumStatsArray
public class NumStatsArray{
//Create a private array as a double as final
________________________________________
public NumStatsArray(double[] a){
arr = a;
}
//Iterate through and cancatenate all values except last and follow each with a comma. Creat string with a "{" the beginning and end it with a "}".
@gitaficionado
gitaficionado / VehicleDemo.java
Created February 4, 2021 15:18
Create a class named Vehicle that simulates a car moving along a 40 block stretch of road. Your class will build a vehicle and keep track of its location on the road. Location values may range from -20 to 20. A location value of 0 represents block 0, a location value of 1 represents block 1, a location value of 2 represents block 2, etc. If the …
public class Vehicle
{
//private integer to store the vehicle's location
private int __________;
public ________()
{
location = ___;
}
@gitaficionado
gitaficionado / .java
Last active January 7, 2021 15:25
The String Shortener assignment requires students to write a short program in Java to shorten messages by removing duplicate letters and vowels.
import java.util.Scanner;
class StringShortener {
public static void main(String[] args) {
//Declare scanner
Scanner scan = new Scanner(System.in);
//Get message from user input
System.out.println("Type the message to be shortened");
String msg = scan.nextLine();
@gitaficionado
gitaficionado / gist:cbfad90584f9eb5c091fae699d459316
Created February 2, 2018 23:30
Write two overloaded methods that return the average of an array with the following headers: public static int average(int[] array) public static double average(double[] array) Write a test program that prompts the user to enter ten double values, invokes this method, and displays the average value.
/*
(Average an array) Write two overloaded methods that return the average of an
array with the following headers:
public static int average(int[] array)
public static double average(double[] array)
Write a test program that prompts the user to enter ten double values, invokes this
method, and displays the average value.
*/
@gitaficionado
gitaficionado / Day1.java
Created December 9, 2020 19:22
AOC 2020 day 1 for demo. Thanks to TurkeyDev for the file
package dev.theturkey.aoc2020;
import java.util.List;
public class Day1 extends AOCPuzzle
{
public Day1()
{
super("1");
}
@gitaficionado
gitaficionado / AOCPuzzle.java
Last active December 9, 2020 19:21
Fetches file from res folder. Thanks to TurkeyDev for the code.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public abstract class AOCPuzzle
{
@gitaficionado
gitaficionado / .java
Created December 9, 2020 19:17
Main file for Advent of code. Thanks to TurkeyDev for sharing this
public class AoC2020Core
{
public static void main(String[] args)
{
//new Day1();
//new Day2();
//new Day3();
//new Day4();
//new Day5();