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,107 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>CharacterClassStringClass.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.string {color: #6a8759}
.number {color: #6897bb}
.comment {color: #808080}
.whitespace {color: #505050}
.ST1 {color: #ffc66d; font-family: monospace; font-weight: bold; font-style: italic}
.ST2 {color: #9876aa; font-family: monospace; font-weight: bold; font-style: italic}
.ST0 {color: #287bde}
.literal {color: #cc7832}
.ST3 {font-family: monospace; font-weight: bold; font-style: italic}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/Lab10_CalebFontenot/src/lab10_calebfontenot/CharacterClassStringClass.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java</span><span class="comment"> to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> lab10_calebfontenot;
<span class="literal">import</span> java.util.Scanner;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> CharacterClassStringClass {
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">main</span>(String[] args) {
<span class="comment">// Create Scanner</span>
Scanner input = <span class="literal">new</span> Scanner(System.<span class="ST2">in</span>);
<span class="comment">// Declare variables</span>
String userResponse;
<span class="literal">boolean</span> loopToggle = <span class="literal">true</span>;
<span class="literal">int</span> parseCheck;
<span class="comment">// While loop</span>
<span class="literal">while</span> (loopToggle) {
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">Continue looping?</span><span class="string">&quot;</span>);
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">Please enter y/n or yes/no: </span><span class="string">&quot;</span>);
userResponse = input.next();
<span class="literal">if</span> (userResponse.toLowerCase().charAt(<span class="number">0</span>) == <span class="string">&#39;</span><span class="string">y</span><span class="string">&#39;</span>) {
<span class="literal">if</span> (userResponse.length() &gt; <span class="number">1</span>) { <span class="comment">// User has entered a string that starts with y</span>
<span class="comment">// Check if string == yes</span>
<span class="literal">if</span> (userResponse.toLowerCase().equals(<span class="string">&quot;</span><span class="string">yes</span><span class="string">&quot;</span>)) {
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">You typed &#39;</span><span class="string">&quot;</span> + userResponse + <span class="string">&#39;</span><span class="string">\&#39;</span><span class="string">&#39;</span>);
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">ok!</span><span class="string">&quot;</span>);
} <span class="literal">else</span> {
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">Invalid input! You entered &#39;</span><span class="string">&quot;</span> + userResponse + <span class="string">&#39;</span><span class="string">\&#39;</span><span class="string">&#39;</span>);
}
} <span class="literal">else</span> {
<span class="comment">// User has responded with &#39;y&#39;</span>
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">You typed &#39;</span><span class="string">&quot;</span> + userResponse + <span class="string">&#39;</span><span class="string">\&#39;</span><span class="string">&#39;</span>);
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">ok!</span><span class="string">&quot;</span>);
}
} <span class="literal">else</span> <span class="literal">if</span> (userResponse.toLowerCase().charAt(<span class="number">0</span>) == <span class="string">&#39;</span><span class="string">n</span><span class="string">&#39;</span>) {
<span class="literal">if</span> (userResponse.length() &gt; <span class="number">1</span>) { <span class="comment">// User has entered a string that starts with y</span>
<span class="comment">// Check if string == yes</span>
<span class="literal">if</span> (userResponse.toLowerCase().equals(<span class="string">&quot;</span><span class="string">no</span><span class="string">&quot;</span>)) {
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">You typed &#39;</span><span class="string">&quot;</span> + userResponse + <span class="string">&#39;</span><span class="string">\&#39;</span><span class="string">&#39;</span>);
<span class="comment">// Kill the loop.</span>
loopToggle = <span class="literal">false</span>;
} <span class="literal">else</span> {
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">Invalid input! You entered &#39;</span><span class="string">&quot;</span> + userResponse + <span class="string">&#39;</span><span class="string">\&#39;</span><span class="string">&#39;</span>);
}
} <span class="literal">else</span> {
<span class="comment">// User has responded with &#39;n&#39;</span>
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">You typed </span><span class="string">&quot;</span> + userResponse.charAt(<span class="number">0</span>));
<span class="comment">// Kill the loop.</span>
loopToggle = <span class="literal">false</span>;
}
} <span class="literal">else</span> { <span class="comment">// Invalid input handling</span>
<span class="comment">// Attempt to parse string as an integer.</span>
<span class="literal">try</span> {
parseCheck = Integer.<span class="ST3">parseInt</span>(userResponse);
<span class="comment">// If it got past this, the user entered a number.</span>
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">Invalid input! You entered </span><span class="string">&quot;</span> + parseCheck + <span class="string">&quot;</span><span class="string">, which is an integer!</span><span class="string">&quot;</span>);
} <span class="literal">catch</span> (NumberFormatException ex) {
<span class="literal">if</span> (!(userResponse.length() &gt; <span class="number">1</span>)) { <span class="comment">// Condition is true if response is a char.</span>
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">&#39;</span><span class="string">&quot;</span> + userResponse + <span class="string">&quot;</span><span class="string">&#39; is an incorrect character!</span><span class="string">&quot;</span>);
} <span class="literal">else</span> { <span class="comment">// Response is a string.</span>
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">&#39;</span><span class="string">&quot;</span> + userResponse + <span class="string">&quot;</span><span class="string">&#39; is too long!</span><span class="string">&quot;</span>);
}
}
}
}
}
}
</pre></body>
</html>

View File

@@ -0,0 +1,55 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>EscapeSequencesAndUnicode.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.string {color: #6a8759}
.number {color: #6897bb}
.comment {color: #808080}
.whitespace {color: #505050}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/Lab10_CalebFontenot/src/lab10_calebfontenot/EscapeSequencesAndUnicode.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> lab10_calebfontenot;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> EscapeSequencesAndUnicode {
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
System.out.println(<span class="string">&quot;</span><span class="string">I delete the last 3 characterssss</span><span class="literal">\b</span><span class="literal">\b</span><span class="literal">\b</span><span class="string">&quot;</span>);
System.out.println(<span class="string">&quot;</span><span class="literal">\t</span><span class="literal">\t</span><span class="string">I used 2 tabs here</span><span class="string">&quot;</span>);
System.out.println(<span class="string">&quot;</span><span class="string">I printed a </span><span class="literal">\&quot;</span><span class="string"> inside quotes</span><span class="string">&quot;</span>);
<span class="literal">char</span> b = <span class="string">&#39;</span><span class="string">b</span><span class="string">&#39;</span>;
<span class="literal">char</span> bCapital = <span class="number">66</span>;
<span class="literal">char</span> a = <span class="string">&#39;</span><span class="string">\u0061</span><span class="string">&#39;</span>; <span class="comment">//16 * 6 + 1 = 96 in decimal</span>
<span class="literal">char</span> aCapital = <span class="number">0x41</span>;
<span class="literal">char</span> greekAlpha = <span class="string">&#39;</span><span class="string">\u03b1</span><span class="string">&#39;</span>; <span class="comment">// 3 x 256 + 11 x 16 + 1 = ? in decimal</span>
System.out.println(<span class="string">&quot;</span><span class="string">I print in latin and in greek ---&gt; </span><span class="string">&quot;</span>+
+ b + <span class="string">&quot;</span> <span class="string">&quot;</span>
+ bCapital + <span class="string">&quot;</span> <span class="string">&quot;</span>
+ aCapital + <span class="string">&quot;</span> <span class="string">&quot;</span>
+ a + <span class="string">&quot;</span> <span class="string">&quot;</span>
+ greekAlpha );
}
}
</pre></body>
</html>

View File

@@ -0,0 +1,66 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>IndependanceUSA.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.string {color: #6a8759}
.number {color: #6897bb}
.comment {color: #808080}
.whitespace {color: #505050}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/Lab10_CalebFontenot/src/lab10_calebfontenot/IndependanceUSA.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> lab10_calebfontenot;
<span class="literal">import</span> java.util.Scanner;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> IndependanceUSA {
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
<span class="comment">// Setup vars</span>
String month, day, year;
<span class="comment">// Create scanner</span>
Scanner input = <span class="literal">new</span> Scanner(System.in);
<span class="literal">boolean</span> conditionStillTrue = <span class="literal">true</span>;
<span class="comment">// Prompt for input</span>
System.out.println(<span class="string">&quot;</span><span class="string">Please enter the date of Independence. (Month, day, year): </span><span class="string">&quot;</span>);
month = input.next();
day = input.next();
year = input.next();
<span class="literal">if</span> (month.compareToIgnoreCase(<span class="string">&quot;</span><span class="string">july</span><span class="string">&quot;</span>) == <span class="number">0</span>) {
<span class="literal">if</span> (day.compareToIgnoreCase(<span class="string">&quot;</span><span class="string">4th</span><span class="string">&quot;</span>) == <span class="number">0</span> || (day == <span class="string">&quot;</span><span class="string">4</span><span class="string">&quot;</span>)) {
<span class="literal">if</span> (year.compareToIgnoreCase(<span class="string">&quot;</span><span class="string">1776</span><span class="string">&quot;</span>) == <span class="number">0</span>) {
System.out.println(<span class="string">&quot;</span><span class="string">Hurrah!</span><span class="string">&quot;</span>);
} <span class="literal">else</span> {
System.out.println(<span class="string">&quot;</span><span class="string">No, no, no! Incorrect!</span><span class="string">&quot;</span>);
}
} <span class="literal">else</span> {
System.out.println(<span class="string">&quot;</span><span class="string">No, no, no! Incorrect!</span><span class="string">&quot;</span>);
}
} <span class="literal">else</span> {
System.out.println(<span class="string">&quot;</span><span class="string">No, no, no! Incorrect!</span><span class="string">&quot;</span>);
}
}
}
</pre></body>
</html>

View File

@@ -0,0 +1,52 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>PasswordMaker1.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.string {color: #6a8759}
.number {color: #6897bb}
.comment {color: #808080}
.whitespace {color: #505050}
.ST1 {color: #ffc66d; font-family: monospace; font-weight: bold; font-style: italic}
.ST2 {color: #9876aa; font-family: monospace; font-weight: bold; font-style: italic}
.ST0 {color: #287bde}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/Lab10_CalebFontenot/src/lab10_calebfontenot/PasswordMaker1.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java</span><span class="comment"> to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> lab10_calebfontenot;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> PasswordMaker1 {
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">main</span>(String[] args) {
String firstName = <span class="string">&quot;</span><span class="string">Caleb</span><span class="string">&quot;</span>;
String middleName = <span class="string">&quot;</span><span class="string">Christopher</span><span class="string">&quot;</span>;
String lastName = <span class="string">&quot;</span><span class="string">Fontenot</span><span class="string">&quot;</span>;
<span class="literal">int</span> age = <span class="number">20</span>;
<span class="comment">//&gt; extract initials</span>
String initials = firstName.substring(<span class="number">0</span>,<span class="number">1</span>) +
middleName.substring(<span class="number">0</span>,<span class="number">1</span>) +
lastName.substring(<span class="number">0</span>,<span class="number">1</span>);
<span class="comment">//&gt; append age after changing the initials to lower case</span>
String password = initials.toLowerCase() + age;
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">Your Password = </span><span class="string">&quot;</span> + password);
}
}
</pre></body>
</html>

View File

@@ -0,0 +1,74 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>PasswordMaker2.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.string {color: #6a8759}
.number {color: #6897bb}
.comment {color: #808080}
.whitespace {color: #505050}
.ST1 {color: #ffc66d; font-family: monospace; font-weight: bold; font-style: italic}
.ST2 {color: #9876aa; font-family: monospace; font-weight: bold; font-style: italic}
.ST0 {color: #287bde}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/Lab10_CalebFontenot/src/lab10_calebfontenot/PasswordMaker2.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java</span><span class="comment"> to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> lab10_calebfontenot;
<span class="literal">import</span> java.util.Scanner;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> PasswordMaker2 {
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">main</span>(String[] args) {
<span class="comment">// Create Scanner</span>
Scanner input = <span class="literal">new</span> Scanner(System.<span class="ST2">in</span>);
String firstName; <span class="literal">int</span> lenFirstName;
<span class="comment">//String middleName; int lenMiddleName;</span>
String lastName; <span class="literal">int</span> lenLastName;
String birthYear, birthYearTruncated;
<span class="comment">// Prompt for input</span>
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">Enter first name, last name, and your year of birth and I will generate a password for you:</span><span class="string">&quot;</span>);
firstName = input.next();
<span class="comment">//middleName = input.next();</span>
lastName = input.next();
birthYear = input.next();
<span class="comment">// Count number of chars in inputs</span>
lenFirstName = firstName.length();
<span class="comment">//lenMiddleName = middleName.length();</span>
lenLastName = lastName.length();
<span class="comment">// Extract last two places from age</span>
birthYearTruncated = birthYear.substring(<span class="number">2</span>,<span class="number">4</span>);
<span class="comment">//&gt; extract chars</span>
String passwordChars = firstName.substring((lenFirstName - <span class="number">2</span>),lenFirstName) +
lastName.substring((lenLastName - <span class="number">2</span>), lenLastName);
<span class="comment">//&gt; append age after changing the initials to lower case</span>
String password = passwordChars.toLowerCase() + birthYearTruncated;
System.<span class="ST2">out</span>.println(<span class="string">&quot;</span><span class="string">Your Password = </span><span class="string">&quot;</span> + password);
<span class="comment">//middleName.substring((lenMiddleName - 2), lenMiddleName) + </span>
}
}
</pre></body>
</html>

View File

@@ -0,0 +1,56 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>ReadWriteCapsOrSmallLetters.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.string {color: #6a8759}
.comment {color: #808080}
.whitespace {color: #505050}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/Lab10_CalebFontenot/src/lab10_calebfontenot/ReadWriteCapsOrSmallLetters.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> lab10_calebfontenot;
<span class="literal">import</span> java.util.Scanner;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> ReadWriteCapsOrSmallLetters {
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
{
<span class="comment">// Declare variables</span>
String line;
<span class="comment">// Setup scanner</span>
Scanner input = <span class="literal">new</span> Scanner(System.in);
<span class="comment">// Prompt for input</span>
System.out.println(<span class="string">&quot;</span><span class="string">Please enter 5 words on one line seperated by whitespace: </span><span class="string">&quot;</span>);
line = input.nextLine();
System.out.println(<span class="string">&quot;</span><span class="string">The line you entered: </span><span class="string">&quot;</span>+ line);
System.out.println(<span class="string">&quot;</span><span class="string">The line you entered in all caps: </span><span class="string">&quot;</span> + line.toUpperCase());
}
}
</pre></body>
</html>

View File

@@ -0,0 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>ReadWriteName1.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.string {color: #6a8759}
.comment {color: #808080}
.whitespace {color: #505050}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/Lab10_CalebFontenot/src/lab10_calebfontenot/ReadWriteName1.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> lab10_calebfontenot;
<span class="literal">import</span> java.util.Scanner;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> ReadWriteName1 {
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
{
Scanner scan = <span class="literal">new</span> Scanner(System.in);
System.out.print(<span class="string">&quot;</span><span class="string">Please enter your first name followed by your last name </span><span class="literal">\n</span><span class="string">being seperated</span><span class="string">&quot;</span> +
<span class="string">&quot;</span><span class="string"> from each other by whitespace or carriage return: </span><span class="string">&quot;</span>);
String firstName = scan.next();
String lastName = scan.next();
System.out.println(<span class="string">&quot;</span><span class="literal">\n</span><span class="string">Hello </span><span class="string">&quot;</span> + firstName + <span class="string">&quot;</span> <span class="string">&quot;</span> + lastName + <span class="string">&quot;</span><span class="string">!</span><span class="string">&quot;</span>);
}
}
</pre></body>
</html>

View File

@@ -0,0 +1,53 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>ReadWriteName2.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.string {color: #6a8759}
.comment {color: #808080}
.whitespace {color: #505050}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/Lab10_CalebFontenot/src/lab10_calebfontenot/ReadWriteName2.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> lab10_calebfontenot;
<span class="literal">import</span> java.util.Scanner;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> ReadWriteName2 {
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
{
<span class="comment">// Create scanner</span>
Scanner input = <span class="literal">new</span> Scanner(System.in);
<span class="comment">// Setup variables</span>
String firstName, lastName;
<span class="comment">// Prompt for input</span>
System.out.println(<span class="string">&quot;</span><span class="string">Please enter your first name, followed by your last name: </span><span class="string">&quot;</span>);
firstName = input.next();
lastName = input.next();
<span class="comment">//Print output</span>
System.out.println(<span class="string">&quot;</span><span class="string">Hello, </span><span class="string">&quot;</span> + firstName + <span class="string">&quot;</span><span class="string">, </span><span class="string">&quot;</span> + lastName + <span class="string">&quot;</span><span class="string">.</span><span class="string">&quot;</span>);
}
}
</pre></body>
</html>

View File

@@ -0,0 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>ReadWriteName3.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.string {color: #6a8759}
.comment {color: #808080}
.whitespace {color: #505050}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/Lab10_CalebFontenot/src/lab10_calebfontenot/ReadWriteName3.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> lab10_calebfontenot;
<span class="literal">import</span> java.util.Scanner;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> ReadWriteName3 {
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
{
Scanner scan = <span class="literal">new</span> Scanner(System.in);
System.out.print(<span class="string">&quot;</span><span class="string">Please enter your first name followed by your last name </span><span class="literal">\n</span><span class="string">being seperated </span><span class="string">&quot;</span>
+ <span class="string">&quot;</span><span class="string">from each other by whitespace: </span><span class="string">&quot;</span>);
String wholeLine = scan.nextLine();
System.out.println(<span class="string">&quot;</span><span class="literal">\n</span><span class="string">Hello </span><span class="string">&quot;</span> + wholeLine + <span class="string">&quot;</span><span class="string">!</span><span class="string">&quot;</span>);
}
}
</pre></body>
</html>

View File

@@ -0,0 +1,56 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Rounding1.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
.string {color: #6a8759}
.number {color: #6897bb}
.comment {color: #808080}
.whitespace {color: #505050}
.literal {color: #cc7832}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/Lab10_CalebFontenot/src/lab10_calebfontenot/Rounding1.java</td></tr></table>
<pre>
<span class="comment">/*</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
<span class="comment"> */</span>
<span class="literal">package</span> lab10_calebfontenot;
<span class="comment">/**</span>
<span class="comment"> *</span>
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
<span class="comment">*/</span>
<span class="literal">public</span> <span class="literal">class</span> Rounding1 {
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
System.out.println(<span class="string">&quot;</span><span class="string">Math.ceil(2.1) returns </span><span class="string">&quot;</span> + Math.ceil(<span class="number">2.1</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.ceil(2.0) returns </span><span class="string">&quot;</span> + Math.ceil(<span class="number">2.0</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.ceil(-2.0) returns </span><span class="string">&quot;</span> + Math.ceil(-<span class="number">2.0</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.ceil(-2.1) returns </span><span class="string">&quot;</span> + Math.ceil(-<span class="number">2.1</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.floor(2.1) returns </span><span class="string">&quot;</span> + Math.floor(<span class="number">2.1</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.floor(2.0) returns </span><span class="string">&quot;</span> + Math.floor(<span class="number">2.0</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.floor(-2.0) returns </span><span class="string">&quot;</span> + Math.floor(-<span class="number">2.0</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.floor(-3.0) returns </span><span class="string">&quot;</span> + Math.floor(-<span class="number">3.0</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.rint(2.1) returns </span><span class="string">&quot;</span> + Math.rint(<span class="number">2.1</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.rint(2.0) returns </span><span class="string">&quot;</span> + Math.rint(<span class="number">2.0</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.rint(-2.0) returns </span><span class="string">&quot;</span> + Math.rint(-<span class="number">2.0</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.rint(-2.1) returns </span><span class="string">&quot;</span> + Math.rint(-<span class="number">2.1</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.rint(2.5) returns </span><span class="string">&quot;</span> + Math.rint(<span class="number">2.5</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.rint(-2.5) returns </span><span class="string">&quot;</span> + Math.rint(-<span class="number">2.5</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.round(-2.6f) returns </span><span class="string">&quot;</span> + Math.round(-<span class="number">2.6f</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.round(2.0) returns </span><span class="string">&quot;</span> + Math.round(<span class="number">2.0</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.round(-2.0) returns </span><span class="string">&quot;</span> + Math.round(-<span class="number">2.0</span>));
System.out.println(<span class="string">&quot;</span><span class="string">Math.round(-2.6) returns </span><span class="string">&quot;</span> + Math.round(-<span class="number">2.6</span>));
}
}
</pre></body>
</html>

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="Lab10_CalebFontenot" default="default" basedir=".">
<description>Builds, tests, and runs the project Lab10_CalebFontenot.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="Lab10_CalebFontenot-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
build.xml.data.CRC32=c95a3eda
build.xml.script.CRC32=36282ef2
build.xml.stylesheet.CRC32=f85dc8f2@1.104.0.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=c95a3eda
nbproject/build-impl.xml.script.CRC32=cbddb481
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.104.0.48

View File

@@ -0,0 +1,95 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.modulepath=\
${run.modulepath}
debug.test.classpath=\
${run.test.classpath}
debug.test.modulepath=\
${run.test.modulepath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/Lab10_CalebFontenot.jar
dist.javadoc.dir=${dist.dir}/javadoc
dist.jlink.dir=${dist.dir}/jlink
dist.jlink.output=${dist.jlink.dir}/Lab10_CalebFontenot
excludes=
includes=**
jar.compress=false
javac.classpath=
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.modulepath=
javac.processormodulepath=
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.modulepath=\
${javac.modulepath}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.html5=false
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
# The jlink additional root modules to resolve
jlink.additionalmodules=
# The jlink additional command line parameters
jlink.additionalparam=
jlink.launcher=true
jlink.launcher.name=Lab10_CalebFontenot
main.class=lab10_calebfontenot.Lab10_CalebFontenot
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.modulepath=\
${javac.modulepath}
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
run.test.modulepath=\
${javac.test.modulepath}
source.encoding=UTF-8
src.dir=src
test.src.dir=test

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>Lab10_CalebFontenot</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>

View File

@@ -0,0 +1,79 @@
/*
* 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 lab10_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class CharacterClassStringClass {
public static void main(String[] args) {
// Create Scanner
Scanner input = new Scanner(System.in);
// Declare variables
String userResponse;
boolean loopToggle = true;
int parseCheck;
// While loop
while (loopToggle) {
System.out.println("Continue looping?");
System.out.println("Please enter y/n or yes/no: ");
userResponse = input.next();
if (userResponse.toLowerCase().charAt(0) == 'y') {
if (userResponse.length() > 1) { // User has entered a string that starts with y
// Check if string == yes
if (userResponse.toLowerCase().equals("yes")) {
System.out.println("You typed '" + userResponse + '\'');
System.out.println("ok!");
} else {
System.out.println("Invalid input! You entered '" + userResponse + '\'');
}
} else {
// User has responded with 'y'
System.out.println("You typed '" + userResponse + '\'');
System.out.println("ok!");
}
} else if (userResponse.toLowerCase().charAt(0) == 'n') {
if (userResponse.length() > 1) { // User has entered a string that starts with y
// Check if string == yes
if (userResponse.toLowerCase().equals("no")) {
System.out.println("You typed '" + userResponse + '\'');
// Kill the loop.
loopToggle = false;
} else {
System.out.println("Invalid input! You entered '" + userResponse + '\'');
}
} else {
// User has responded with 'n'
System.out.println("You typed " + userResponse.charAt(0));
// Kill the loop.
loopToggle = false;
}
} else { // Invalid input handling
// Attempt to parse string as an integer.
try {
parseCheck = Integer.parseInt(userResponse);
// If it got past this, the user entered a number.
System.out.println("Invalid input! You entered " + parseCheck + ", which is an integer!");
} catch (NumberFormatException ex) {
if (!(userResponse.length() > 1)) { // Condition is true if response is a char.
System.out.println("'" + userResponse + "' is an incorrect character!");
} else { // Response is a string.
System.out.println("'" + userResponse + "' is too long!");
}
}
}
}
}
}

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 lab10_calebfontenot;
/**
*
* @author caleb
*/
public class EscapeSequencesAndUnicode {
public static void main(String[] args) {
System.out.println("I delete the last 3 characterssss\b\b\b");
System.out.println("\t\tI used 2 tabs here");
System.out.println("I printed a \" inside quotes");
char b = 'b';
char bCapital = 66;
char a = '\u0061'; //16 * 6 + 1 = 96 in decimal
char aCapital = 0x41;
char greekAlpha = '\u03b1'; // 3 x 256 + 11 x 16 + 1 = ? in decimal
System.out.println("I print in latin and in greek ---> "+
+ b + " "
+ bCapital + " "
+ aCapital + " "
+ a + " "
+ greekAlpha );
}
}

View File

@@ -0,0 +1,42 @@
/*
* 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 lab10_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class IndependanceUSA {
public static void main(String[] args) {
// Setup vars
String month, day, year;
// Create scanner
Scanner input = new Scanner(System.in);
boolean conditionStillTrue = true;
// Prompt for input
System.out.println("Please enter the date of Independence. (Month, day, year): ");
month = input.next();
day = input.next();
year = input.next();
if (month.compareToIgnoreCase("july") == 0) {
if (day.compareToIgnoreCase("4th") == 0 || (day == "4")) {
if (year.compareToIgnoreCase("1776") == 0) {
System.out.println("Hurrah!");
} else {
System.out.println("No, no, no! Incorrect!");
}
} else {
System.out.println("No, no, no! Incorrect!");
}
} else {
System.out.println("No, no, no! Incorrect!");
}
}
}

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 lab10_calebfontenot;
/**
*
* @author caleb
*/
public class PasswordMaker1 {
public static void main(String[] args) {
String firstName = "Caleb";
String middleName = "Christopher";
String lastName = "Fontenot";
int age = 20;
//> extract initials
String initials = firstName.substring(0,1) +
middleName.substring(0,1) +
lastName.substring(0,1);
//> append age after changing the initials to lower case
String password = initials.toLowerCase() + age;
System.out.println("Your Password = " + password);
}
}

View File

@@ -0,0 +1,47 @@
/*
* 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 lab10_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class PasswordMaker2 {
public static void main(String[] args) {
// Create Scanner
Scanner input = new Scanner(System.in);
String firstName; int lenFirstName;
//String middleName; int lenMiddleName;
String lastName; int lenLastName;
String birthYear, birthYearTruncated;
// Prompt for input
System.out.println("Enter first name, last name, and your year of birth and I will generate a password for you:");
firstName = input.next();
//middleName = input.next();
lastName = input.next();
birthYear = input.next();
// Count number of chars in inputs
lenFirstName = firstName.length();
//lenMiddleName = middleName.length();
lenLastName = lastName.length();
// Extract last two places from age
birthYearTruncated = birthYear.substring(2,4);
//> extract chars
String passwordChars = firstName.substring((lenFirstName - 2),lenFirstName) +
lastName.substring((lenLastName - 2), lenLastName);
//> append age after changing the initials to lower case
String password = passwordChars.toLowerCase() + birthYearTruncated;
System.out.println("Your Password = " + password);
//middleName.substring((lenMiddleName - 2), lenMiddleName) +
}
}

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 lab10_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class ReadWriteCapsOrSmallLetters {
public static void main(String[] args)
{
// Declare variables
String line;
// Setup scanner
Scanner input = new Scanner(System.in);
// Prompt for input
System.out.println("Please enter 5 words on one line seperated by whitespace: ");
line = input.nextLine();
System.out.println("The line you entered: "+ line);
System.out.println("The line you entered in all caps: " + line.toUpperCase());
}
}

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 lab10_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class ReadWriteName1 {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.print("Please enter your first name followed by your last name \nbeing seperated" +
" from each other by whitespace or carriage return: ");
String firstName = scan.next();
String lastName = scan.next();
System.out.println("\nHello " + firstName + " " + lastName + "!");
}
}

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 lab10_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class ReadWriteName2 {
public static void main(String[] args)
{
// Create scanner
Scanner input = new Scanner(System.in);
// Setup variables
String firstName, lastName;
// Prompt for input
System.out.println("Please enter your first name, followed by your last name: ");
firstName = input.next();
lastName = input.next();
//Print output
System.out.println("Hello, " + firstName + ", " + lastName + ".");
}
}

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 lab10_calebfontenot;
import java.util.Scanner;
/**
*
* @author caleb
*/
public class ReadWriteName3 {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.print("Please enter your first name followed by your last name \nbeing seperated "
+ "from each other by whitespace: ");
String wholeLine = scan.nextLine();
System.out.println("\nHello " + wholeLine + "!");
}
}

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 lab10_calebfontenot;
/**
*
* @author caleb
*/
public class Rounding1 {
public static void main(String[] args) {
System.out.println("Math.ceil(2.1) returns " + Math.ceil(2.1));
System.out.println("Math.ceil(2.0) returns " + Math.ceil(2.0));
System.out.println("Math.ceil(-2.0) returns " + Math.ceil(-2.0));
System.out.println("Math.ceil(-2.1) returns " + Math.ceil(-2.1));
System.out.println("Math.floor(2.1) returns " + Math.floor(2.1));
System.out.println("Math.floor(2.0) returns " + Math.floor(2.0));
System.out.println("Math.floor(-2.0) returns " + Math.floor(-2.0));
System.out.println("Math.floor(-3.0) returns " + Math.floor(-3.0));
System.out.println("Math.rint(2.1) returns " + Math.rint(2.1));
System.out.println("Math.rint(2.0) returns " + Math.rint(2.0));
System.out.println("Math.rint(-2.0) returns " + Math.rint(-2.0));
System.out.println("Math.rint(-2.1) returns " + Math.rint(-2.1));
System.out.println("Math.rint(2.5) returns " + Math.rint(2.5));
System.out.println("Math.rint(-2.5) returns " + Math.rint(-2.5));
System.out.println("Math.round(-2.6f) returns " + Math.round(-2.6f));
System.out.println("Math.round(2.0) returns " + Math.round(2.0));
System.out.println("Math.round(-2.0) returns " + Math.round(-2.0));
System.out.println("Math.round(-2.6) returns " + Math.round(-2.6));
}
}