new semester, new repo structure
This commit is contained in:
128
Semester 1/Assignments/MP3_CalebFontenot/Calendar.html
Normal file
128
Semester 1/Assignments/MP3_CalebFontenot/Calendar.html
Normal file
@@ -0,0 +1,128 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Calendar.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/Calendar.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> mp3_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> java.util.Scanner;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> Calendar {
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.in);
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a year: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> year = input.nextInt();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the first day of the year: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> firstDay = input.nextInt();
|
||||
|
||||
<span class="literal">int</span> startDay = firstDay;
|
||||
<span class="literal">int</span> numberOfDaysInMonth = <span class="number">0</span>;
|
||||
<span class="literal">for</span> (<span class="literal">int</span> month = <span class="number">1</span>; month <= <span class="number">12</span>; month++) {
|
||||
System.out.print(<span class="string">"</span> <span class="string">"</span>);
|
||||
<span class="literal">switch</span> (month) {
|
||||
<span class="literal">case</span> <span class="number">1</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">January </span><span class="string">"</span> + year);
|
||||
numberOfDaysInMonth = <span class="number">31</span>;
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">2</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">February </span><span class="string">"</span> + year);
|
||||
<span class="literal">if</span> (year % <span class="number">400</span> == <span class="number">0</span> || (year % <span class="number">4</span> == <span class="number">0</span> && year % <span class="number">100</span> != <span class="number">0</span>)) {
|
||||
numberOfDaysInMonth = <span class="number">29</span>;
|
||||
} <span class="literal">else</span> {
|
||||
numberOfDaysInMonth = <span class="number">28</span>;
|
||||
}
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">3</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">March </span><span class="string">"</span> + year);
|
||||
numberOfDaysInMonth = <span class="number">31</span>;
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">4</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">April </span><span class="string">"</span> + year);
|
||||
numberOfDaysInMonth = <span class="number">30</span>;
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">5</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">May </span><span class="string">"</span> + year);
|
||||
numberOfDaysInMonth = <span class="number">31</span>;
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">6</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">June </span><span class="string">"</span> + year);
|
||||
numberOfDaysInMonth = <span class="number">30</span>;
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">7</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">July </span><span class="string">"</span> + year);
|
||||
numberOfDaysInMonth = <span class="number">31</span>;
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">8</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">August </span><span class="string">"</span> + year);
|
||||
numberOfDaysInMonth = <span class="number">31</span>;
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">9</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">September </span><span class="string">"</span> + year);
|
||||
numberOfDaysInMonth = <span class="number">30</span>;
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">10</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">October </span><span class="string">"</span> + year);
|
||||
numberOfDaysInMonth = <span class="number">31</span>;
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">11</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">November </span><span class="string">"</span> + year);
|
||||
numberOfDaysInMonth = <span class="number">30</span>;
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">12</span>:
|
||||
System.out.println(<span class="string">"</span><span class="string">December </span><span class="string">"</span> + year);
|
||||
numberOfDaysInMonth = <span class="number">31</span>;
|
||||
<span class="literal">break</span>;
|
||||
}
|
||||
System.out.println(<span class="string">"</span><span class="string">------------------------------</span><span class="string">"</span>);
|
||||
System.out.println(<span class="string">"</span><span class="string"> Sun Mon Tue Wed Thu Fri Sat</span><span class="string">"</span>);
|
||||
<span class="literal">int</span> i = <span class="number">0</span>;
|
||||
<span class="literal">for</span> (i = <span class="number">0</span>; i < startDay; i++) {
|
||||
System.out.print(<span class="string">"</span> <span class="string">"</span>);
|
||||
}
|
||||
|
||||
<span class="literal">for</span> (i = <span class="number">1</span>; i <= numberOfDaysInMonth; i++) {
|
||||
<span class="literal">if</span> (i < <span class="number">10</span>) {
|
||||
System.out.print(<span class="string">"</span> <span class="string">"</span> + i);
|
||||
} <span class="literal">else</span> {
|
||||
System.out.print(<span class="string">"</span> <span class="string">"</span> + i);
|
||||
}
|
||||
|
||||
<span class="literal">if</span> ((i + startDay) % <span class="number">7</span> == <span class="number">0</span>) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
startDay = (startDay + numberOfDaysInMonth) % <span class="number">7</span>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
90
Semester 1/Assignments/MP3_CalebFontenot/CalendarWhile.html
Normal file
90
Semester 1/Assignments/MP3_CalebFontenot/CalendarWhile.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>CalendarWhile.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/CalendarWhile.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> mp3_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> java.util.Scanner;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> CalendarWhile {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.in);
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a year: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> year = input.nextInt();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the first day of the year: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> firstDay = input.nextInt();
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
|
||||
<span class="literal">int</span> startDay = firstDay;
|
||||
<span class="literal">int</span> numberOfDaysInMonth = <span class="number">0</span>;
|
||||
<span class="literal">int</span> month = <span class="number">1</span>;
|
||||
<span class="literal">while</span> (month <= <span class="number">12</span>) {
|
||||
System.out.print(<span class="string">"</span> <span class="string">"</span>);
|
||||
<span class="literal">switch</span> (month) {
|
||||
<span class="literal">case</span> <span class="number">1</span>: System.out.println(<span class="string">"</span><span class="string">January </span><span class="string">"</span> + year); numberOfDaysInMonth = <span class="number">31</span>; <span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">2</span>: System.out.println(<span class="string">"</span><span class="string">February </span><span class="string">"</span> + year);
|
||||
<span class="literal">if</span> (year % <span class="number">400</span> == <span class="number">0</span> || (year % <span class="number">4</span> == <span class="number">0</span> && year % <span class="number">100</span> != <span class="number">0</span>)) numberOfDaysInMonth = <span class="number">29</span>;
|
||||
<span class="literal">else</span> numberOfDaysInMonth = <span class="number">28</span>;
|
||||
<span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">3</span>: System.out.println(<span class="string">"</span><span class="string">March </span><span class="string">"</span> + year); numberOfDaysInMonth = <span class="number">31</span>; <span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">4</span>: System.out.println(<span class="string">"</span><span class="string">April </span><span class="string">"</span> + year); numberOfDaysInMonth = <span class="number">30</span>; <span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">5</span>: System.out.println(<span class="string">"</span><span class="string">May </span><span class="string">"</span> + year); numberOfDaysInMonth = <span class="number">31</span>; <span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">6</span>: System.out.println(<span class="string">"</span><span class="string">June </span><span class="string">"</span> + year); numberOfDaysInMonth = <span class="number">30</span>; <span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">7</span>: System.out.println(<span class="string">"</span><span class="string">July </span><span class="string">"</span> + year); numberOfDaysInMonth = <span class="number">31</span>; <span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">8</span>: System.out.println(<span class="string">"</span><span class="string">August </span><span class="string">"</span> + year); numberOfDaysInMonth = <span class="number">31</span>; <span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">9</span>: System.out.println(<span class="string">"</span><span class="string">September </span><span class="string">"</span> + year); numberOfDaysInMonth = <span class="number">30</span>; <span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">10</span>: System.out.println(<span class="string">"</span><span class="string">October </span><span class="string">"</span> + year); numberOfDaysInMonth = <span class="number">31</span>; <span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">11</span>: System.out.println(<span class="string">"</span><span class="string">November </span><span class="string">"</span> + year); numberOfDaysInMonth = <span class="number">30</span>; <span class="literal">break</span>;
|
||||
<span class="literal">case</span> <span class="number">12</span>: System.out.println(<span class="string">"</span><span class="string">December </span><span class="string">"</span> + year); numberOfDaysInMonth = <span class="number">31</span>; <span class="literal">break</span>;
|
||||
}
|
||||
System.out.println(<span class="string">"</span><span class="string">------------------------------</span><span class="string">"</span>);
|
||||
System.out.println(<span class="string">"</span><span class="string"> Sun Mon Tue Wed Thu Fri Sat</span><span class="string">"</span>);
|
||||
<span class="literal">int</span> i = <span class="number">0</span>;
|
||||
<span class="literal">for</span> (i = <span class="number">0</span>; i < startDay; i++) {
|
||||
System.out.print(<span class="string">"</span> <span class="string">"</span>);
|
||||
}
|
||||
<span class="literal">for</span> (i = <span class="number">1</span>; i <= numberOfDaysInMonth; i++) {
|
||||
<span class="literal">if</span> (i < <span class="number">10</span>) System.out.print(<span class="string">"</span> <span class="string">"</span> + i);
|
||||
<span class="literal">else</span> System.out.print(<span class="string">"</span> <span class="string">"</span> + i);
|
||||
|
||||
<span class="literal">if</span> ((i + startDay) % <span class="number">7</span> == <span class="number">0</span>) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
startDay = (startDay + numberOfDaysInMonth) % <span class="number">7</span>;
|
||||
month++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@@ -0,0 +1,60 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>FindHighestScore.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/FindHighestScore.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> mp3_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> java.util.Scanner;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> FindHighestScore {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.in);
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the number of students: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> numOfStudents = input.nextInt();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student name: </span><span class="string">"</span>);
|
||||
String student1 = input.next();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student score: </span><span class="string">"</span>);
|
||||
<span class="literal">double</span> score1 = input.nextDouble();
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < numOfStudents - <span class="number">1</span>; i++) {
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student name: </span><span class="string">"</span>);
|
||||
String student = input.next();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student score: </span><span class="string">"</span>);
|
||||
<span class="literal">double</span> score = input.nextDouble();
|
||||
<span class="literal">if</span> (score > score1) {
|
||||
student1 = student;
|
||||
score1 = score;
|
||||
}
|
||||
}
|
||||
System.out.println(<span class="string">"</span><span class="string">Top student </span><span class="string">"</span> + student1 + <span class="string">"</span><span class="string">'s score is </span><span class="string">"</span> + score1);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@@ -0,0 +1,61 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>FindHighestScoreDoWhile.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/FindHighestScoreDoWhile.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> mp3_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> java.util.Scanner;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> FindHighestScoreDoWhile {
|
||||
<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>;
|
||||
String student1 = <span class="string">""</span>;
|
||||
<span class="literal">double</span> score1 = <span class="number">0</span>;
|
||||
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.in);
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the number of students: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> numOfStudents = input.nextInt();
|
||||
<span class="literal">do</span> {
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student name: </span><span class="string">"</span>);
|
||||
String student = input.next();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student score: </span><span class="string">"</span>);
|
||||
<span class="literal">double</span> score = input.nextDouble();
|
||||
<span class="literal">if</span> (score > score1) {
|
||||
student1 = student;
|
||||
score1 = score;
|
||||
}
|
||||
i++;
|
||||
} <span class="literal">while</span> (i < numOfStudents);
|
||||
System.out.println(<span class="string">"</span><span class="string">Top student </span><span class="string">"</span> + student1 + <span class="string">"</span><span class="string">'s score is </span><span class="string">"</span> + score1);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@@ -0,0 +1,63 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>FindHighestScoreWhile.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/FindHighestScoreWhile.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> mp3_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> java.util.Scanner;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> FindHighestScoreWhile {
|
||||
<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>;
|
||||
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.in);
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the number of students: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> numOfStudents = input.nextInt();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student name: </span><span class="string">"</span>);
|
||||
String student1 = input.next();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student score: </span><span class="string">"</span>);
|
||||
<span class="literal">double</span> score1 = input.nextDouble();
|
||||
<span class="literal">while</span> (i < numOfStudents - <span class="number">1</span>) {
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student name: </span><span class="string">"</span>);
|
||||
String student = input.next();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student score: </span><span class="string">"</span>);
|
||||
<span class="literal">double</span> score = input.nextDouble();
|
||||
<span class="literal">if</span> (score > score1) {
|
||||
student1 = student;
|
||||
score1 = score;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
System.out.println(<span class="string">"</span><span class="string">Top student </span><span class="string">"</span> + student1 + <span class="string">"</span><span class="string">'s score is </span><span class="string">"</span> + score1);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@@ -0,0 +1,71 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>FindTwoHighestScores.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/FindTwoHighestScores.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> mp3_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> java.util.Scanner;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> FindTwoHighestScores {
|
||||
|
||||
<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">// Define variables</span>
|
||||
<span class="literal">double</span> highScore1 = <span class="number">0</span>, highScore2 = <span class="number">0</span>, score;
|
||||
String bestStudent1 = <span class="string">""</span>, bestStudent2 = <span class="string">""</span>, student;
|
||||
<span class="literal">int</span> numberToIterate = <span class="number">0</span>;
|
||||
|
||||
<span class="comment">// Compute</span>
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the number of students: </span><span class="string">"</span>);
|
||||
numberToIterate = input.nextInt();
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i != numberToIterate; i++) {
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student name: </span><span class="string">"</span>);
|
||||
student = input.next();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter </span><span class="string">"</span> + student + <span class="string">"</span><span class="string">'s score: </span><span class="string">"</span>);
|
||||
score = input.nextDouble();
|
||||
|
||||
<span class="literal">if</span> (score > highScore1) { <span class="comment">// New high score detected</span>
|
||||
|
||||
<span class="literal">if</span> (highScore1 != <span class="number">0</span>) {
|
||||
highScore2 = highScore1; <span class="comment">// assign highScore1 to highScore2</span>
|
||||
bestStudent2 = bestStudent1;
|
||||
}
|
||||
highScore1 = score; <span class="comment">// assign current score to high score</span>
|
||||
bestStudent1 = student;
|
||||
}
|
||||
}
|
||||
System.out.println(<span class="string">"</span><span class="string">Best score belongs to </span><span class="string">"</span> + bestStudent1 + <span class="string">"</span><span class="string">, with a score of </span><span class="string">"</span> + highScore1);
|
||||
System.out.println(<span class="string">"</span><span class="string">Next best score belongs to </span><span class="string">"</span> + bestStudent2 + <span class="string">"</span><span class="string">, with a score of </span><span class="string">"</span> + highScore2);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@@ -0,0 +1,73 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>FindTwoHighestScoresDoWhile.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/FindTwoHighestScoresDoWhile.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> mp3_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> java.util.Scanner;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> FindTwoHighestScoresDoWhile {
|
||||
|
||||
<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">// Define variables</span>
|
||||
<span class="literal">double</span> highScore1 = <span class="number">0</span>, highScore2 = <span class="number">0</span>, score;
|
||||
String bestStudent1 = <span class="string">""</span>, bestStudent2 = <span class="string">""</span>, student;
|
||||
<span class="literal">int</span> numberToIterate = <span class="number">0</span>;
|
||||
|
||||
<span class="comment">// Compute</span>
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the number of students: </span><span class="string">"</span>);
|
||||
numberToIterate = input.nextInt();
|
||||
<span class="literal">int</span> i = <span class="number">0</span>;
|
||||
<span class="literal">do</span> {
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student name: </span><span class="string">"</span>);
|
||||
student = input.next();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter </span><span class="string">"</span> + student + <span class="string">"</span><span class="string">'s score: </span><span class="string">"</span>);
|
||||
score = input.nextDouble();
|
||||
|
||||
<span class="literal">if</span> (score > highScore1) { <span class="comment">// New high score detected</span>
|
||||
|
||||
<span class="literal">if</span> (highScore1 != <span class="number">0</span>) {
|
||||
highScore2 = highScore1; <span class="comment">// assign highScore1 to highScore2</span>
|
||||
bestStudent2 = bestStudent1;
|
||||
}
|
||||
highScore1 = score; <span class="comment">// assign current score to high score</span>
|
||||
bestStudent1 = student;
|
||||
}
|
||||
i++;
|
||||
} <span class="literal">while</span> (i != numberToIterate);
|
||||
System.out.println(<span class="string">"</span><span class="string">Best score belongs to </span><span class="string">"</span> + bestStudent1 + <span class="string">"</span><span class="string">, with a score of </span><span class="string">"</span> + highScore1);
|
||||
System.out.println(<span class="string">"</span><span class="string">Next best score belongs to </span><span class="string">"</span> + bestStudent2 + <span class="string">"</span><span class="string">, with a score of </span><span class="string">"</span> + highScore2);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@@ -0,0 +1,73 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>FindTwoHighestScoresWhile.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/FindTwoHighestScoresWhile.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> mp3_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> java.util.Scanner;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> FindTwoHighestScoresWhile {
|
||||
|
||||
<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">// Define variables</span>
|
||||
<span class="literal">double</span> highScore1 = <span class="number">0</span>, highScore2 = <span class="number">0</span>, score;
|
||||
String bestStudent1 = <span class="string">""</span>, bestStudent2 = <span class="string">""</span>, student;
|
||||
<span class="literal">int</span> numberToIterate = <span class="number">0</span>;
|
||||
|
||||
<span class="comment">// Compute</span>
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the number of students: </span><span class="string">"</span>);
|
||||
numberToIterate = input.nextInt();
|
||||
<span class="literal">int</span> i = <span class="number">0</span>;
|
||||
<span class="literal">while</span> (i != numberToIterate) {
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter a student name: </span><span class="string">"</span>);
|
||||
student = input.next();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter </span><span class="string">"</span> + student + <span class="string">"</span><span class="string">'s score: </span><span class="string">"</span>);
|
||||
score = input.nextDouble();
|
||||
|
||||
<span class="literal">if</span> (score > highScore1) { <span class="comment">// New high score detected</span>
|
||||
|
||||
<span class="literal">if</span> (highScore1 != <span class="number">0</span>) {
|
||||
highScore2 = highScore1; <span class="comment">// assign highScore1 to highScore2</span>
|
||||
bestStudent2 = bestStudent1;
|
||||
}
|
||||
highScore1 = score; <span class="comment">// assign current score to high score</span>
|
||||
bestStudent1 = student;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
System.out.println(<span class="string">"</span><span class="string">Best score belongs to </span><span class="string">"</span> + bestStudent1 + <span class="string">"</span><span class="string">, with a score of </span><span class="string">"</span> + highScore1);
|
||||
System.out.println(<span class="string">"</span><span class="string">Next best score belongs to </span><span class="string">"</span> + bestStudent2 + <span class="string">"</span><span class="string">, with a score of </span><span class="string">"</span> + highScore2);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
50
Semester 1/Assignments/MP3_CalebFontenot/GCD.html
Normal file
50
Semester 1/Assignments/MP3_CalebFontenot/GCD.html
Normal file
@@ -0,0 +1,50 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>GCD.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/GCD.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> mp3_calebfontenot;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> GCD {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
|
||||
java.util.Scanner input = <span class="literal">new</span> java.util.Scanner(System.in);
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the first number: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> n1 = input.nextInt();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the second number: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> n2 = input.nextInt();
|
||||
|
||||
<span class="literal">int</span> d = (n1 < n2) ? n1 : n2;
|
||||
<span class="literal">for</span> (; d >= <span class="number">1</span>; d--)
|
||||
<span class="literal">if</span> ((n1 % d == <span class="number">0</span>) && (n2 % d == <span class="number">0</span>))
|
||||
<span class="literal">break</span>;
|
||||
System.out.println(<span class="string">"</span><span class="string">GCD of </span><span class="string">"</span> + n1 + <span class="string">"</span><span class="string"> and </span><span class="string">"</span> + n2 + <span class="string">"</span><span class="string"> is </span><span class="string">"</span> + d);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
54
Semester 1/Assignments/MP3_CalebFontenot/GCDDoWhile.html
Normal file
54
Semester 1/Assignments/MP3_CalebFontenot/GCDDoWhile.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>GCDDoWhile.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/GCDDoWhile.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> mp3_calebfontenot;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> GCDDoWhile {
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
|
||||
java.util.Scanner input = <span class="literal">new</span> java.util.Scanner(System.in);
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the first number: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> n1 = input.nextInt();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the second number: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> n2 = input.nextInt();
|
||||
|
||||
<span class="literal">int</span> d = (n1 < n2) ? n1 : n2;
|
||||
<span class="literal">do</span> {
|
||||
<span class="literal">if</span> ((n1 % d == <span class="number">0</span>) && (n2 % d == <span class="number">0</span>)) {
|
||||
<span class="literal">break</span>;
|
||||
}
|
||||
d--;
|
||||
} <span class="literal">while</span> (d >= <span class="number">1</span>);
|
||||
System.out.println(<span class="string">"</span><span class="string">GCD of </span><span class="string">"</span> + n1 + <span class="string">"</span><span class="string"> and </span><span class="string">"</span> + n2 + <span class="string">"</span><span class="string"> is </span><span class="string">"</span> + d);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
54
Semester 1/Assignments/MP3_CalebFontenot/GCDWhile.html
Normal file
54
Semester 1/Assignments/MP3_CalebFontenot/GCDWhile.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>GCDWhile.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/GCDWhile.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> mp3_calebfontenot;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> GCDWhile {
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
|
||||
java.util.Scanner input = <span class="literal">new</span> java.util.Scanner(System.in);
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the first number: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> n1 = input.nextInt();
|
||||
System.out.print(<span class="string">"</span><span class="string">Enter the second number: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> n2 = input.nextInt();
|
||||
|
||||
<span class="literal">int</span> d = (n1 < n2) ? n1 : n2;
|
||||
<span class="literal">while</span> (d >= <span class="number">1</span>) {
|
||||
<span class="literal">if</span> ((n1 % d == <span class="number">0</span>) && (n2 % d == <span class="number">0</span>)) {
|
||||
<span class="literal">break</span>;
|
||||
}
|
||||
d--;
|
||||
}
|
||||
System.out.println(<span class="string">"</span><span class="string">GCD of </span><span class="string">"</span> + n1 + <span class="string">"</span><span class="string"> and </span><span class="string">"</span> + n2 + <span class="string">"</span><span class="string"> is </span><span class="string">"</span> + d);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
96
Semester 1/Assignments/MP3_CalebFontenot/Stats.html
Normal file
96
Semester 1/Assignments/MP3_CalebFontenot/Stats.html
Normal file
@@ -0,0 +1,96 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Stats.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: Ubuntu}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: Ubuntu}
|
||||
table {color: #888888; background-color: #313335; font-family: Ubuntu}
|
||||
.literal {color: #cc7832}
|
||||
.ST4 {font-family: Ubuntu; font-style: italic}
|
||||
.ST0 {color: #287bde}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST2 {color: #ffc66d; font-family: Ubuntu; font-style: italic}
|
||||
.ST3 {color: #9876aa; font-family: Ubuntu; font-style: italic}
|
||||
.ST1 {color: #808080; font-family: Ubuntu; font-weight: bold}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/MP3_CalebFontenot/src/mp3_calebfontenot/Stats.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> mp3_calebfontenot;
|
||||
|
||||
<span class="literal">import</span> java.util.Scanner;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST1">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> Stats {
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST2">main</span>(String[] args)
|
||||
{
|
||||
<span class="comment">// Create scanner</span>
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.<span class="ST3">in</span>);
|
||||
<span class="comment">// Define variables</span>
|
||||
<span class="literal">double</span> mean = <span class="number">0</span>; <span class="comment">//It's twice as mean</span>
|
||||
<span class="literal">double</span> inputSum = <span class="number">0</span>, numberOfTimesRun = <span class="number">0</span>, inputPow = <span class="number">0</span>, deviation = <span class="number">0</span>;
|
||||
String userInput = <span class="string">""</span>;
|
||||
|
||||
<span class="comment">// Prompt for input</span>
|
||||
<span class="literal">do</span> {
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">Press Y/y to enter a series of numbers or Q/q to quit.</span><span class="string">"</span>);
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">Current sum: </span><span class="string">"</span> + inputSum);
|
||||
userInput = input.next();
|
||||
<span class="literal">if</span> (userInput.toLowerCase().equals(<span class="string">"</span><span class="string">y</span><span class="string">"</span>)) {
|
||||
<span class="literal">try</span> {
|
||||
<span class="literal">do</span> {
|
||||
System.<span class="ST3">out</span>.print(<span class="string">"</span><span class="string">Please enter a series of numbers; Type '-1' to quit (no quotes, you doofus!): </span><span class="string">"</span>);
|
||||
userInput = input.next();
|
||||
<span class="literal">if</span> (Double.<span class="ST4">parseDouble</span>(userInput) != -<span class="number">1</span>) {
|
||||
inputSum += Double.<span class="ST4">parseDouble</span>(userInput);
|
||||
inputPow += Math.<span class="ST4">pow</span>(Double.<span class="ST4">parseDouble</span>(userInput), <span class="number">2</span>);
|
||||
numberOfTimesRun++; <span class="comment">// counter to store number of times we've added to input sum</span>
|
||||
}
|
||||
<span class="literal">if</span> (numberOfTimesRun == <span class="number">0</span>) {
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">No numbers entered!</span><span class="string">"</span>);
|
||||
}
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">Current sum: </span><span class="string">"</span> + inputSum);
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">Input sum^2: </span><span class="string">"</span> + inputPow);
|
||||
} <span class="literal">while</span> (Double.<span class="ST4">parseDouble</span>(userInput) != -<span class="number">1</span>);
|
||||
} <span class="literal">catch</span> (Exception e) {
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">Invalid input!</span><span class="string">"</span>);
|
||||
}
|
||||
|
||||
} <span class="literal">else</span> {
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">Invalid input!</span><span class="string">"</span>);
|
||||
}
|
||||
<span class="comment">// Calculate mean</span>
|
||||
mean = inputSum / numberOfTimesRun;
|
||||
<span class="comment">// Calculate deviation</span>
|
||||
<span class="literal">if</span> (numberOfTimesRun == <span class="number">1</span>) { <span class="comment">// if the loop has only run once, don't bother calculating it, because the deviation is zero.</span>
|
||||
deviation = <span class="number">0</span>;
|
||||
} <span class="literal">else</span> {
|
||||
deviation = Math.<span class="ST4">sqrt</span>((inputPow - (Math.<span class="ST4">pow</span>(inputSum, <span class="number">2</span>) / numberOfTimesRun)) / (numberOfTimesRun - <span class="number">1</span>));
|
||||
}
|
||||
System.<span class="ST3">out</span>.println();
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">The mean is: </span><span class="string">"</span> + mean);
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">The deviation is: </span><span class="string">"</span> + deviation);
|
||||
|
||||
}
|
||||
<span class="literal">while</span> (!(userInput.toLowerCase().equals(<span class="string">"</span><span class="string">q</span><span class="string">"</span>)));
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
73
Semester 1/Assignments/MP3_CalebFontenot/build.xml
Normal file
73
Semester 1/Assignments/MP3_CalebFontenot/build.xml
Normal 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="MP3_CalebFontenot" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project MP3_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="MP3_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>
|
3
Semester 1/Assignments/MP3_CalebFontenot/manifest.mf
Normal file
3
Semester 1/Assignments/MP3_CalebFontenot/manifest.mf
Normal file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
X-COMMENT: Main-Class will be added automatically by build
|
||||
|
BIN
Semester 1/Assignments/MP3_CalebFontenot/mp3-asdv1220-f22.pdf
Normal file
BIN
Semester 1/Assignments/MP3_CalebFontenot/mp3-asdv1220-f22.pdf
Normal file
Binary file not shown.
1771
Semester 1/Assignments/MP3_CalebFontenot/nbproject/build-impl.xml
Normal file
1771
Semester 1/Assignments/MP3_CalebFontenot/nbproject/build-impl.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
build.xml.data.CRC32=af984b5c
|
||||
build.xml.script.CRC32=3d30e549
|
||||
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=af984b5c
|
||||
nbproject/build-impl.xml.script.CRC32=19fda9dc
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.104.0.48
|
@@ -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}/MP3_CalebFontenot.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
dist.jlink.dir=${dist.dir}/jlink
|
||||
dist.jlink.output=${dist.jlink.dir}/MP3_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=MP3_CalebFontenot
|
||||
main.class=mp3_calebfontenot.MP3_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
|
@@ -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>MP3_CalebFontenot</name>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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 mp3_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Calendar {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner input = new Scanner(System.in);
|
||||
System.out.print("Enter a year: ");
|
||||
int year = input.nextInt();
|
||||
System.out.print("Enter the first day of the year: ");
|
||||
int firstDay = input.nextInt();
|
||||
|
||||
int startDay = firstDay;
|
||||
int numberOfDaysInMonth = 0;
|
||||
for (int month = 1; month <= 12; month++) {
|
||||
System.out.print(" ");
|
||||
switch (month) {
|
||||
case 1:
|
||||
System.out.println("January " + year);
|
||||
numberOfDaysInMonth = 31;
|
||||
break;
|
||||
case 2:
|
||||
System.out.println("February " + year);
|
||||
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
|
||||
numberOfDaysInMonth = 29;
|
||||
} else {
|
||||
numberOfDaysInMonth = 28;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
System.out.println("March " + year);
|
||||
numberOfDaysInMonth = 31;
|
||||
break;
|
||||
case 4:
|
||||
System.out.println("April " + year);
|
||||
numberOfDaysInMonth = 30;
|
||||
break;
|
||||
case 5:
|
||||
System.out.println("May " + year);
|
||||
numberOfDaysInMonth = 31;
|
||||
break;
|
||||
case 6:
|
||||
System.out.println("June " + year);
|
||||
numberOfDaysInMonth = 30;
|
||||
break;
|
||||
case 7:
|
||||
System.out.println("July " + year);
|
||||
numberOfDaysInMonth = 31;
|
||||
break;
|
||||
case 8:
|
||||
System.out.println("August " + year);
|
||||
numberOfDaysInMonth = 31;
|
||||
break;
|
||||
case 9:
|
||||
System.out.println("September " + year);
|
||||
numberOfDaysInMonth = 30;
|
||||
break;
|
||||
case 10:
|
||||
System.out.println("October " + year);
|
||||
numberOfDaysInMonth = 31;
|
||||
break;
|
||||
case 11:
|
||||
System.out.println("November " + year);
|
||||
numberOfDaysInMonth = 30;
|
||||
break;
|
||||
case 12:
|
||||
System.out.println("December " + year);
|
||||
numberOfDaysInMonth = 31;
|
||||
break;
|
||||
}
|
||||
System.out.println("------------------------------");
|
||||
System.out.println(" Sun Mon Tue Wed Thu Fri Sat");
|
||||
int i = 0;
|
||||
for (i = 0; i < startDay; i++) {
|
||||
System.out.print(" ");
|
||||
}
|
||||
|
||||
for (i = 1; i <= numberOfDaysInMonth; i++) {
|
||||
if (i < 10) {
|
||||
System.out.print(" " + i);
|
||||
} else {
|
||||
System.out.print(" " + i);
|
||||
}
|
||||
|
||||
if ((i + startDay) % 7 == 0) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
startDay = (startDay + numberOfDaysInMonth) % 7;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 mp3_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class CalendarWhile {
|
||||
public static void main(String[] args) {
|
||||
Scanner input = new Scanner(System.in);
|
||||
System.out.print("Enter a year: ");
|
||||
int year = input.nextInt();
|
||||
System.out.print("Enter the first day of the year: ");
|
||||
int firstDay = input.nextInt();
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
|
||||
int startDay = firstDay;
|
||||
int numberOfDaysInMonth = 0;
|
||||
int month = 1;
|
||||
while (month <= 12) {
|
||||
System.out.print(" ");
|
||||
switch (month) {
|
||||
case 1: System.out.println("January " + year); numberOfDaysInMonth = 31; break;
|
||||
case 2: System.out.println("February " + year);
|
||||
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) numberOfDaysInMonth = 29;
|
||||
else numberOfDaysInMonth = 28;
|
||||
break;
|
||||
case 3: System.out.println("March " + year); numberOfDaysInMonth = 31; break;
|
||||
case 4: System.out.println("April " + year); numberOfDaysInMonth = 30; break;
|
||||
case 5: System.out.println("May " + year); numberOfDaysInMonth = 31; break;
|
||||
case 6: System.out.println("June " + year); numberOfDaysInMonth = 30; break;
|
||||
case 7: System.out.println("July " + year); numberOfDaysInMonth = 31; break;
|
||||
case 8: System.out.println("August " + year); numberOfDaysInMonth = 31; break;
|
||||
case 9: System.out.println("September " + year); numberOfDaysInMonth = 30; break;
|
||||
case 10: System.out.println("October " + year); numberOfDaysInMonth = 31; break;
|
||||
case 11: System.out.println("November " + year); numberOfDaysInMonth = 30; break;
|
||||
case 12: System.out.println("December " + year); numberOfDaysInMonth = 31; break;
|
||||
}
|
||||
System.out.println("------------------------------");
|
||||
System.out.println(" Sun Mon Tue Wed Thu Fri Sat");
|
||||
int i = 0;
|
||||
for (i = 0; i < startDay; i++) {
|
||||
System.out.print(" ");
|
||||
}
|
||||
for (i = 1; i <= numberOfDaysInMonth; i++) {
|
||||
if (i < 10) System.out.print(" " + i);
|
||||
else System.out.print(" " + i);
|
||||
|
||||
if ((i + startDay) % 7 == 0) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
startDay = (startDay + numberOfDaysInMonth) % 7;
|
||||
month++;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 mp3_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class FindHighestScore {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Scanner input = new Scanner(System.in);
|
||||
System.out.print("Enter the number of students: ");
|
||||
int numOfStudents = input.nextInt();
|
||||
System.out.print("Enter a student name: ");
|
||||
String student1 = input.next();
|
||||
System.out.print("Enter a student score: ");
|
||||
double score1 = input.nextDouble();
|
||||
for (int i = 0; i < numOfStudents - 1; i++) {
|
||||
System.out.print("Enter a student name: ");
|
||||
String student = input.next();
|
||||
System.out.print("Enter a student score: ");
|
||||
double score = input.nextDouble();
|
||||
if (score > score1) {
|
||||
student1 = student;
|
||||
score1 = score;
|
||||
}
|
||||
}
|
||||
System.out.println("Top student " + student1 + "'s score is " + score1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 mp3_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class FindHighestScoreDoWhile {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int i = 0;
|
||||
String student1 = "";
|
||||
double score1 = 0;
|
||||
|
||||
Scanner input = new Scanner(System.in);
|
||||
System.out.print("Enter the number of students: ");
|
||||
int numOfStudents = input.nextInt();
|
||||
do {
|
||||
System.out.print("Enter a student name: ");
|
||||
String student = input.next();
|
||||
System.out.print("Enter a student score: ");
|
||||
double score = input.nextDouble();
|
||||
if (score > score1) {
|
||||
student1 = student;
|
||||
score1 = score;
|
||||
}
|
||||
i++;
|
||||
} while (i < numOfStudents);
|
||||
System.out.println("Top student " + student1 + "'s score is " + score1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 mp3_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class FindHighestScoreWhile {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
Scanner input = new Scanner(System.in);
|
||||
System.out.print("Enter the number of students: ");
|
||||
int numOfStudents = input.nextInt();
|
||||
System.out.print("Enter a student name: ");
|
||||
String student1 = input.next();
|
||||
System.out.print("Enter a student score: ");
|
||||
double score1 = input.nextDouble();
|
||||
while (i < numOfStudents - 1) {
|
||||
System.out.print("Enter a student name: ");
|
||||
String student = input.next();
|
||||
System.out.print("Enter a student score: ");
|
||||
double score = input.nextDouble();
|
||||
if (score > score1) {
|
||||
student1 = student;
|
||||
score1 = score;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
System.out.println("Top student " + student1 + "'s score is " + score1);
|
||||
}
|
||||
}
|
@@ -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 mp3_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class FindTwoHighestScores {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Define variables
|
||||
double highScore1 = 0, highScore2 = 0, score;
|
||||
String bestStudent1 = "", bestStudent2 = "", student;
|
||||
int numberToIterate = 0;
|
||||
|
||||
// Compute
|
||||
System.out.print("Enter the number of students: ");
|
||||
numberToIterate = input.nextInt();
|
||||
for (int i = 0; i != numberToIterate; i++) {
|
||||
System.out.print("Enter a student name: ");
|
||||
student = input.next();
|
||||
System.out.print("Enter " + student + "'s score: ");
|
||||
score = input.nextDouble();
|
||||
|
||||
if (score > highScore1) { // New high score detected
|
||||
|
||||
if (highScore1 != 0) {
|
||||
highScore2 = highScore1; // assign highScore1 to highScore2
|
||||
bestStudent2 = bestStudent1;
|
||||
}
|
||||
highScore1 = score; // assign current score to high score
|
||||
bestStudent1 = student;
|
||||
}
|
||||
}
|
||||
System.out.println("Best score belongs to " + bestStudent1 + ", with a score of " + highScore1);
|
||||
System.out.println("Next best score belongs to " + bestStudent2 + ", with a score of " + highScore2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 mp3_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class FindTwoHighestScoresDoWhile {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Define variables
|
||||
double highScore1 = 0, highScore2 = 0, score;
|
||||
String bestStudent1 = "", bestStudent2 = "", student;
|
||||
int numberToIterate = 0;
|
||||
|
||||
// Compute
|
||||
System.out.print("Enter the number of students: ");
|
||||
numberToIterate = input.nextInt();
|
||||
int i = 0;
|
||||
do {
|
||||
System.out.print("Enter a student name: ");
|
||||
student = input.next();
|
||||
System.out.print("Enter " + student + "'s score: ");
|
||||
score = input.nextDouble();
|
||||
|
||||
if (score > highScore1) { // New high score detected
|
||||
|
||||
if (highScore1 != 0) {
|
||||
highScore2 = highScore1; // assign highScore1 to highScore2
|
||||
bestStudent2 = bestStudent1;
|
||||
}
|
||||
highScore1 = score; // assign current score to high score
|
||||
bestStudent1 = student;
|
||||
}
|
||||
i++;
|
||||
} while (i != numberToIterate);
|
||||
System.out.println("Best score belongs to " + bestStudent1 + ", with a score of " + highScore1);
|
||||
System.out.println("Next best score belongs to " + bestStudent2 + ", with a score of " + highScore2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 mp3_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class FindTwoHighestScoresWhile {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Define variables
|
||||
double highScore1 = 0, highScore2 = 0, score;
|
||||
String bestStudent1 = "", bestStudent2 = "", student;
|
||||
int numberToIterate = 0;
|
||||
|
||||
// Compute
|
||||
System.out.print("Enter the number of students: ");
|
||||
numberToIterate = input.nextInt();
|
||||
int i = 0;
|
||||
while (i != numberToIterate) {
|
||||
System.out.print("Enter a student name: ");
|
||||
student = input.next();
|
||||
System.out.print("Enter " + student + "'s score: ");
|
||||
score = input.nextDouble();
|
||||
|
||||
if (score > highScore1) { // New high score detected
|
||||
|
||||
if (highScore1 != 0) {
|
||||
highScore2 = highScore1; // assign highScore1 to highScore2
|
||||
bestStudent2 = bestStudent1;
|
||||
}
|
||||
highScore1 = score; // assign current score to high score
|
||||
bestStudent1 = student;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
System.out.println("Best score belongs to " + bestStudent1 + ", with a score of " + highScore1);
|
||||
System.out.println("Next best score belongs to " + bestStudent2 + ", with a score of " + highScore2);
|
||||
}
|
||||
}
|
@@ -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 mp3_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class GCD {
|
||||
public static void main(String[] args) {
|
||||
java.util.Scanner input = new java.util.Scanner(System.in);
|
||||
System.out.print("Enter the first number: ");
|
||||
int n1 = input.nextInt();
|
||||
System.out.print("Enter the second number: ");
|
||||
int n2 = input.nextInt();
|
||||
|
||||
int d = (n1 < n2) ? n1 : n2;
|
||||
for (; d >= 1; d--)
|
||||
if ((n1 % d == 0) && (n2 % d == 0))
|
||||
break;
|
||||
System.out.println("GCD of " + n1 + " and " + n2 + " is " + d);
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package mp3_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class GCDDoWhile {
|
||||
|
||||
public static void main(String[] args) {
|
||||
java.util.Scanner input = new java.util.Scanner(System.in);
|
||||
System.out.print("Enter the first number: ");
|
||||
int n1 = input.nextInt();
|
||||
System.out.print("Enter the second number: ");
|
||||
int n2 = input.nextInt();
|
||||
|
||||
int d = (n1 < n2) ? n1 : n2;
|
||||
do {
|
||||
if ((n1 % d == 0) && (n2 % d == 0)) {
|
||||
break;
|
||||
}
|
||||
d--;
|
||||
} while (d >= 1);
|
||||
System.out.println("GCD of " + n1 + " and " + n2 + " is " + d);
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package mp3_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class GCDWhile {
|
||||
|
||||
public static void main(String[] args) {
|
||||
java.util.Scanner input = new java.util.Scanner(System.in);
|
||||
System.out.print("Enter the first number: ");
|
||||
int n1 = input.nextInt();
|
||||
System.out.print("Enter the second number: ");
|
||||
int n2 = input.nextInt();
|
||||
|
||||
int d = (n1 < n2) ? n1 : n2;
|
||||
while (d >= 1) {
|
||||
if ((n1 % d == 0) && (n2 % d == 0)) {
|
||||
break;
|
||||
}
|
||||
d--;
|
||||
}
|
||||
System.out.println("GCD of " + n1 + " and " + n2 + " is " + d);
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
|
||||
*/
|
||||
package mp3_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class MP3_CalebFontenot {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// TODO code application logic here
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 mp3_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Stats {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
// Define variables
|
||||
double mean = 0; //It's twice as mean
|
||||
double inputSum = 0, numberOfTimesRun = 0, inputPow = 0, deviation = 0;
|
||||
String userInput = "";
|
||||
|
||||
// Prompt for input
|
||||
do {
|
||||
System.out.println("Press Y/y to enter a series of numbers or Q/q to quit.");
|
||||
System.out.println("Current sum: " + inputSum);
|
||||
userInput = input.next();
|
||||
if (userInput.toLowerCase().equals("y")) {
|
||||
try {
|
||||
do {
|
||||
System.out.print("Please enter a series of numbers; Type '-1' to quit (no quotes, you doofus!): ");
|
||||
userInput = input.next();
|
||||
if (Double.parseDouble(userInput) != -1) {
|
||||
inputSum += Double.parseDouble(userInput);
|
||||
inputPow += Math.pow(Double.parseDouble(userInput), 2);
|
||||
numberOfTimesRun++; // counter to store number of times we've added to input sum
|
||||
}
|
||||
if (numberOfTimesRun == 0) {
|
||||
System.out.println("No numbers entered!");
|
||||
}
|
||||
System.out.println("Current sum: " + inputSum);
|
||||
System.out.println("Input sum^2: " + inputPow);
|
||||
} while (Double.parseDouble(userInput) != -1);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Invalid input!");
|
||||
}
|
||||
|
||||
} else {
|
||||
System.out.println("Invalid input!");
|
||||
}
|
||||
// Calculate mean
|
||||
mean = inputSum / numberOfTimesRun;
|
||||
// Calculate deviation
|
||||
if (numberOfTimesRun == 1) { // if the loop has only run once, don't bother calculating it, because the deviation is zero.
|
||||
deviation = 0;
|
||||
} else {
|
||||
deviation = Math.sqrt((inputPow - (Math.pow(inputSum, 2) / numberOfTimesRun)) / (numberOfTimesRun - 1));
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println("The mean is: " + mean);
|
||||
System.out.println("The deviation is: " + deviation);
|
||||
|
||||
}
|
||||
while (!(userInput.toLowerCase().equals("q")));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user