inital commit

This commit is contained in:
Chris's Razer Blade 2021-01-08 17:40:12 -05:00
parent d0803b933f
commit 1dad68ed79
11 changed files with 124 additions and 0 deletions

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

1
.idea/description.html Normal file
View File

@ -0,0 +1 @@
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>

6
.idea/encodings.xml Normal file
View 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>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="InfiniteLoopStatement" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>

9
.idea/misc.xml Normal file
View File

@ -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_14" default="true" project-jdk-name="14" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/untitled.iml" filepath="$PROJECT_DIR$/untitled.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,3 @@
<template>
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
</template>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

Binary file not shown.

71
src/com/company/Main.java Normal file
View File

@ -0,0 +1,71 @@
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
while (true) {
print("Enter first number: ");
String num1 = in.nextLine();
print("please enter second number");
String num2 = in.nextLine();
print("Inputs complete");
print("Please input operator");
print("+ , - , * or x , /");
String op = in.nextLine();
switch (op) {
case "+": {
int total = add(num1, num2);
System.out.println(total);
}
case "-": {
int total = sub(num1, num2);
System.out.println(total);
}
case "x": {
int total = mul(num1, num2);
System.out.println(total);
}
case "*": {
int total = mul(num1, num2);
System.out.println(total);
}
case "/": {
int total = div(num1, num2);
System.out.println(total);
}
default: print("Unexpected value: " + op + " ...restarting program");
}
}
}
private static void print(String text){
System.out.println(text);
}
private static int add(String num1, String num2){
int add1 = Integer.parseInt(num1);
int add2 = Integer.parseInt(num2);
return add1 + add2;
}
private static int sub(String num1, String num2){
int sub1 = Integer.parseInt(num1);
int sub2 = Integer.parseInt(num2);
return sub1 - sub2;
}
private static int mul(String num1, String num2){
int mul1 = Integer.parseInt(num1);
int mul2 = Integer.parseInt(num2);
return mul1 * mul2;
}
private static int div(String num1, String num2){
int div1 = Integer.parseInt(num1);
int div2 = Integer.parseInt(num2);
if (div2 == 0 || div1 == 0){
print("cant divide by zero");
return -1;
}
return div1 / div2;
}
}

11
untitled.iml Normal file
View File

@ -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>