Skip to content

Instantly share code, notes, and snippets.

//for any given pair of intergers, print a statement that states whether the second is a multiple of the fist
import java.util.Scanner;
public class findMultiples {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Please introduce two numbers, separated by the enter key");
int a = input.nextInt();
int b = input.nextInt();
//ARRAY: Given an array of ints of ODD length,
//look at the first, last,
//and middle values in the array and return the largest. The array length will be a least 1.
import java.util.Scanner;
public class oddArray{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
@JorgeOlvera
JorgeOlvera / months.java
Last active August 29, 2015 13:56
Given a number from 1 to 12, the program returns the corresponding month
//Givenanumberfrom1-12,returnthenameoftheappropriatemonth.
import java.util.Scanner;
public class months {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int onetotwelve = input.nextInt();
// Calculate and return the area of a circle, given the radius.
import java.util.Scanner;
public class circleArea {
public static void main (String[] args){
Scanner input = new Scanner(System.in);
double radius = input.nextDouble();
radius = calculateArea(radius);
@JorgeOlvera
JorgeOlvera / asteriskz
Created February 13, 2014 04:19
Asterisks
//Foranygiven(small)number,printasquareofasteriskswiththelengthof each side equal to the given number.
import java.util.Scanner;
public class asteriskz{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int asteriskNumber = input.nextInt();
/*Returnanarraythatis"leftshifted"byone--so{6,2,5,3}returns{2,5,3, 6}. You may modify and return the given array, or return a new array.
shiftLeft({6, 2, 5, 3}) → {2, 5, 3, 6} shiftLeft({1, 2}) → {2, 1} shiftLeft({1}) → {1}
public int[] shiftLeft(int[] nums)
*/
import java.util.Scanner;
public class holyshift {
public static void main(String [] args) {
/*Write a method public static int max(int[][] a)that
returns the maximum value in the 2d parameter array a.
*/
import java.util.Scanner;
public class maximumArray{
public static int max(int[][] my2d) {
Scanner input = new Scanner(System.in);
/* Returnthesumofthenumbersinthearray,returning0foranempty array.
Except the number 13 is very unlucky, so it does not count and numbers
that come immediately after a 13 also do not count.
sum13({1, 2, 2, 1}) → 6
*/
import java.util.Scanner;
public class internalsum{
public static void main(String [] args)
{
/*Returntrueifthearraycontains,somewhere,threeincreasingadjacent numbers like 4, 5, 6 or 23, 24, 25.
tripleUp({1, 4, 5, 6, 2}) → true tripleUp({1, 2, 3}) → true tripleUp({1, 2, 4}) → false
public boolean tripleUp(int[] nums)*/
import java.util.Scanner;
public class adjacent {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
//Establish array length
/*Returntrueifthearraycontains,somewhere,threeincreasingadjacent numbers like 4, 5, 6 or 23, 24, 25.
tripleUp({1, 4, 5, 6, 2}) → true tripleUp({1, 2, 3}) → true tripleUp({1, 2, 4}) → false
public boolean tripleUp(int[] nums)*/
import java.util.Scanner;
public class uniqueAdjacent {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
//Establish array length