Practice for Exam 1
This commit is contained in:
parent
bbc15604a4
commit
6f4aada887
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,3 +7,6 @@
|
||||
/MP2_CalebFontenot/target/
|
||||
/lab8_CalebFontenot/target/
|
||||
/lab9_CalebFontenot/target/
|
||||
/ExamPractice/target/
|
||||
/Exam1_CalebFontenot/target/
|
||||
/Exam1Practice_CalebFontenot/target/
|
||||
|
86
Exam1Practice_CalebFontenot/DayOfTheWeek.html
Executable file
86
Exam1Practice_CalebFontenot/DayOfTheWeek.html
Executable file
@ -0,0 +1,86 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>DayOfTheWeek.java</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #000000; background-color: #ffffff; font-family: monospace}
|
||||
pre {color: #000000; background-color: #ffffff; font-family: monospace}
|
||||
table {color: #404040; background-color: #e9e8e2; font-family: monospace}
|
||||
.ST1 {color: #969696; font-family: monospace; font-weight: bold}
|
||||
.ST2 {font-family: monospace; font-weight: bold}
|
||||
.comment {color: #969696}
|
||||
.ST3 {font-family: monospace; font-weight: bold; font-style: italic}
|
||||
.ST4 {color: #ce54b8; font-family: monospace; font-style: italic}
|
||||
.ST0 {color: #287bde}
|
||||
.string {color: #1e9347}
|
||||
.ST5 {color: #1e9347; font-family: monospace; font-weight: bold}
|
||||
.literal {color: #336bdd}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">C:\Users\ar114\Documents\NetBeansProjects\Exam1_CalebFontenot\src\main\java\com\calebfontenot\exam1_calebfontenot\DayOfTheWeek.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> com.calebfontenot.exam1_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">ar114</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> <span class="ST2">DayOfTheWeek</span> {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST3">main</span>(String[] args) {
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.<span class="ST4">in</span>);
|
||||
System.<span class="ST4">out</span>.print(<span class="string">"</span><span class="ST5">\n</span><span class="ST5">\n</span><span class="string"> Enter year (e.g. 2008): </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> year = input.nextInt();
|
||||
System.<span class="ST4">out</span>.print(<span class="string">"</span><span class="string">Enter month 1-12: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> month = input.nextInt();
|
||||
<span class="literal">if</span> (month == 1) {
|
||||
month = 13;
|
||||
year = year - 1;
|
||||
}
|
||||
<span class="literal">else</span> <span class="literal">if</span> (month == 2) {
|
||||
month = 14;
|
||||
year = year - 1;
|
||||
}
|
||||
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">Enter the day of the month: 1-31: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> dayOfMonth = input.nextInt();
|
||||
|
||||
<span class="literal">int</span> j = year / 100;
|
||||
<span class="literal">int</span> k = year % 100;
|
||||
|
||||
<span class="literal">int</span> dayOfWeek = (dayOfMonth
|
||||
+ 26 * (month + 1) / 10 + k + k / 4 + j / 4 + 5 * j) % 7;
|
||||
<span class="literal">if</span> (dayOfWeek == 0) {
|
||||
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">Day of the week is Saturday</span><span class="string">"</span>);
|
||||
}
|
||||
<span class="literal">else</span> <span class="literal">if</span> (dayOfWeek == 1) {
|
||||
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">Day of the week is Sunday</span><span class="string">"</span>);
|
||||
}
|
||||
<span class="literal">else</span> <span class="literal">if</span> (dayOfWeek == 2) {
|
||||
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">Day of the week is Monday</span><span class="string">"</span>);
|
||||
}
|
||||
<span class="literal">else</span> <span class="literal">if</span> (dayOfWeek == 3) {
|
||||
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">Day of the week is Tuesday</span><span class="string">"</span>);
|
||||
}
|
||||
<span class="literal">else</span> <span class="literal">if</span> (dayOfWeek == 4) {
|
||||
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">Day of the week is Wednesday</span><span class="string">"</span>);
|
||||
}
|
||||
<span class="literal">else</span> <span class="literal">if</span> (dayOfWeek == 5) {
|
||||
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">Day of the week is Thursday</span><span class="string">"</span>);
|
||||
}
|
||||
<span class="literal">else</span> <span class="literal">if</span> (dayOfWeek == 6) {
|
||||
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">Day of the week is Friday</span><span class="string">"</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
71
Exam1Practice_CalebFontenot/RandomMonth.html
Executable file
71
Exam1Practice_CalebFontenot/RandomMonth.html
Executable 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>RandomMonth.java</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #000000; background-color: #ffffff; font-family: monospace}
|
||||
pre {color: #000000; background-color: #ffffff; font-family: monospace}
|
||||
table {color: #404040; background-color: #e9e8e2; font-family: monospace}
|
||||
.ST1 {color: #969696; font-family: monospace; font-weight: bold}
|
||||
.ST2 {font-family: monospace; font-weight: bold}
|
||||
.comment {color: #969696}
|
||||
.ST3 {font-family: monospace; font-weight: bold; font-style: italic}
|
||||
.ST4 {font-family: monospace; font-style: italic}
|
||||
.ST5 {color: #ce54b8; font-family: monospace; font-style: italic}
|
||||
.ST0 {color: #287bde}
|
||||
.string {color: #1e9347}
|
||||
.literal {color: #336bdd}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">C:\Users\ar114\Documents\NetBeansProjects\Exam1_CalebFontenot\src\main\java\com\calebfontenot\exam1_calebfontenot\RandomMonth.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> com.calebfontenot.exam1_calebfontenot;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST1">@author</span> <span class="comment">ar114</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> <span class="ST2">RandomMonth</span> {
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST3">main</span>(String[] args) {
|
||||
<span class="literal">int</span> number = (<span class="literal">int</span>) (Math.<span class="ST4">random</span>() * 12 + 1);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Random generated number is: </span><span class="string">"</span> + number);
|
||||
<span class="literal">switch</span> (number) {
|
||||
<span class="literal">case</span> 1:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is January</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
<span class="literal">case</span> 2:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is February</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
<span class="literal">case</span> 3:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is March</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
<span class="literal">case</span> 4:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is April</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
<span class="literal">case</span> 5:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is May</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
<span class="literal">case</span> 6:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is June</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
<span class="literal">case</span> 7:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is July</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
<span class="literal">case</span> 8:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is August</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
<span class="literal">case</span> 9:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is September</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
<span class="literal">case</span> 10:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is October</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
<span class="literal">case</span> 11:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is November</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
<span class="literal">case</span> 12:
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">Month is December</span><span class="string">"</span>); <span class="literal">break</span>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
61
Exam1Practice_CalebFontenot/TrianglePerimeter.html
Executable file
61
Exam1Practice_CalebFontenot/TrianglePerimeter.html
Executable 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>TrianglePerimeter.java</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #000000; background-color: #ffffff; font-family: monospace}
|
||||
pre {color: #000000; background-color: #ffffff; font-family: monospace}
|
||||
table {color: #404040; background-color: #e9e8e2; font-family: monospace}
|
||||
.ST1 {color: #969696; font-family: monospace; font-weight: bold}
|
||||
.ST2 {font-family: monospace; font-weight: bold}
|
||||
.comment {color: #969696}
|
||||
.ST3 {font-family: monospace; font-weight: bold; font-style: italic}
|
||||
.ST4 {color: #ce54b8; font-family: monospace; font-style: italic}
|
||||
.ST0 {color: #287bde}
|
||||
.string {color: #1e9347}
|
||||
.literal {color: #336bdd}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">C:\Users\ar114\Documents\NetBeansProjects\Exam1_CalebFontenot\src\main\java\com\calebfontenot\exam1_calebfontenot\TrianglePerimeter.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> com.calebfontenot.exam1_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">ar114</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> <span class="ST2">TrianglePerimeter</span> {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST3">main</span>(String[] args) {
|
||||
<span class="comment">// Create scanner</span>
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.<span class="ST4">in</span>);
|
||||
|
||||
<span class="comment">// Define variables</span>
|
||||
<span class="literal">int</span> triEdge1, triEdge2, triEdge3;
|
||||
|
||||
<span class="comment">// Prompt for input</span>
|
||||
System.<span class="ST4">out</span>.print(<span class="string">"</span><span class="string">Enter 3 edges for a triangle: </span><span class="string">"</span>);
|
||||
triEdge1 = input.nextInt();
|
||||
triEdge2 = input.nextInt();
|
||||
triEdge3 = input.nextInt();
|
||||
|
||||
<span class="comment">// Compute and print output</span>
|
||||
System.<span class="ST4">out</span>.println(((triEdge1 + triEdge2) > triEdge3) ||
|
||||
((triEdge1 + triEdge3) > triEdge2) ||
|
||||
((triEdge2 + triEdge3) > triEdge1) ?
|
||||
<span class="string">"</span><span class="string">Input is valid</span><span class="string">"</span> : <span class="string">"</span><span class="string">Invalid Input</span><span class="string">"</span>);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
14
Exam1Practice_CalebFontenot/pom.xml
Executable file
14
Exam1Practice_CalebFontenot/pom.xml
Executable file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.calebfontenot.exam1_calebfontenot</groupId>
|
||||
<artifactId>Exam1_CalebFontenot</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<exec.mainClass>com.calebfontenot.exam1_calebfontenot.Exam1_CalebFontenot</exec.mainClass>
|
||||
</properties>
|
||||
</project>
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.exam1_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ar114
|
||||
*/
|
||||
public class DayOfTheWeek {
|
||||
public static void main(String[] args) {
|
||||
Scanner input = new Scanner(System.in);
|
||||
System.out.print("\n\n Enter year (e.g. 2008): ");
|
||||
int year = input.nextInt();
|
||||
System.out.print("Enter month 1-12: ");
|
||||
int month = input.nextInt();
|
||||
if (month == 1) {
|
||||
month = 13;
|
||||
year = year - 1;
|
||||
}
|
||||
else if (month == 2) {
|
||||
month = 14;
|
||||
year = year - 1;
|
||||
}
|
||||
System.out.println("Enter the day of the month: 1-31: ");
|
||||
int dayOfMonth = input.nextInt();
|
||||
|
||||
int j = year / 100;
|
||||
int k = year % 100;
|
||||
|
||||
int dayOfWeek = (dayOfMonth
|
||||
+ 26 * (month + 1) / 10 + k + k / 4 + j / 4 + 5 * j) % 7;
|
||||
if (dayOfWeek == 0) {
|
||||
System.out.println("Day of the week is Saturday");
|
||||
}
|
||||
else if (dayOfWeek == 1) {
|
||||
System.out.println("Day of the week is Sunday");
|
||||
}
|
||||
else if (dayOfWeek == 2) {
|
||||
System.out.println("Day of the week is Monday");
|
||||
}
|
||||
else if (dayOfWeek == 3) {
|
||||
System.out.println("Day of the week is Tuesday");
|
||||
}
|
||||
else if (dayOfWeek == 4) {
|
||||
System.out.println("Day of the week is Wednesday");
|
||||
}
|
||||
else if (dayOfWeek == 5) {
|
||||
System.out.println("Day of the week is Thursday");
|
||||
}
|
||||
else if (dayOfWeek == 6) {
|
||||
System.out.println("Day of the week is Friday");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
|
||||
*/
|
||||
|
||||
package com.calebfontenot.exam1_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ar114
|
||||
*/
|
||||
public class Exam1_CalebFontenot {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.exam1_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ar114
|
||||
*/
|
||||
public class RandomMonth {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int number = (int) (Math.random() * 12 + 1);
|
||||
System.out.println("Random generated number is: " + number);
|
||||
switch (number) {
|
||||
case 1:
|
||||
System.out.println("Month is January"); break;
|
||||
case 2:
|
||||
System.out.println("Month is February"); break;
|
||||
case 3:
|
||||
System.out.println("Month is March"); break;
|
||||
case 4:
|
||||
System.out.println("Month is April"); break;
|
||||
case 5:
|
||||
System.out.println("Month is May"); break;
|
||||
case 6:
|
||||
System.out.println("Month is June"); break;
|
||||
case 7:
|
||||
System.out.println("Month is July"); break;
|
||||
case 8:
|
||||
System.out.println("Month is August"); break;
|
||||
case 9:
|
||||
System.out.println("Month is September"); break;
|
||||
case 10:
|
||||
System.out.println("Month is October"); break;
|
||||
case 11:
|
||||
System.out.println("Month is November"); break;
|
||||
case 12:
|
||||
System.out.println("Month is December"); break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.exam1_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ar114
|
||||
*/
|
||||
public class TrianglePerimeter {
|
||||
public static void main(String[] args) {
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Define variables
|
||||
int triEdge1, triEdge2, triEdge3;
|
||||
|
||||
// Prompt for input
|
||||
System.out.print("Enter 3 edges for a triangle: ");
|
||||
triEdge1 = input.nextInt();
|
||||
triEdge2 = input.nextInt();
|
||||
triEdge3 = input.nextInt();
|
||||
|
||||
// Compute and print output
|
||||
System.out.println(((triEdge1 + triEdge2) > triEdge3) ||
|
||||
((triEdge1 + triEdge3) > triEdge2) ||
|
||||
((triEdge2 + triEdge3) > triEdge1) ?
|
||||
"Input is valid" : "Invalid Input");
|
||||
|
||||
}
|
||||
}
|
BIN
ExamPractice/exam1Programming-2-1.pdf
Normal file
BIN
ExamPractice/exam1Programming-2-1.pdf
Normal file
Binary file not shown.
14
ExamPractice/pom.xml
Normal file
14
ExamPractice/pom.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.calebfontenot</groupId>
|
||||
<artifactId>ExamPractice</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>18</maven.compiler.source>
|
||||
<maven.compiler.target>18</maven.compiler.target>
|
||||
<exec.mainClass>com.calebfontenot.exampractice.ExamPractice</exec.mainClass>
|
||||
</properties>
|
||||
</project>
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.exampractice;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class AscendingOrderOf3 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
//Define variables
|
||||
int x, y, z;
|
||||
int firstNumber=-1, secondNumber=-1, thirdNumber=-1;
|
||||
// Prompt for input
|
||||
System.out.print("Enter a 3 integers: ");
|
||||
x = input.nextInt();
|
||||
y = input.nextInt();
|
||||
z = input.nextInt();
|
||||
|
||||
// Compute!
|
||||
if (x <= y && x <= z) {// Check if x is greater than y && y is greater than z
|
||||
System.out.println("1st if condition met");
|
||||
firstNumber = x;
|
||||
if (y <= z) {
|
||||
secondNumber = y;
|
||||
thirdNumber = z;
|
||||
}
|
||||
else {
|
||||
secondNumber = z;
|
||||
thirdNumber = y;
|
||||
}
|
||||
}
|
||||
if (y <= x && y <= z) {
|
||||
System.out.println("2nd if condition met");
|
||||
firstNumber = y;
|
||||
if (x <= z) {
|
||||
secondNumber = x;
|
||||
thirdNumber = z;
|
||||
}
|
||||
else {
|
||||
secondNumber = z;
|
||||
thirdNumber = x;
|
||||
}
|
||||
}
|
||||
if (z <= y && z <= x) {
|
||||
System.out.println("3rd if condition met");
|
||||
firstNumber = z;
|
||||
if (z <= x) {
|
||||
secondNumber = y;
|
||||
thirdNumber = x;
|
||||
}
|
||||
else {
|
||||
secondNumber = x;
|
||||
thirdNumber = y;
|
||||
}
|
||||
}
|
||||
// Output
|
||||
System.out.println(firstNumber + ", " + secondNumber + ", " + thirdNumber);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.exampractice;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class ExamPractice {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int numberPicker;
|
||||
char letter;
|
||||
while (true) {
|
||||
numberPicker = (int) (Math.random() * 0x7F);
|
||||
letter = (char) numberPicker;
|
||||
System.out.println(letter);
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ public class LogicalExpression {
|
||||
System.out.print(x < 100 && x > 1 || (x < 0)); //correct
|
||||
System.out.print(": " + x);
|
||||
|
||||
if (x >= 150 && hasCycled == false) {
|
||||
if (x >= 150 & hasCycled == false) {
|
||||
hasCycled = true;
|
||||
} else if (x <= -10) {
|
||||
hasCycled = false;
|
||||
|
@ -2,7 +2,6 @@
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
|
||||
*/
|
||||
|
||||
package com.mycompany.mavenproject1;
|
||||
|
||||
/**
|
||||
@ -11,7 +10,16 @@ package com.mycompany.mavenproject1;
|
||||
*/
|
||||
public class Mavenproject1 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(0 ^ 0);
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int x = 10;
|
||||
int y = 1;
|
||||
|
||||
System.out.println(x ^ y); // result is 11
|
||||
System.out.println(x & y); //result is 0
|
||||
System.out.println(x | y); // result is 11
|
||||
System.out.println(0 ^ 1); // result is 1
|
||||
System.out.println(1 ^ 1); // result is 0
|
||||
System.out.println(0 ^ 0); // result is 11
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5
mavenproject1/target/maven-archiver/pom.properties
Normal file
5
mavenproject1/target/maven-archiver/pom.properties
Normal file
@ -0,0 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Tue Sep 27 12:01:14 CDT 2022
|
||||
artifactId=mavenproject1
|
||||
groupId=com.mycompany
|
||||
version=1.0-SNAPSHOT
|
@ -1,2 +1,5 @@
|
||||
/home/caleb/NetBeansProjects/mavenproject1/src/main/java/com/mycompany/mavenproject1/Mavenproject1.java
|
||||
/home/caleb/NetBeansProjects/mavenproject1/src/main/java/com/mycompany/mavenproject1/ByteOverFlow.java
|
||||
/home/caleb/NetBeansProjects/ADSV Java/mavenproject1/src/main/java/com/mycompany/mavenproject1/LogicalExpression.java
|
||||
/home/caleb/NetBeansProjects/ADSV Java/mavenproject1/src/main/java/com/mycompany/mavenproject1/ByteOverFlow.java
|
||||
/home/caleb/NetBeansProjects/ADSV Java/mavenproject1/src/main/java/com/mycompany/mavenproject1/PrePostIncrement.java
|
||||
/home/caleb/NetBeansProjects/ADSV Java/mavenproject1/src/main/java/com/mycompany/mavenproject1/Mavenproject1.java
|
||||
/home/caleb/NetBeansProjects/ADSV Java/mavenproject1/src/main/java/com/mycompany/mavenproject1/NotDemo.java
|
||||
|
BIN
mavenproject1/target/mavenproject1-1.0-SNAPSHOT.jar
Normal file
BIN
mavenproject1/target/mavenproject1-1.0-SNAPSHOT.jar
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user