Reset author name to chosen name

This commit is contained in:
2025-10-19 22:02:41 -05:00
parent 168b35c94a
commit 578c33de70
316 changed files with 17381 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.chloefontenot.lab16_arrays2_chloefontenot;
/**
*
* @author chloe
*/
public class ArrayCopy1 {
public static void main(String[] args)
{
int[] sourceArray = {1, 2, 3, 4, 5};
int[] targetArray = new int[sourceArray.length];
// Print the source array
for (int i = 0; i < sourceArray.length; i++) {
System.out.print(sourceArray[i] + " ");
}
System.out.println();
// Copy the source array to the target array
for (int i = 0; i < sourceArray.length; i++) {
targetArray[i] = sourceArray[i];
}
// Print the target array
for (int i = 0; i < sourceArray.length; i++) {
System.out.print(targetArray[i] + " ");
}
}
}

View File

@@ -0,0 +1,33 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.chloefontenot.lab16_arrays2_chloefontenot;
/**
*
* @author chloe
*/
public class ArrayCopy2 {
public static void main(String[] args)
{
int[] sourceArray = {1, 2, 3, 4, 5};
int[] targetArray = new int[sourceArray.length];
// Print the source array
for (int i = 0; i < sourceArray.length; i++) {
System.out.print(sourceArray[i] + " ");
}
System.out.println();
// Copy the source array to the target array in reversed order
int j = (sourceArray.length - 1);
for (int i = 0; i < sourceArray.length; i++) {
targetArray[i] = sourceArray[j];
j--;
}
// Print the target array
for (int i = 0; i < sourceArray.length; i++) {
System.out.print(targetArray[i] + " ");
}
}
}

View File

@@ -0,0 +1,29 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.chloefontenot.lab16_arrays2_chloefontenot;
/**
*
* @author chloe
*/
public class ArrayCopy3 {
public static void main(String[] args)
{
int[] sourceArray = {1, 2, 3, 4, 5};
int[] targetArray = new int[sourceArray.length];
// Print the source array
for (int i = 0; i < sourceArray.length; i++) {
System.out.print(sourceArray[i] + " ");
}
System.out.println();
// Copy the source array to the target array
System.arraycopy(sourceArray, 0, targetArray, 0, sourceArray.length);
// Print the target array
for (int i = 0; i < sourceArray.length; i++) {
System.out.print(targetArray[i] + " ");
}
}
}

View File

@@ -0,0 +1,43 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.chloefontenot.lab16_arrays2_chloefontenot;
import java.util.Arrays;
/**
*
* @author chloe
*/
public class ArrayCopy4 {
public static void main(String[] args)
{
int[] array = {1, 2, 3, 4, 5};
int[] array1 = Arrays.copyOfRange(array, 2, 5);
int[] array2 = new int[array.length - 2];
int[] array3 = new int[array.length];
System.out.println("array1: (copy with java.util.Arrays.copyOfRange(); )");
for (int i: array1) {
System.out.print(i + " ");
}
System.out.println();
// Copy array into array2 with a for loop and print it
System.out.println("array2: (copy with System.arraycopy(); )");
System.arraycopy(array, 2, array2, 0, 3);
for (int i : array2) {
System.out.print(i + " ");
}
System.out.println();
// Copy array manually
System.out.println("array3: (manually copy with for loop)");
for (int i : array3) {
array[i] = array3[i];
}
for (int i : array1) {
System.out.print(i + " ");
}
System.out.println();
}
}

View File

@@ -0,0 +1,31 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.chloefontenot.lab16_arrays2_chloefontenot;
/**
*
* @author chloe
*/
public class ArrayShift1 {
public static void main(String[] args)
{
int[] ar = {1, 2, 3, 4, 5};
int temp = ar[0];
for (int value : ar) {
System.out.print(value + " ");
}
System.out.println();
for (int i = 1; i < ar.length; ++i) {
ar[i - 1] = ar[i];
}
ar[ar.length - 1] = temp;
for (int value : ar) {
System.out.print(value + " ");
}
}
}

View File

