I don't know what changes I've made lol

This commit is contained in:
2022-11-01 14:30:06 -05:00
parent 8d1ef61699
commit 9a1bc9cfb5
26 changed files with 1013 additions and 3 deletions

10
LAB-4/.classpath Normal file
View 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>

17
LAB-4/.project Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LAB-4</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>

View File

@@ -0,0 +1,9 @@
/**
*
*/
/**
* @author brett
*
*/
module uwstout.courses.cs144 {
}

View File

@@ -0,0 +1,70 @@
package uwstout.courses.cs144.labs.lab4;
import java.text.DecimalFormat;
/**
* An expression formatter
*
* @author Brett Bender
* @version 2022.10.10
*
*/
public class ExpFormat {
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.##");
private int x;
private int y;
private double result;
/**
* An expression formatter
*
* @param ix The X value
* @param iy The Y value
* @param iresult The result
*/
public ExpFormat(int ix, int iy, double iresult) {
x = ix;
y = iy;
result = iresult;
}
/**
* Get the X value of the expression
*
* @return The X value
*/
public int getX() {
return x;
}
/**
* Get the Y value of the expression
*
* @return The Y value
*/
public int getY() {
return y;
}
/**
* Get the result of the expression
*
* @return The result
*/
public double getResult() {
return result;
}
@Override
public String toString() {
String reString = "";
reString += x + " * " + y + " + 2\n";
reString += "----------\n";
reString += x + "^2 + 1\n";
reString += "= " + DECIMAL_FORMAT.format(result);
return reString;
}
}

View File

@@ -0,0 +1,51 @@
package uwstout.courses.cs144.labs.lab4;
import java.util.Scanner;
/**
* Calculates (xy + 2)/(x^2 + 1) with the values entered by the end user.
*
* @author Brett Bender
* @version 2022.10.10
*/
public class Expression {
/**
* Calculates (xy + 2)/(x^2 + 1) with the values entered by the end user. It
* then prints out a formatted version of the expression and result
*
* TESTS
*
* IN1: [1, 1] OUT1: [1.5]
*
* IN2: [1, 0] OUT2: [1]
*
* IN3: [0, 1] OUT3: [2]
*
* IN4: [-1, -1] OUT4: [1.5]
*
* @param args Command line arguments, not used
*/
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
// Read Inputs
/// Read X
System.out.print("Enter the x value: ");
int x = scan.nextInt();
/// Read Y
System.out.print("Enter the y value: ");
int y = scan.nextInt();
// Calculate: (xy + 2)/(x^2 + 1)
double result = ((x * y) + 2) / (Math.pow(x, 2) + 1);
// Format & Print
ExpFormat ef = new ExpFormat(x, y, result);
System.out.println("\n" + ef);
scan.close();
}
}

View File

@@ -0,0 +1,68 @@
package uwstout.courses.cs144.labs.lab4;
import java.text.NumberFormat;
import java.util.Scanner;
/**
* Calculates the fabrication cost for a number of units, the cost per unit, and
* a mark-up. This automatically includes a constant setup cost
*
* @author Brett Bender
* @version 2022.10.10
*
*/
public class FabricationCost {
private static final double SETUP_COST = 3575.95;
/**
* Calculates the fabrication cost for a number of units, the cost per unit, and
* a mark-up. This automatically includes a constant setup cost
*
*
* TESTS
*
* IN1: [5, 5.00, 0.5] OUT1: [5, $5.00, 50%, $3,613.45]
*
* IN2: [-1, -1.0, 0.0] OUT2: [1, $1.00, 0%, $3,756.95]
*
* IN3: [0, 0.0, 0.0] OUT3: [0, 0.00, 0%, $3,575.95]
*
* IN4: [10, 2.75, -0.15]: [10, $2.75, -15%, $3,599.32]
*
* @param args Command line arguments (not used)
*/
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
// Read Units
System.out.print("Enter the number of units: ");
int units = Math.abs(scan.nextInt());
// Read Cost Per Unit
System.out.print("Enter the cost per unit: $");
double costPerUnit = Math.abs(scan.nextDouble());
// Red Percent Mark-up
System.out.print("Enter the percent markup: ");
double percentMarkup = scan.nextDouble();
// Calculate
/// Initial calculation of units x cost per unit
double totalCost = units * costPerUnit;
/// Add the mark-up
totalCost += totalCost * percentMarkup;
/// Add the setup cost
totalCost += SETUP_COST;
// Output Units, Cost per unit, percent mark-up, and computed value
System.out.println("Units: " + units);
System.out.println("Cost Per: " + NumberFormat.getCurrencyInstance().format(costPerUnit));
System.out.println("Markup: " + NumberFormat.getPercentInstance().format(percentMarkup));
System.out.println("Total Cost: " + NumberFormat.getCurrencyInstance().format(totalCost));
scan.close();
}
}