Answer:
Explanation:
Code:
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class Knapsack {
public static void knapsack(int wk[], int pr[], int W, String ofile) throws IOException
{
int i, w;
int[][] Ksack = new int[wk.length + 1][W + 1];
for (i = 0; i <= wk.length; i++) {
for (w = 0; w <= W; w++) {
if (i == 0 || w == 0)
Ksack[i][w] = 0;
else if (wk[i - 1] <= w)
Ksack[i][w] = Math.max(pr[i - 1] + Ksack[i - 1][w - wk[i - 1]], Ksack[i - 1][w]);
else
Ksack[i][w] = Ksack[i - 1][w];
}
}
int maxProfit = Ksack[wk.length][W];
int tempProfit = maxProfit;
int count = 0;
w = W;
int[] projectIncluded = new int[1000];
for (i = wk.length; i > 0 && tempProfit > 0; i--) {
if (tempProfit == Ksack[i - 1][w])
continue;
else {
projectIncluded[count++] = i-1;
tempProfit = tempProfit - pr[i - 1];
w = w - wk[i - 1];
}
FileWriter f =new FileWriter("C:\\Users\\gshubhita\\Desktop\\"+ ofile);
f.write("Number of projects available: "+ wk.length+ "\r\n");
f.write("Available employee work weeks: "+ W + "\r\n");
f.write("Number of projects chosen: "+ count + "\r\n");
f.write("Total profit: "+ maxProfit + "\r\n");
for (int j = 0; j < count; j++)
f.write("\nProject"+ projectIncluded[j] +" " +wk[projectIncluded[j]]+ " "+ pr[projectIncluded[j]] + "\r\n");
f.close();
}
}
public static void main(String[] args) throws Exception
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of available employee work weeks: ");
int avbWeeks = sc.nextInt();
System.out.print("Enter the name of input file: ");
String inputFile = sc.next();
System.out.print("Enter the name of output file: ");
String outputFile = sc.next();
System.out.print("Number of projects = ");
int projects = sc.nextInt();
int[] workWeeks = new int[projects];
int[] profit = new int[projects];
File file = new File("C:\\Users\\gshubhita\\Desktop\\" + inputFile);
Scanner fl = new Scanner(file);
int count = 0;
while (fl.hasNextLine()){
String line = fl.nextLine();
String[] x = line.split(" ");
workWeeks[count] = Integer.parseInt(x[1]);
profit[count] = Integer.parseInt(x[2]);
count++;
}
knapsack(workWeeks, profit, avbWeeks, outputFile);
}
}
Console Output:
Enter the number of available employee work weeks: 10
Enter the name of input file: input.txt
Enter the name of output file: output.txt
Number of projects = 4
Output.txt:
Number of projects available: 4
Available employee work weeks: 10
Number of projects chosen: 2
Total profit: 46
Project2 4 16
Project0 6 30
Determine the temperature at the center plane of the brass plate after 3 minutes of cooling.
Answer:
809.98°C
Explanation:
STEP ONE: The first step to take in order to solve this particular Question or problem is to find or determine the Biot value.
Biot value = (heat transfer coefficient × length) ÷ thermal conductivity.
Biot value = (220 × 0.1)÷ 110 = 0.2.
Biot value = 0.2.
STEP TWO: Determine the Fourier number. Since the Biot value is greater than 0.1. Tis can be done by making use of the formula below;
Fourier number = thermal diffusivity × time ÷ (length)^2.
Fourier number = (3 × 60 × 33.9 × 10^-6)/( 0.1)^2 = 0.6102.
STEP THREE: This is the last step for the question, here we will be calculating the temperature of the center plane of the brass plate after 3 minutes.
Thus, the temperature of the center plane of the brass plane after 3 minutes = (1.00705) (0.89199) (900- 15) + 15.
= > the temperature of the center plane of the brass plane after 3 minutes = 809.98°C.
Answer:
The solution code is as follows:
Explanation:
Firstly, we initialize a 10-elements array, myArray (Line 7) with no values.
Next, we create a for-loop (Line 10). Within the loop, we prompt user to enter an integer and assign the input value to the current element of myArray (Line 12-13).
Answer:
Volume of aeration tank = 1.29 x 10^4 m³
Explanation:
Food/Micro- organism Ratio = 0.2/day
Feed Rate (Q) = 0.438 m³/s
Influent BOD = 150 mg/L
MLVSS = 2200 mg/L
The above mentioned parameters are related by the equation
F/M = QS₀/VX
where S₀ is the influent BOD and X is the cell concentration, with V being the Volume of the tank. Re- arranging the above equation for V and putting the values in, we get
V = 0.4380 x 150/0.2 x 2200
V = 0.1493 (m³/s) x day
V = 0.1493 x 24 x 60 x 60
V = 1.29 x 10^4 m³
b. The change in diameter of the specimen. Indicate an increase in diameter with a positive number and a decrease with a negative number.
Answer:
1)ΔL = 0.616 mm
2)Δd = 0.00194 mm
Explanation:
We are given;
Force; F = 52900 N
Initial length; L_o = 207 mm = 0.207 m
Diameter; d_o = 19.2 mm = 0.0192 m
Elastic modulus; E = 61.4 GPa = 61.4 × 10^(9) N/m²
Now, from Hooke's law;
E = σ/ε
Where; σ is stress = force/area = F/A
A = πd²/4 = π × 0.0192²/4
A = 0.00009216π
σ = 52900/0.00009216π
ε = ΔL/L_o
ε = ΔL/0.207
Thus,from E = σ/ε, we have;
61.4 × 10^(9) = (52900/0.00009216π) ÷ (ΔL/0.207)
Making ΔL the subject, we have;
ΔL = (52900 × 0.207)/(61.4 × 10^(9) × 0.00009216π)
ΔL = 0.616 × 10^(-3) m
ΔL = 0.616 mm
B) Poisson's ratio is given as;
υ = ε_x/ε_z
ε_x = Δd/d_o
ε_z = ΔL/L_o
Thus;
υ = (Δd/d_o) ÷ (ΔL/L_o)
Making Δd the subject gives;
Δd = (υ × d_o × ΔL)/L_o
We are given Poisson's ratio to be 0.34.
Thus;
Δd = (0.34 × 19.2 × 0.616)/207
Δd = 0.00194 mm
193GPa, a = 17x10^-6/°C) carriage bolts of the clamp each have a diameter of 10mm, and they hold
the cylinder snug with a negligible force against the rigid jaws, determine the temperature at which
the average normal stress in either the magnesium or steel becomes 12 MPa.
Answer:
......................
Explanation:
Answer:
I = Line Current = 242.58 A
Q = Reactive Power = 41.5 kVAr
Explanation:
Firstly, converting 100 hp to kW.
Since, 1 hp = 0.746 kW,
100 hp = 0.746 kW x 100
100 hp = 74.6 kW
The power of a three phase induction motor can be given as:
where,
P in = Input Power required by the motor
V = Line Voltage
I = Line Current
Cosα = Power Factor
Now, calculating Pin:
a) Calculating the line current:
b) Calculating Reactive Power:
The reactive power can be calculated as:
Q = P tanα
where,
Q = Reactive power
P = Active Power
α = power factor angle
Since,
Therefore,