Initial Commit
This commit is contained in:
8
Source Code/Assignment6/.idea/.gitignore
generated
vendored
Normal file
8
Source Code/Assignment6/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/../../../../../:\JavaProjects\JavaYear1\Assignment6\.idea/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
25
Source Code/Assignment6/.idea/codeStyles/Project.xml
generated
Normal file
25
Source Code/Assignment6/.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,25 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
</JetCodeStyleSettings>
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
Source Code/Assignment6/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
Source Code/Assignment6/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
1
Source Code/Assignment6/.idea/description.html
generated
Normal file
1
Source Code/Assignment6/.idea/description.html
generated
Normal file
@ -0,0 +1 @@
|
||||
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>
|
6
Source Code/Assignment6/.idea/encodings.xml
generated
Normal file
6
Source Code/Assignment6/.idea/encodings.xml
generated
Normal file
@ -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>
|
12
Source Code/Assignment6/.idea/misc.xml
generated
Normal file
12
Source Code/Assignment6/.idea/misc.xml
generated
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="ProjectKey">
|
||||
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
Source Code/Assignment6/.idea/modules.xml
generated
Normal file
8
Source Code/Assignment6/.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Assignment6.iml" filepath="$PROJECT_DIR$/Assignment6.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
3
Source Code/Assignment6/.idea/project-template.xml
generated
Normal file
3
Source Code/Assignment6/.idea/project-template.xml
generated
Normal file
@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
|
||||
</template>
|
12
Source Code/Assignment6/Assignment6.iml
Normal file
12
Source Code/Assignment6/Assignment6.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?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.
27
Source Code/Assignment6/src/LeapYearCheck.java
Normal file
27
Source Code/Assignment6/src/LeapYearCheck.java
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
*This class takes a given date and tells the user if it is a leap year
|
||||
* @author Isaac Shoebottom (3429069)
|
||||
*/
|
||||
public class LeapYearCheck {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
java.util.Scanner scanner = new java.util.Scanner(System.in);
|
||||
long year;
|
||||
do {
|
||||
System.out.print("Please enter a year: ");
|
||||
year = scanner.nextLong();
|
||||
if (year < 1582) {
|
||||
System.out.println("Invalid Year, you cannot enter a year prior to 1582");
|
||||
}
|
||||
}
|
||||
while (year < 1582);
|
||||
|
||||
if ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)) {
|
||||
System.out.println("This is a leap year");
|
||||
}
|
||||
else {
|
||||
System.out.println("This is not a leap year.");
|
||||
}
|
||||
}
|
||||
}
|
71
Source Code/Assignment6/src/MakingChange.java
Normal file
71
Source Code/Assignment6/src/MakingChange.java
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* This class returns the amount of change the user would be given provided they give the amount they paid and the price of their items
|
||||
* @author Isaac Shoebottom (3429069)
|
||||
*/
|
||||
|
||||
public class MakingChange {
|
||||
public static void main(String[] args){
|
||||
java.util.Scanner scanner = new java.util.Scanner(System.in);
|
||||
double totalPrice;
|
||||
double amountPaid;
|
||||
long changeTotal;
|
||||
|
||||
do {
|
||||
do {
|
||||
System.out.print("Please enter the total price: ");
|
||||
totalPrice = scanner.nextDouble();
|
||||
if (totalPrice <= 0) {
|
||||
System.out.println("Invalid input. Please enter a positive number");
|
||||
}
|
||||
}
|
||||
while (totalPrice <= 0);
|
||||
|
||||
do {
|
||||
System.out.print("Please enter the amount paid: ");
|
||||
amountPaid = scanner.nextDouble();
|
||||
if (amountPaid <= 0) {
|
||||
System.out.println("Invalid input. Please enter a positive number");
|
||||
}
|
||||
}
|
||||
while (amountPaid < 0);
|
||||
changeTotal = (long)(amountPaid*100) - (long)(totalPrice*100);
|
||||
if (changeTotal< 0) {
|
||||
System.out.println("Invalid inputs. The amount of change given must be at least zero \n");
|
||||
}
|
||||
}
|
||||
while (changeTotal < 0);
|
||||
|
||||
|
||||
long twenties = (changeTotal/2000);
|
||||
changeTotal -= (twenties * 2000);
|
||||
long tens = (changeTotal/1000);
|
||||
changeTotal -= (tens * 1000);
|
||||
long fives = (changeTotal/500);
|
||||
changeTotal -= (fives * 500);
|
||||
long toonies = (changeTotal/200);
|
||||
changeTotal -= (toonies * 200);
|
||||
long loonies = (changeTotal/100);
|
||||
changeTotal -= (loonies * 100);
|
||||
long quarters = (changeTotal/25);
|
||||
changeTotal -= (quarters * 25);
|
||||
long dimes = (changeTotal/10);
|
||||
changeTotal -= (dimes * 10);
|
||||
long nickels = (changeTotal/5);
|
||||
changeTotal -= (nickels * 5);
|
||||
long pennies = changeTotal;
|
||||
|
||||
System.out.println(
|
||||
"\n" +
|
||||
"Here is the change that they are due:\n" +
|
||||
"20$ bills: " + twenties + "\n" +
|
||||
"10$ bills: " + tens + "\n" +
|
||||
"5$ bills: " + fives + "\n" +
|
||||
"Toonies: " + toonies + "\n" +
|
||||
"Loonies: " + loonies + "\n" +
|
||||
"Quarters: " + quarters + "\n" +
|
||||
"Dimes: " + dimes + "\n" +
|
||||
"Nickels: " + nickels + "\n" +
|
||||
"Pennies: " + pennies
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user