Initial Commit
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/../../../../../../:\ProgrammingProjects\JavaProjects\JavaYear1\Assignment11\.idea/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
@@ -0,0 +1,7 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
+1
@@ -0,0 +1 @@
|
||||
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT" />
|
||||
</component>
|
||||
</project>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,10 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<Languages>
|
||||
<language minSize="133" name="Java" />
|
||||
</Languages>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
Generated
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectKey">
|
||||
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Assignment11.iml" filepath="$PROJECT_DIR$/Assignment11.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
|
||||
</template>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,50 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Simple test stats
|
||||
* @author Isaac Shoebottom (3429069)
|
||||
*/
|
||||
|
||||
public class ClassGrades {
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
long testScore;
|
||||
long numberOfA = 0;
|
||||
long numberOfB = 0;
|
||||
long numberOfC = 0;
|
||||
long numberOfD = 0;
|
||||
long numberOfF = 0;
|
||||
do {
|
||||
System.out.print("Enter test score: ");
|
||||
testScore = scan.nextLong();
|
||||
|
||||
if (testScore > 100) {
|
||||
System.out.println("Please enter a test score within the range 0-100");
|
||||
}
|
||||
else {
|
||||
if (testScore >= 85) {
|
||||
numberOfA++;
|
||||
}
|
||||
else if (testScore >= 70) {
|
||||
numberOfB++;
|
||||
}
|
||||
else if (testScore >= 55) {
|
||||
numberOfC++;
|
||||
}
|
||||
else if (testScore >= 45) {
|
||||
numberOfD++;
|
||||
}
|
||||
else if (testScore >= 0) {
|
||||
numberOfF++;
|
||||
}
|
||||
}
|
||||
} while (testScore >= 0);
|
||||
|
||||
System.out.println("Number of A's: " + numberOfA);
|
||||
System.out.println("Number of B's: " + numberOfB);
|
||||
System.out.println("Number of C's: " + numberOfC);
|
||||
System.out.println("Number of D's: " + numberOfD);
|
||||
System.out.println("Number of F's: " + numberOfF);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Sideways histogram for tests
|
||||
* @author Isaac Shoebottom (3429069)
|
||||
*/
|
||||
|
||||
public class ClassGradesHistogram {
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
long testScore;
|
||||
long numberOfA = 0;
|
||||
long numberOfB = 0;
|
||||
long numberOfC = 0;
|
||||
long numberOfD = 0;
|
||||
long numberOfF = 0;
|
||||
do {
|
||||
System.out.print("Enter test score: ");
|
||||
testScore = scan.nextLong();
|
||||
|
||||
if (testScore > 100) {
|
||||
System.out.println("Please enter a test score within the range 0-100");
|
||||
} else {
|
||||
if (testScore >= 85) {
|
||||
numberOfA++;
|
||||
} else if (testScore >= 70) {
|
||||
numberOfB++;
|
||||
} else if (testScore >= 55) {
|
||||
numberOfC++;
|
||||
} else if (testScore >= 45) {
|
||||
numberOfD++;
|
||||
} else if (testScore >= 0) {
|
||||
numberOfF++;
|
||||
}
|
||||
}
|
||||
} while (testScore >= 0);
|
||||
|
||||
System.out.println("Scores");
|
||||
System.out.print("A\t\t|");
|
||||
while (numberOfA > 0) {
|
||||
System.out.print('*');
|
||||
numberOfA--;
|
||||
}
|
||||
System.out.println();
|
||||
System.out.print("B\t\t|");
|
||||
while (numberOfB > 0) {
|
||||
System.out.print('*');
|
||||
numberOfB--;
|
||||
}
|
||||
System.out.println();
|
||||
System.out.print("C\t\t|");
|
||||
while (numberOfC > 0) {
|
||||
System.out.print('*');
|
||||
numberOfC--;
|
||||
}
|
||||
System.out.println();
|
||||
System.out.print("D\t\t|");
|
||||
while (numberOfD > 0) {
|
||||
System.out.print('*');
|
||||
numberOfD--;
|
||||
}
|
||||
System.out.println();
|
||||
System.out.print("F\t\t|");
|
||||
while (numberOfF > 0) {
|
||||
System.out.print('*');
|
||||
numberOfF--;
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println("\t\t" + "===============================");
|
||||
System.out.println("\t\t" + "+ + + +");
|
||||
System.out.println("\t\t" + "0 10 20 30");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Vertical histogram for tests
|
||||
* @author Isaac Shoebottom (3429069)
|
||||
*/
|
||||
|
||||
public class ClassGradesHistogramVertical {
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
long testScore;
|
||||
long numberOfA = 0;
|
||||
long numberOfB = 0;
|
||||
long numberOfC = 0;
|
||||
long numberOfD = 0;
|
||||
long numberOfF = 0;
|
||||
do {
|
||||
System.out.print("Enter test score: ");
|
||||
testScore = scan.nextLong();
|
||||
|
||||
if (testScore > 100) {
|
||||
System.out.println("Please enter a test score within the range 0-100");
|
||||
} else {
|
||||
if (testScore >= 85) {
|
||||
numberOfA++;
|
||||
} else if (testScore >= 70) {
|
||||
numberOfB++;
|
||||
} else if (testScore >= 55) {
|
||||
numberOfC++;
|
||||
} else if (testScore >= 45) {
|
||||
numberOfD++;
|
||||
} else if (testScore >= 0) {
|
||||
numberOfF++;
|
||||
}
|
||||
}
|
||||
} while (testScore >= 0);
|
||||
|
||||
for (int i = 30; i > 0; i--) {
|
||||
if (i == 30 | i == 20 | i == 10)
|
||||
System.out.print(i+ "+");
|
||||
System.out.print("\t| ");
|
||||
if (numberOfA >= i) {
|
||||
System.out.print('*');
|
||||
}
|
||||
else {
|
||||
System.out.print(' ');
|
||||
}
|
||||
System.out.print(' ');
|
||||
if (numberOfB >= i) {
|
||||
System.out.print('*');
|
||||
}
|
||||
else {
|
||||
System.out.print(' ');
|
||||
}
|
||||
System.out.print(' ');
|
||||
if (numberOfC >= i) {
|
||||
System.out.print('*');
|
||||
}
|
||||
else {
|
||||
System.out.print(' ');
|
||||
}
|
||||
System.out.print(' ');
|
||||
if (numberOfD >= i) {
|
||||
System.out.print('*');
|
||||
}
|
||||
else {
|
||||
System.out.print(' ');
|
||||
}
|
||||
System.out.print(' ');
|
||||
if (numberOfF >= i) {
|
||||
System.out.print('*');
|
||||
}
|
||||
else {
|
||||
System.out.print(' ');
|
||||
}
|
||||
System.out.print(' ');
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println("0+\t===========");
|
||||
System.out.println("\t A B C D F");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Array utils for ints
|
||||
* @author Isaac Shoebottom (3429069)
|
||||
*/
|
||||
|
||||
public class IntArrayUtil {
|
||||
|
||||
/**
|
||||
* Appends an array to another array
|
||||
* @param arrA First array in append
|
||||
* @param arrB Second array in append
|
||||
* @return Appended array
|
||||
*/
|
||||
public static int[] append (int[] arrA, int[] arrB) {
|
||||
int appendedLength = arrA.length + arrB.length;
|
||||
int[] appended = new int[appendedLength];
|
||||
for(int i = 0; i < arrA.length; i++) {
|
||||
appended[i] = arrA[i];
|
||||
}
|
||||
for(int i = 0; i < arrB.length; i++) {
|
||||
appended[i + arrA.length] = arrB[i];
|
||||
}
|
||||
return appended;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the order of elements in a string
|
||||
* @param arr The array to be reversed
|
||||
* @return The reversed array
|
||||
*/
|
||||
public static int[] reverse (int[] arr) {
|
||||
int[] reversed = new int[arr.length];
|
||||
for(int i =0; i<arr.length; i++ ) {
|
||||
reversed[i] = arr[i];
|
||||
}
|
||||
|
||||
for(int i = 0; i < arr.length/2; i++) {
|
||||
int temp = reversed[i];
|
||||
reversed[i] = arr[(arr.length-1) - i];
|
||||
reversed[(arr.length-1) - i] = temp;
|
||||
}
|
||||
|
||||
return reversed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts every odd index from a string from every even index
|
||||
* @param arr The array to perform math on
|
||||
* @return The alternating sum of the array
|
||||
*/
|
||||
public static int alternatingSum (int[] arr) {
|
||||
|
||||
int positives = 0;
|
||||
int negatives = 0;
|
||||
boolean isPos = true;
|
||||
for (int j : arr)
|
||||
if (isPos) {
|
||||
positives += j;
|
||||
isPos = false;
|
||||
} else {
|
||||
negatives += j;
|
||||
isPos = true;
|
||||
}
|
||||
|
||||
return positives-negatives;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
public class IntArrayUtilDriver {
|
||||
public static void main(String[] args) {
|
||||
int[] array1 = {1, 4 ,9, 16};
|
||||
int[] array2 = {9, 7, 4, 9 ,11};
|
||||
|
||||
int[] array3 = IntArrayUtil.append(array1, array2);
|
||||
|
||||
|
||||
System.out.println("These are the original strings");
|
||||
System.out.println(Arrays.toString(array1));
|
||||
System.out.println(Arrays.toString(array2));
|
||||
System.out.println(Arrays.toString(array3));
|
||||
|
||||
System.out.println("These are the modified strings");
|
||||
System.out.println(Arrays.toString(IntArrayUtil.append(array1, array2)));
|
||||
System.out.println(Arrays.toString(IntArrayUtil.reverse(array3)));
|
||||
System.out.println(IntArrayUtil.alternatingSum(array3));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
public class Pattern {
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (int i = 10; i > 0; i--) {
|
||||
for (int j = 1; j <= i; j++) {
|
||||
System.out.print('*');
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Inverted Stairs
|
||||
* @author Isaac Shoebottom (3429069)
|
||||
*/
|
||||
|
||||
public class PatternInverted {
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (int i = 1; i < 10; i++) {
|
||||
for (int a = 9; a > i; a--) {
|
||||
System.out.print(' ');
|
||||
}
|
||||
for (int j = 1; j <= i; j++) {
|
||||
System.out.print('*');
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user