This file contains hidden or 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
//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(); |
This file contains hidden or 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
//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); |
This file contains hidden or 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
//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(); |
This file contains hidden or 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
// 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); |
This file contains hidden or 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
//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(); |
This file contains hidden or 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
/*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) { | |
This file contains hidden or 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
/*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); |
This file contains hidden or 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
/* 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) | |
{ |
This file contains hidden or 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
/*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 |
This file contains hidden or 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
/*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 |