Skip to content

Instantly share code, notes, and snippets.

import java.util.*;
public class LogCalculator
{
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter a Log Base: ");
int logBase = s.nextInt();
System.out.print("Enter the Number of Values: ");
int n = s.nextInt();
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.*;
public class TwoDArrayPractice
{
public TwoDArrayPractice(){
/*
int[][] testArr = {
{10, 9, 8, 7},
{6, 5, 4, 3},
{2, 1, -1, 0}
{22, 31, 11, 40}
import java.util.*;
public class BinaryConverter
{
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter a binary number: ");
String binary = s.nextLine();
long base = 1;
long decimal = 0;
import java.util.*;
public class Euler69_TotientMaximum
{
public static void main(String[] args) {
double high = 0;
int nHigh = 0;
for (int n = 2; n <= 10; n++) {
int phi = numOfRelativePrimes(n);
double phiN = (double)(n/phi);
import java.util.*;
public class DecimalToFraction
{
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter a decimal: ");
String dec = s.nextLine();
int spot = dec.indexOf(".");
int num = Integer.parseInt(dec.substring(spot+1));
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.time.*;
import java.time.format.*;
import java.util.*;
import java.util.TimeZone.*;
/**
* My bot responds to time/date based keywords including day, clock, date, and time.
* I included these words because when asking about the time or date, you commonly use the words date or time.
* The words day and clock are also commonly used, such as when asking "What does the clock read?" or "What day is it?"
* Also, when you ask "What time is it in..." the chatbot will respond with the time. However, this only works with cities in with time zone IDs in the TimeZone class.
*
import java.time.*;
import java.time.format.*;
import java.util.*;
import java.util.TimeZone.*;
/**
* My bot responds to time/date based keywords including day, clock, date, and time.
* I included these words because when asking about the time or date, you commonly use the words date or time.
* The words day and clock are also commonly used, such as when asking "What does the clock read?" or "What day is it?"
* Also, when you ask "What time is it in..." the chatbot will respond with the time. However, this only works with cities in with time zone IDs in the TimeZone class.
*
private int findKeyword(String statement, String goal, int startPos){
int spot = -1;
spot = statement.indexOf(goal);
if (spot == -1) {
return spot;
}
int spotEnd = spot + goal.length();
if (statement.length() == spotEnd) {
spot = statement.indexOf(goal);
} else if (statement.length() == spotEnd+1 && statement.substring(spotEnd,spotEnd+1).equals(".")) {