lab12
This commit is contained in:
parent
97ebbb64d4
commit
eeead47ab0
48
Assignments/lab12_CalebFontenot/ForNested1.html
Normal file
48
Assignments/lab12_CalebFontenot/ForNested1.html
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>ForNested1.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/ForNested1.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> lab12_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> ForNested1 {
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||||
|
{
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="number">3</span>; ++i)
|
||||||
|
{
|
||||||
|
System.out.print(<span class="string">"</span><span class="string">(i, j) = </span><span class="string">"</span>);
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < <span class="number">4</span>; ++j)
|
||||||
|
{
|
||||||
|
System.out.print(<span class="string">"</span><span class="string">(</span><span class="string">"</span> + i + <span class="string">"</span><span class="string">, </span><span class="string">"</span> + j + <span class="string">"</span><span class="string">) </span><span class="string">"</span>);
|
||||||
|
}
|
||||||
|
System.out.println(<span class="string">""</span>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
43
Assignments/lab12_CalebFontenot/Lab12_CalebFontenot.html
Normal file
43
Assignments/lab12_CalebFontenot/Lab12_CalebFontenot.html
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Lab12_CalebFontenot.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}
|
||||||
|
.comment {color: #808080}
|
||||||
|
.whitespace {color: #505050}
|
||||||
|
.literal {color: #cc7832}
|
||||||
|
-->
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/lab12_CalebFontenot/src/lab12_calebfontenot/Lab12_CalebFontenot.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/Main.java to edit this template</span>
|
||||||
|
<span class="comment"> */</span>
|
||||||
|
<span class="literal">package</span> lab12_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> Lab12_CalebFontenot {
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> * </span><span class="comment">@param</span> <span class="comment">args</span> <span class="comment">the</span> <span class="comment">command</span> <span class="comment">line</span> <span class="comment">arguments</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||||
|
{
|
||||||
|
<span class="comment">// TODO code application logic here</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
54
Assignments/lab12_CalebFontenot/NestedForPatternA.html
Normal file
54
Assignments/lab12_CalebFontenot/NestedForPatternA.html
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>NestedForPatternA.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/NestedForPatternA.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> lab12_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> NestedForPatternA {
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||||
|
{
|
||||||
|
<span class="comment">/*</span>
|
||||||
|
<span class="comment"> String line = "";</span>
|
||||||
|
<span class="comment"> //First for loop</span>
|
||||||
|
<span class="comment"> for (int i = 1; i <= 6; ++i)</span>
|
||||||
|
<span class="comment"> {</span>
|
||||||
|
<span class="comment"> line = line + " " + i;</span>
|
||||||
|
<span class="comment"> System.out.println(line);</span>
|
||||||
|
<span class="comment"> }</span>
|
||||||
|
<span class="comment"> */</span>
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">1</span>; i < <span class="number">7</span>; i++) {
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">1</span>; j < i + <span class="number">1</span>; j++) {
|
||||||
|
System.out.print(j + <span class="string">"</span> <span class="string">"</span>);
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
54
Assignments/lab12_CalebFontenot/NestedForPatternB.html
Normal file
54
Assignments/lab12_CalebFontenot/NestedForPatternB.html
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>NestedForPatternB.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/NestedForPatternB.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> lab12_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> NestedForPatternB {
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||||
|
{
|
||||||
|
<span class="comment">/*</span>
|
||||||
|
<span class="comment"> String line = "";</span>
|
||||||
|
<span class="comment"> //First for loop</span>
|
||||||
|
<span class="comment"> for (int i = 1; i <= 6; ++i)</span>
|
||||||
|
<span class="comment"> {</span>
|
||||||
|
<span class="comment"> line = line + " " + i;</span>
|
||||||
|
<span class="comment"> System.out.println(line);</span>
|
||||||
|
<span class="comment"> }</span>
|
||||||
|
<span class="comment"> */</span>
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">6</span>; i > <span class="number">0</span>; i--) {
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">1</span>; j < i + <span class="number">1</span>; j++) {
|
||||||
|
System.out.print(j + <span class="string">"</span> <span class="string">"</span>);
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
64
Assignments/lab12_CalebFontenot/NestedForPyramid.html
Normal file
64
Assignments/lab12_CalebFontenot/NestedForPyramid.html
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>NestedForPyramid.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.string {color: #6a8759}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/NestedForPyramid.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> lab12_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> NestedForPyramid {
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">main</span>(String[] args) {
|
||||||
|
<span class="literal">int</span> startRight = <span class="number">0</span>, <span class="comment">//Init decending numbers</span>
|
||||||
|
endSpace = <span class="number">7</span>; <span class="comment">//Init number of whitespaces to pad</span>
|
||||||
|
|
||||||
|
<span class="comment">// PRIMARY FOR LOOP</span>
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> row = <span class="number">1</span>; row <= <span class="number">128</span>; row += row) {
|
||||||
|
<span class="comment">// Whitespace Moment</span>
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> startSpace = <span class="number">0</span>; startSpace < endSpace; startSpace++) {
|
||||||
|
System.<span class="ST2">out</span>.print(<span class="string">"</span> <span class="string">"</span>);
|
||||||
|
}
|
||||||
|
<span class="comment">// Display ascending numbers</span>
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> l = <span class="number">1</span>; l <= row; l += l) {
|
||||||
|
System.<span class="ST2">out</span>.printf(<span class="string">"</span><span class="string">%4d</span><span class="string">"</span>, (l));
|
||||||
|
}
|
||||||
|
<span class="comment">// Display decending numbers</span>
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> r = startRight; r > <span class="number">0</span>; r /= <span class="number">2</span>) {
|
||||||
|
System.<span class="ST2">out</span>.printf(<span class="string">"</span><span class="string">%4d</span><span class="string">"</span>, (r));
|
||||||
|
}
|
||||||
|
|
||||||
|
System.<span class="ST2">out</span>.println();
|
||||||
|
endSpace--;
|
||||||
|
startRight = row;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
64
Assignments/lab12_CalebFontenot/NestedWhilePatternC.html
Normal file
64
Assignments/lab12_CalebFontenot/NestedWhilePatternC.html
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>NestedWhilePatternC.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.string {color: #6a8759}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/NestedWhilePatternC.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> lab12_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> NestedWhilePatternC {
|
||||||
|
|
||||||
|
<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">// Define variables</span>
|
||||||
|
<span class="literal">int</span> numberOfLines = <span class="number">6</span>;
|
||||||
|
<span class="literal">int</span> rows = <span class="number">1</span>;
|
||||||
|
<span class="literal">int</span> spacing;
|
||||||
|
<span class="literal">int</span> collums;
|
||||||
|
|
||||||
|
<span class="comment">//Main while looping</span>
|
||||||
|
<span class="literal">while</span> (rows <= numberOfLines) {
|
||||||
|
spacing = numberOfLines - rows;
|
||||||
|
<span class="literal">while</span> (spacing >= <span class="number">1</span>) { <span class="comment">//Spacing</span>
|
||||||
|
System.<span class="ST2">out</span>.print(<span class="string">"</span> <span class="string">"</span>);
|
||||||
|
spacing--;
|
||||||
|
}
|
||||||
|
collums = rows;
|
||||||
|
<span class="literal">while</span> (collums >= <span class="number">1</span>) { <span class="comment">//Number printing</span>
|
||||||
|
System.<span class="ST2">out</span>.print(collums + <span class="string">"</span> <span class="string">"</span>);
|
||||||
|
collums--;
|
||||||
|
}
|
||||||
|
System.<span class="ST2">out</span>.println();
|
||||||
|
rows++;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
64
Assignments/lab12_CalebFontenot/NestedWhilePatternD.html
Normal file
64
Assignments/lab12_CalebFontenot/NestedWhilePatternD.html
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>NestedWhilePatternD.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.string {color: #6a8759}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/NestedWhilePatternD.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> lab12_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> NestedWhilePatternD {
|
||||||
|
|
||||||
|
<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">// Define variables</span>
|
||||||
|
<span class="literal">int</span> numberOfLines = <span class="number">6</span>;
|
||||||
|
<span class="literal">int</span> rows = <span class="number">1</span>;
|
||||||
|
<span class="literal">int</span> spacing;
|
||||||
|
<span class="literal">int</span> collums;
|
||||||
|
|
||||||
|
<span class="comment">//Main while looping</span>
|
||||||
|
<span class="literal">while</span> (rows <= numberOfLines) {
|
||||||
|
spacing = numberOfLines - rows;
|
||||||
|
<span class="literal">while</span> (spacing < <span class="number">6</span>) { <span class="comment">//Spacing</span>
|
||||||
|
System.<span class="ST2">out</span>.print(<span class="string">"</span> <span class="string">"</span>);
|
||||||
|
spacing++;
|
||||||
|
}
|
||||||
|
collums = rows;
|
||||||
|
<span class="literal">while</span> (collums <= <span class="number">6</span>) { <span class="comment">// Number printing</span>
|
||||||
|
System.<span class="ST2">out</span>.print((collums - rows + <span class="number">1</span>) + <span class="string">"</span> <span class="string">"</span>);
|
||||||
|
collums++;
|
||||||
|
}
|
||||||
|
System.<span class="ST2">out</span>.println();
|
||||||
|
rows++;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
73
Assignments/lab12_CalebFontenot/Palindrome1.html
Normal file
73
Assignments/lab12_CalebFontenot/Palindrome1.html
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Palindrome1.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/lab12_CalebFontenot/src/lab12_calebfontenot/Palindrome1.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> lab12_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> Palindrome1 {
|
||||||
|
|
||||||
|
<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 a Scanner</span>
|
||||||
|
Scanner input = <span class="literal">new</span> Scanner(System.<span class="ST2">in</span>);
|
||||||
|
|
||||||
|
<span class="comment">// Prompt the user to enter a string</span>
|
||||||
|
System.<span class="ST2">out</span>.print(<span class="string">"</span><span class="string">Enter a string: </span><span class="string">"</span>);
|
||||||
|
String s = input.nextLine();
|
||||||
|
|
||||||
|
<span class="comment">// The index of the first character in the string</span>
|
||||||
|
<span class="literal">int</span> low = <span class="number">0</span>;
|
||||||
|
|
||||||
|
<span class="comment">// The index of the last character in the string</span>
|
||||||
|
<span class="literal">int</span> high = s.length() - <span class="number">1</span>;
|
||||||
|
|
||||||
|
<span class="literal">boolean</span> isPalindrome = <span class="literal">true</span>;
|
||||||
|
<span class="literal">while</span> (low < high) {
|
||||||
|
<span class="literal">if</span> (s.charAt(low) != s.charAt(high)) {
|
||||||
|
isPalindrome = <span class="literal">false</span>;
|
||||||
|
<span class="literal">break</span>;
|
||||||
|
}
|
||||||
|
|
||||||
|
low++;
|
||||||
|
high--;
|
||||||
|
}
|
||||||
|
<span class="literal">if</span> (isPalindrome) {
|
||||||
|
System.<span class="ST2">out</span>.println(s + <span class="string">"</span><span class="string"> is a palindrome</span><span class="string">"</span>);
|
||||||
|
} <span class="literal">else</span> {
|
||||||
|
System.<span class="ST2">out</span>.println(s + <span class="string">"</span><span class="string"> is not a palindrome</span><span class="string">"</span>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
73
Assignments/lab12_CalebFontenot/Palindrome2.html
Normal file
73
Assignments/lab12_CalebFontenot/Palindrome2.html
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Palindrome2.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/lab12_CalebFontenot/src/lab12_calebfontenot/Palindrome2.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> lab12_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> Palindrome2 {
|
||||||
|
|
||||||
|
<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 a Scanner</span>
|
||||||
|
Scanner input = <span class="literal">new</span> Scanner(System.<span class="ST2">in</span>);
|
||||||
|
|
||||||
|
<span class="comment">// Prompt the user to enter a string</span>
|
||||||
|
System.<span class="ST2">out</span>.print(<span class="string">"</span><span class="string">Enter a string: </span><span class="string">"</span>);
|
||||||
|
String s = input.nextLine();
|
||||||
|
|
||||||
|
<span class="comment">// The index of the first character in the string</span>
|
||||||
|
<span class="literal">int</span> low;
|
||||||
|
|
||||||
|
<span class="comment">// The index of the last character in the string</span>
|
||||||
|
<span class="literal">int</span> high = s.length() - <span class="number">1</span>;
|
||||||
|
|
||||||
|
<span class="literal">boolean</span> isPalindrome = <span class="literal">true</span>;
|
||||||
|
<span class="literal">for</span> (low = <span class="number">0</span>; low < high; low++) {
|
||||||
|
<span class="literal">if</span> (s.charAt(low) != s.charAt(high)) {
|
||||||
|
isPalindrome = <span class="literal">false</span>;
|
||||||
|
<span class="literal">break</span>;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="comment">//low++;</span>
|
||||||
|
high--;
|
||||||
|
}
|
||||||
|
<span class="literal">if</span> (isPalindrome) {
|
||||||
|
System.<span class="ST2">out</span>.println(s + <span class="string">"</span><span class="string"> is a palindrome</span><span class="string">"</span>);
|
||||||
|
} <span class="literal">else</span> {
|
||||||
|
System.<span class="ST2">out</span>.println(s + <span class="string">"</span><span class="string"> is not a palindrome</span><span class="string">"</span>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
55
Assignments/lab12_CalebFontenot/TestBreak1.html
Normal file
55
Assignments/lab12_CalebFontenot/TestBreak1.html
Normal 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>TestBreak1.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.string {color: #6a8759}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/TestBreak1.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> lab12_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> TestBreak1 {
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">main</span>(String[] args) {
|
||||||
|
<span class="literal">int</span> sum = <span class="number">0</span>,
|
||||||
|
number = <span class="number">0</span>;
|
||||||
|
|
||||||
|
<span class="literal">while</span> (number < <span class="number">20</span>) {
|
||||||
|
<span class="literal">if</span> (sum >= <span class="number">100</span>) {
|
||||||
|
<span class="literal">break</span>;
|
||||||
|
}
|
||||||
|
number++;
|
||||||
|
sum += number;
|
||||||
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">Current sum: </span><span class="string">"</span> + sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="string">The number is </span><span class="string">"</span> + number);
|
||||||
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">The sum is </span><span class="string">"</span> + sum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
55
Assignments/lab12_CalebFontenot/TestBreak2.html
Normal file
55
Assignments/lab12_CalebFontenot/TestBreak2.html
Normal 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>TestBreak2.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.string {color: #6a8759}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/TestBreak2.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> lab12_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> TestBreak2 {
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">main</span>(String[] args) {
|
||||||
|
<span class="literal">int</span> sum = <span class="number">0</span>,
|
||||||
|
number; <span class="comment">// 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.</span>
|
||||||
|
|
||||||
|
<span class="literal">for</span> (number = <span class="number">0</span>; number < <span class="number">20</span>; number++) {
|
||||||
|
<span class="literal">if</span> (sum >= <span class="number">100</span>) {
|
||||||
|
<span class="literal">break</span>;
|
||||||
|
}
|
||||||
|
|
||||||
|
sum += number;
|
||||||
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">Current sum: </span><span class="string">"</span> + sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="string">The number is </span><span class="string">"</span> + number);
|
||||||
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">The sum is </span><span class="string">"</span> + sum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
53
Assignments/lab12_CalebFontenot/TestContinue1.html
Normal file
53
Assignments/lab12_CalebFontenot/TestContinue1.html
Normal 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>TestContinue1.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.string {color: #6a8759}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/TestContinue1.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> lab12_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> TestContinue1 {
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">main</span>(String[] args) {
|
||||||
|
<span class="literal">int</span> sum = <span class="number">0</span>,
|
||||||
|
number = <span class="number">0</span>;
|
||||||
|
|
||||||
|
<span class="literal">while</span> (number < <span class="number">20</span>) {
|
||||||
|
number++;
|
||||||
|
sum += number;
|
||||||
|
<span class="literal">if</span> (number == <span class="number">10</span> || number == <span class="number">11</span>) {
|
||||||
|
<span class="literal">continue</span>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.<span class="ST2">out</span>.println(number);
|
||||||
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">The sum is </span><span class="string">"</span> + sum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
52
Assignments/lab12_CalebFontenot/TestContinue2.html
Normal file
52
Assignments/lab12_CalebFontenot/TestContinue2.html
Normal 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>TestContinue2.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.string {color: #6a8759}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/TestContinue2.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> lab12_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> TestContinue2 {
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">main</span>(String[] args) {
|
||||||
|
<span class="literal">int</span> sum = <span class="number">0</span>,
|
||||||
|
number;
|
||||||
|
|
||||||
|
<span class="literal">for</span> (number = <span class="number">0</span>; number < <span class="number">20</span>; number++) {
|
||||||
|
sum += number;
|
||||||
|
<span class="literal">if</span> (number == <span class="number">10</span> || number == <span class="number">11</span>) {
|
||||||
|
<span class="literal">continue</span>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.<span class="ST2">out</span>.println(number);
|
||||||
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">The sum is </span><span class="string">"</span> + sum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
48
Assignments/lab12_CalebFontenot/WhileNested2.html
Normal file
48
Assignments/lab12_CalebFontenot/WhileNested2.html
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>WhileNested2.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/WhileNested2.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> lab12_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> WhileNested2 {
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||||
|
{
|
||||||
|
<span class="literal">int</span> i = <span class="number">0</span>;
|
||||||
|
<span class="literal">while</span> (i < <span class="number">3</span>)
|
||||||
|
{
|
||||||
|
System.out.print(<span class="string">"</span><span class="string">(i, j) = </span><span class="string">"</span>);
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < <span class="number">4</span>; ++j)
|
||||||
|
System.out.print(<span class="string">"</span><span class="string">(</span><span class="string">"</span> + i + <span class="string">"</span><span class="string">, </span><span class="string">"</span> + j + <span class="string">"</span><span class="string">) </span><span class="string">"</span>);
|
||||||
|
System.out.println(<span class="string">""</span>);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
46
Assignments/lab12_CalebFontenot/WhileNested3.html
Normal file
46
Assignments/lab12_CalebFontenot/WhileNested3.html
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>WhileNested3.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}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.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/lab12_CalebFontenot/src/lab12_calebfontenot/WhileNested3.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> lab12_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> WhileNested3 {
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||||
|
{
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="number">3</span>; ++i)
|
||||||
|
{
|
||||||
|
System.out.print(<span class="string">"</span><span class="string">(i, j) = </span><span class="string">"</span>);
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < <span class="number">4</span>; ++j)
|
||||||
|
System.out.print(<span class="string">"</span><span class="string">(</span><span class="string">"</span> + i + <span class="string">"</span><span class="string">, </span><span class="string">"</span> + j + <span class="string">"</span><span class="string">) </span><span class="string">"</span>);
|
||||||
|
System.out.println(<span class="string">""</span>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -10,19 +10,28 @@ package lab12_calebfontenot;
|
|||||||
*/
|
*/
|
||||||
public class NestedWhilePatternC {
|
public class NestedWhilePatternC {
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args) {
|
||||||
{
|
// Define variables
|
||||||
int int1 = 1, int2, int3;
|
int numberOfLines = 6;
|
||||||
while (int1 <= 6) {
|
int rows = 1;
|
||||||
System.out.print(int1 + ": ");
|
int spacing;
|
||||||
System.out.print("6 5 4 3 2 1");
|
int collums;
|
||||||
int2 = 1;
|
|
||||||
while (int2 != int1) {
|
//Main while looping
|
||||||
System.out.print("\b\b");
|
while (rows <= numberOfLines) {
|
||||||
int2++;
|
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();
|
System.out.println();
|
||||||
int1++;
|
rows++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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++;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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 com.mycompany.mavenproject1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author caleb
|
||||||
|
*/
|
||||||
|
public class Exercise_05_18_C {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// Display pattern C
|
||||||
|
int numberOfLines = 6;
|
||||||
|
System.out.println("Pattern C");
|
||||||
|
for (int rows = 1; rows <= numberOfLines; rows++) {
|
||||||
|
for (int s = numberOfLines - rows; s >= 1; s--) {
|
||||||
|
System.out.print(" ");
|
||||||
|
}
|
||||||
|
for (int col = rows; col >= 1; col--) {
|
||||||
|
System.out.print(col + " ");
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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.mycompany.mavenproject1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author caleb
|
||||||
|
*/
|
||||||
|
public class Exercise_05_19 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int startRight = 0, // Initialize decending numbers
|
||||||
|
endSpace = 7; // Initialize number of white space in row
|
||||||
|
// Display number of rows and numbers in each row
|
||||||
|
for (int row = 1; row <= 128; row += row) {
|
||||||
|
// Display white space
|
||||||
|
for (int startSpace = 0; startSpace < endSpace; startSpace++) {
|
||||||
|
System.out.print(" ");
|
||||||
|
}
|
||||||
|
// Display acending 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(); // End line
|
||||||
|
endSpace--; // Decrement endSpace
|
||||||
|
startRight = row; // Assign row to startRight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
BIN
ZIPs/lab12_CalebFontenot.zip
Normal file
BIN
ZIPs/lab12_CalebFontenot.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user