new semester, new repo structure

This commit is contained in:
2023-01-10 11:59:05 -06:00
parent 0a76658f85
commit ba6de6e18e
725 changed files with 1199 additions and 103 deletions

View File

@@ -0,0 +1,24 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class ForNested1 {
public static void main(String[] args)
{
for (int i = 0; i < 3; ++i)
{
System.out.print("(i, j) = ");
for (int j = 0; j < 4; ++j)
{
System.out.print("(" + i + ", " + j + ") ");
}
System.out.println("");
}
}
}

View File

@@ -0,0 +1,21 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package lab12_calebfontenot;
/**
*
* @author caleb
*/
public class Lab12_CalebFontenot {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
// TODO code application logic here
}
}

View File

@@ -0,0 +1,30 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class NestedForPatternA {
public static void main(String[] args)
{
/*
String line = "";
//First for loop
for (int i = 1; i <= 6; ++i)
{
line = line + " " + i;
System.out.println(line);
}
*/
for (int i = 1; i < 7; i++) {
for (int j = 1; j < i + 1; j++) {
System.out.print(j + " ");
}
System.out.println();
}
}
}

View File

@@ -0,0 +1,30 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class NestedForPatternB {
public static void main(String[] args)
{
/*
String line = "";
//First for loop
for (int i = 1; i <= 6; ++i)
{
line = line + " " + i;
System.out.println(line);
}
*/
for (int i = 6; i > 0; i--) {
for (int j = 1; j < i + 1; j++) {
System.out.print(j + " ");
}
System.out.println();
}
}
}

View File

@@ -0,0 +1,37 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class NestedForPyramid {
public static void main(String[] args) {
int startRight = 0, //Init decending numbers
endSpace = 7; //Init number of whitespaces to pad
// PRIMARY FOR LOOP
for (int row = 1; row <= 128; row += row) {
// Whitespace Moment
for (int startSpace = 0; startSpace < endSpace; startSpace++) {
System.out.print(" ");
}
// Display ascending numbers
for (int l = 1; l <= row; l += l) {
System.out.printf("%4d", (l));
}
// Display decending numbers
for (int r = startRight; r > 0; r /= 2) {
System.out.printf("%4d", (r));
}
System.out.println();
endSpace--;
startRight = row;
}
}
}

View File

@@ -0,0 +1,37 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class NestedWhilePatternC {
public static void main(String[] args) {
// Define variables
int numberOfLines = 6;
int rows = 1;
int spacing;
int collums;
//Main while looping
while (rows <= numberOfLines) {
spacing = numberOfLines - rows;
while (spacing >= 1) { //Spacing
System.out.print(" ");
spacing--;
}
collums = rows;
while (collums >= 1) { //Number printing
System.out.print(collums + " ");
collums--;
}
System.out.println();
rows++;
}
}
}

View File

@@ -0,0 +1,37 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class NestedWhilePatternD {
public static void main(String[] args) {
// Define variables
int numberOfLines = 6;
int rows = 1;
int spacing;
int collums;
//Main while looping
while (rows <= numberOfLines) {
spacing = numberOfLines - rows;
while (spacing < 6) { //Spacing
System.out.print(" ");
spacing++;
}
collums = rows;
while (collums <= 6) { // Number printing
System.out.print((collums - rows + 1) + " ");
collums++;
}
System.out.println();
rows++;
}
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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 lab12_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class Palindrome1 {
public static void main(String[] args) {
// Create a Scanner
Scanner input = new Scanner(System.in);
// Prompt the user to enter a string
System.out.print("Enter a string: ");
String s = input.nextLine();
// The index of the first character in the string
int low = 0;
// The index of the last character in the string
int high = s.length() - 1;
boolean isPalindrome = true;
while (low < high) {
if (s.charAt(low) != s.charAt(high)) {
isPalindrome = false;
break;
}
low++;
high--;
}
if (isPalindrome) {
System.out.println(s + " is a palindrome");
} else {
System.out.println(s + " is not a palindrome");
}
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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 lab12_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class Palindrome2 {
public static void main(String[] args) {
// Create a Scanner
Scanner input = new Scanner(System.in);
// Prompt the user to enter a string
System.out.print("Enter a string: ");
String s = input.nextLine();
// The index of the first character in the string
int low;
// The index of the last character in the string
int high = s.length() - 1;
boolean isPalindrome = true;
for (low = 0; low < high; low++) {
if (s.charAt(low) != s.charAt(high)) {
isPalindrome = false;
break;
}
//low++;
high--;
}
if (isPalindrome) {
System.out.println(s + " is a palindrome");
} else {
System.out.println(s + " is not a palindrome");
}
}
}

View File

@@ -0,0 +1,28 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class TestBreak1 {
public static void main(String[] args) {
int sum = 0,
number = 0;
while (number < 20) {
if (sum >= 100) {
break;
}
number++;
sum += number;
System.out.println("Current sum: " + sum);
}
System.out.println("\nThe number is " + number);
System.out.println("The sum is " + sum);
}
}

View File

@@ -0,0 +1,28 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class TestBreak2 {
public static void main(String[] args) {
int sum = 0,
number; // Define number here intead of inside the for loop so that 'number' doesn't get removed from memory the second the for loop is broken out of.
for (number = 0; number < 20; number++) {
if (sum >= 100) {
break;
}
sum += number;
System.out.println("Current sum: " + sum);
}
System.out.println("\nThe number is " + number);
System.out.println("The sum is " + sum);
}
}

View File

@@ -0,0 +1,26 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class TestContinue1 {
public static void main(String[] args) {
int sum = 0,
number = 0;
while (number < 20) {
number++;
sum += number;
if (number == 10 || number == 11) {
continue;
}
}
System.out.println(number);
System.out.println("The sum is " + sum);
}
}

View File

@@ -0,0 +1,25 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class TestContinue2 {
public static void main(String[] args) {
int sum = 0,
number;
for (number = 0; number < 20; number++) {
sum += number;
if (number == 10 || number == 11) {
continue;
}
}
System.out.println(number);
System.out.println("The sum is " + sum);
}
}

View File

@@ -0,0 +1,24 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class WhileNested2 {
public static void main(String[] args)
{
int i = 0;
while (i < 3)
{
System.out.print("(i, j) = ");
for (int j = 0; j < 4; ++j)
System.out.print("(" + i + ", " + j + ") ");
System.out.println("");
++i;
}
}
}

View File

@@ -0,0 +1,22 @@
/*
* 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 lab12_calebfontenot;
/**
*
* @author caleb
*/
public class WhileNested3 {
public static void main(String[] args)
{
for (int i = 0; i < 3; ++i)
{
System.out.print("(i, j) = ");
for (int j = 0; j < 4; ++j)
System.out.print("(" + i + ", " + j + ") ");
System.out.println("");
}
}
}