Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
public class Magic8{ | |
// Magic 8 Ball usually has a 20 sided dice inside with 10 positive dice sides, 5 negative dice sides and 5 vague responses | |
// Below defines positive/negative/vague responses | |
ArrayList<String> positiveResponses = new ArrayList<String> (Arrays.asList("As I see it yes", "It is certain", "It is decidedly so", "Most likely", "Outlook good", "Signs point to yes", "Without a doubt", "You may rely on it", "Yes definitely", "Absolutely")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Program is designed to check if a DNA Sequence is a protein, it does this by checking if it contains ATG, contains TGA at some point after ATG and the characters inbetween are divisible by 3 | |
public class DNA{ | |
public boolean isProtein(String dna){ | |
// The begins and ends variables find the index value of where ATG starts and the index value of where TGA starts + 3 so we get the value of where it ends | |
int begins = dna.indexOf("ATG"); | |
int ends = (dna.indexOf("TGA")) + 3; | |
// The string newDna now will hold the new string starting with ATG and ending with TGA cutting out anything before or after in the original string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
class PrimeDirective { | |
/* This checks if the number is prime by first checking if the number is 0 or less than 0, which makes it not prime. | |
It then checks if the number is divisible by every number from 3 to itself -1, if it is divisible it sets the return as false as it cannot be a prime number, it it is not the value remains as true */ | |
public boolean isPrime(int num){ | |
boolean value = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FizzBuzz{ | |
public static void main(String[] args){ | |
for (int i=1; i <= 100; i++){ | |
if (i%3==0 && i%5==0){ | |
System.out.println("FizzBuzz"); | |
} else if (i%3==0){ | |
System.out.println("Fizz"); | |
} else if (i%5==0){ | |
System.out.println("Buzz"); | |
} else{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TransitCalculator{ | |
//Defining the variables | |
int numOfDays = 3; | |
int numOfRides = 34; | |
// Defining the lists | |
public static | |
double[] priceList = {2.75, 33.00, 127.00}; | |
String[] fareOptions = {"Pay-per-ride", "7-day Unlimited Rides", "30-day Unlimited Rides"}; |