@@ -0,0 +1,32 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.chloefontenot.lab16_arrays2_chloefontenot;
/**
*
* @author chloe
*/
public class ArrayShift2 {
public static void main(String[] args)
{
int[] ar = {1, 2, 3, 4, 5};
int temp = ar[ar.length - 1];
for (int value : ar) {
System.out.print(value + " ");
}
System.out.println();
for (int i = (ar.length -1); i > 0 ; --i) {
ar[i] = ar[i -1];
}
ar[0] = temp;
for (int value : ar) {
System.out.print(value + " ");
}
}
}

View File

@@ -0,0 +1,81 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.chloefontenot.lab16_arrays2_chloefontenot;
/**
*
* @author chloe
*/
public class ArraysAndMethods {
public static void printArray(int[] arrayInput)
{
for (int i : arrayInput) {
System.out.print(i + " ");
}
System.out.println();
}
public static void printArray(char[] arrayInput)
{
for (int i : arrayInput) {
System.out.print((char) i + " ");
}
System.out.println();
}
public static void printArray(double[] arrayInput)
{
for (double i : arrayInput) {
System.out.print(i + " ");
}
System.out.println();
}
public static int[] reverse(int[] arrayToReverse)
{
int arrayResult[] = new int[arrayToReverse.length];
int j = (arrayToReverse.length - 1);
for (int i = 0; i <= arrayToReverse.length - 1; i++) {
arrayResult[i] = arrayToReverse[j];
j--;
}
return arrayResult;
}
public static int linearSearch(int list[], int key)
{
int indexFound = -1;
for (int i = 0; i < list.length; ++i) {
if (list[i] == key) {
indexFound = i;
}
}
return indexFound;
}
public static void main(String[] args)
{
int[] array = {1, 2, 3, 4, 5};
printArray(array);
printArray(new int[]{3, 1, 2, 6, 4});
printArray(reverse(array));
System.out.println(linearSearch(array, 5) != 1
? "found at index " + Integer.toString(linearSearch(array, 5))
: "not found at index " + Integer.toString(linearSearch(array, 5))
);
double[] doubles = {6.0, 4.4, 1.9, 2.9, 3.4, 3.5};
// Use the built-in sort method to sort the double.
java.util.Arrays.sort(doubles);
char[] chars = {'a', 'A', '4', 'F', 'D', 'P',};
//Sort again
java.util.Arrays.sort(chars);
// Now print the sorted arrays.
printArray(doubles);
printArray(chars);
}
}

View File

@@ -0,0 +1,62 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.chloefontenot.lab16_arrays2_chloefontenot;
import java.util.Scanner;
/**
*
* @author chloe
*/
public class ArraysAndMethodsGames {
public static double min(double[] array) {
// pull the first number from the array, and compare that with the numbers in the rest of the array. If that number is less than the number in than the first number, set it to our lowest.
double lowest = array[0];
for (int i = 1; i < (array.length -1); i++) {
lowest = Math.min(lowest, array[i]);
}
return lowest;
}
public static double[] readArray() {
// Create a double array.
int doublesRemaining = 10;
double[] returnArray = new double[doublesRemaining];
// Create Scanner
Scanner input = new Scanner(System.in);
// Read characters input and write them to an array.
int i = 0;
do {
System.out.print("Enter 10 doubles (" + doublesRemaining + " left ): ");
returnArray[i] = input.nextDouble();
i++;
doublesRemaining--;
} while (doublesRemaining != 0);
return returnArray;
}
/**
*
* @param array
* @return Returns an average of an array.
*/
public static double average(double[] array) {
// Iterate through array and add values together into double, then divide by the amount of items in the array.
double returnDouble = 0.0;
for (double i: array) {
returnDouble += i;
}
returnDouble /= (double) array.length;
return returnDouble;
}
public static void main(String[] args)
{
double[] doubleArray = new double[10];
doubleArray = readArray();
System.out.println("average function returns: " + average(doubleArray));
System.out.println("lowest function returns: " + min(doubleArray));
}
}

View File

@@ -0,0 +1,17 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
*/
package com.chloefontenot.lab16_arrays2_chloefontenot;
/**
*
* @author chloe
*/
public class Lab16_arrays2_ChloeFontenot {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}