initial commit
This commit is contained in:
10
LAB-2/.classpath
Normal file
10
LAB-2/.classpath
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
LAB-2/.gitignore
vendored
Normal file
1
LAB-2/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
LAB-2/.project
Normal file
17
LAB-2/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>LAB-2</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
2
LAB-2/.settings/org.eclipse.core.resources.prefs
Normal file
2
LAB-2/.settings/org.eclipse.core.resources.prefs
Normal file
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
14
LAB-2/.settings/org.eclipse.jdt.core.prefs
Normal file
14
LAB-2/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,14 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=17
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=17
|
||||
BIN
LAB-2/Lab2.zip
Normal file
BIN
LAB-2/Lab2.zip
Normal file
Binary file not shown.
3
LAB-2/src/module-info.java
Normal file
3
LAB-2/src/module-info.java
Normal file
@@ -0,0 +1,3 @@
|
||||
module uwstout.courses.cs144 {
|
||||
|
||||
}
|
||||
27
LAB-2/src/uwstout/courses/cs144/labs/lab2/MessageOutput.java
Normal file
27
LAB-2/src/uwstout/courses/cs144/labs/lab2/MessageOutput.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package uwstout.courses.cs144.labs.lab2;
|
||||
|
||||
/**
|
||||
* This outputs a message that tests your ability to escape strings.
|
||||
*
|
||||
* @author Brett Bender
|
||||
* @version 2022.09.20
|
||||
*
|
||||
*/
|
||||
public class MessageOutput {
|
||||
|
||||
/**
|
||||
* This outputs a message that tests your ability to escape strings.
|
||||
*
|
||||
* @param args The command line arguments (not used)
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println("\tIn Windows, putting the path to a file into the code is a little");
|
||||
System.out.println("difficult as each \"\\\" in the path must be escaped. So, if your");
|
||||
System.out.println("file is located at C:\\temp\\data.csv, then you would need to");
|
||||
System.out.println("escape it so that it looks like C:\\\\temp\\\\data.csv. It is also");
|
||||
System.out.println("good practice to put \"'s around the path. This avoids problems");
|
||||
System.out.println("with spaces in the file name or the path. The \"'s would have");
|
||||
System.out.println("to be escaped as well.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package uwstout.courses.cs144.labs.lab2;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* This computes the area and perimeter of a rectangle given the rectangle's
|
||||
* length and width.
|
||||
*
|
||||
* @author turners
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public class RectangleValues {
|
||||
|
||||
/**
|
||||
* This computes the area and perimeter of a rectangle given the rectangle's
|
||||
* length and width.
|
||||
*
|
||||
*
|
||||
* @param args Command line arguments (not used)
|
||||
*
|
||||
*
|
||||
* Input: (length: 10, width: 10) Expected: (perim: 40, area: 100)
|
||||
*
|
||||
* Input: (length: 0, width: 9) Expected: (perim: 18, area: 0)
|
||||
*
|
||||
* Input: (length: -2, width: 4) Expected: (perim: 4, area: -8)
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
double length;
|
||||
double width;
|
||||
double perimeter;
|
||||
double area;
|
||||
|
||||
// Create an object to read in data from the keyboard
|
||||
Scanner scan = new Scanner(System.in);
|
||||
// prompt for and read in length and width
|
||||
System.out.println("Enter the length of the rectangle: ");
|
||||
length = scan.nextDouble();
|
||||
|
||||
System.out.println("Enter the width of the rectangle: ");
|
||||
width = scan.nextDouble();
|
||||
|
||||
// compute perimeter and area
|
||||
perimeter = 2 * (length + width);
|
||||
area = length * width;
|
||||
|
||||
// output results
|
||||
System.out.println("For a " + length + " x " + width + " rectangle, the perimeter is " + perimeter
|
||||
+ " and the area is " + area + ".");
|
||||
|
||||
scan.close();
|
||||
}
|
||||
}
|
||||
46
LAB-2/src/uwstout/courses/cs144/labs/lab2/Stones.java
Normal file
46
LAB-2/src/uwstout/courses/cs144/labs/lab2/Stones.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package uwstout.courses.cs144.labs.lab2;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Reads in a value (in stones) and converts it to ounces.
|
||||
*
|
||||
* @author Brett Bender
|
||||
* @version 2022.09.20
|
||||
*/
|
||||
public class Stones {
|
||||
|
||||
private static final int STONE_POUNDS_CF = 14;
|
||||
private static final int POUNDS_OUNCES_CF = 16;
|
||||
private static final int STONE_OUNCES_CF = STONE_POUNDS_CF * POUNDS_OUNCES_CF;
|
||||
|
||||
/**
|
||||
* Reads in a value (in stones) and converts it to ounces.
|
||||
*
|
||||
* @param args Command line arguments (not used)
|
||||
*
|
||||
*
|
||||
* Input: 2 stones Expected: 448 ounces
|
||||
*
|
||||
* Input: -1 stones Expected: -224 ounces
|
||||
*
|
||||
* Input: 0 stones Expected: 0 ounces
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
System.out.println("How heavy is the object in stones?");
|
||||
|
||||
// Read in the weight in stones
|
||||
int stonesIn = scan.nextInt();
|
||||
|
||||
// Calculate the weight in ounces
|
||||
int ouncesOut = stonesIn * STONE_OUNCES_CF;
|
||||
|
||||
// Output it to the user
|
||||
System.out.printf("%d stones in ounces is %d ounces.\n", stonesIn, ouncesOut);
|
||||
|
||||
scan.close();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user