MP3 complete!
This commit is contained in:
parent
a07ef7df60
commit
d32ce7930a
128
Assignments/MP3_CalebFontenot/Calendar.html
Normal file
128
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
Assignments/MP3_CalebFontenot/CalendarWhile.html
Normal file
90
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>
|
60
Assignments/MP3_CalebFontenot/FindHighestScore.html
Normal file
60
Assignments/MP3_CalebFontenot/FindHighestScore.html
Normal file
@ -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>
|
61
Assignments/MP3_CalebFontenot/FindHighestScoreDoWhile.html
Normal file
61
Assignments/MP3_CalebFontenot/FindHighestScoreDoWhile.html
Normal file
@ -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>
|
63
Assignments/MP3_CalebFontenot/FindHighestScoreWhile.html
Normal file
63
Assignments/MP3_CalebFontenot/FindHighestScoreWhile.html
Normal file
@ -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>
|
71
Assignments/MP3_CalebFontenot/FindTwoHighestScores.html
Normal file
71
Assignments/MP3_CalebFontenot/FindTwoHighestScores.html
Normal file
@ -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>
|
73
Assignments/MP3_CalebFontenot/FindTwoHighestScoresWhile.html
Normal file
73
Assignments/MP3_CalebFontenot/FindTwoHighestScoresWhile.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>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
Assignments/MP3_CalebFontenot/GCD.html
Normal file
50
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
Assignments/MP3_CalebFontenot/GCDDoWhile.html
Normal file
54
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
Assignments/MP3_CalebFontenot/GCDWhile.html
Normal file
54
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
Assignments/MP3_CalebFontenot/Stats.html
Normal file
96
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>
|
@ -12,7 +12,8 @@ import java.util.Scanner;
|
||||
*/
|
||||
public class Stats {
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
// Define variables
|
||||
@ -25,32 +26,42 @@ public class Stats {
|
||||
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
|
||||
}
|
||||
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!");
|
||||
}
|
||||
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
|
||||
deviation = ((numberOfTimesRun - 1) / (inputPow - (Math.pow(inputSum, 2) / numberOfTimesRun)));
|
||||
|
||||
System.out.println();
|
||||
System.out.println("The mean is: " + mean);
|
||||
System.out.println("The deviation is: " + deviation);
|
||||
// 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")));
|
||||
}
|
||||
while (!(userInput.toLowerCase().equals("q")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
ZIPs/MP3_CalebFontenot.zip
Normal file
BIN
ZIPs/MP3_CalebFontenot.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user