Hi Leute!
Ich hab einen Arbeitsauftrag bekommen der den Break Event Point einer Photovoltaikanlage berechnen soll. Soweit hab ich alles geschrieben, nur irgendwo sitzt ein Fehler der die ganze Berechnung am Ende versaut. Jedenfalls hab ich eine Beispielausgabe im Arbeitsauftrag, dort stimmen die Preise einfach nicht mit meiner Ausgabe zusammen. Kann mir einer sagen woran es liegt?
Beispielausgabe:
Number of solar modules: 1
Subsidy in % of the investment: 0
Direction of the photovoltaic system:
1: SOUTH
2: SOUTH-EAST
3: EAST
4: SOUTH-WEST
5: WEST
Please enter the direction: 4
Electricity rate in cents/kWh: 19
------
One module facing SOUTH-WEST.
Achievable total power: 0.38 kWp.
However, due to the suboptimal direction, only 0.36 kWp are achieved.
Investment of 259.99 leads to earnings of 61.26 each year.
After year 1: 198.73 still to compensate.
After year 2: 137.48 still to compensate.
After year 3: 76.22 still to compensate.
After year 4: 14.96 still to compensate.
PV system amortized within 5 years.
Bei mir kommt jedoch wenn ich genau das eingebe, das hier raus:
1 modules facing SOUTH-WEST
Achievable total power: 0,38 kWp.
However, due to the suboptimal direction, only 0,36 kWp are achieved.
Investment of 2,60 leads to earnings of 0,61 each year.
After year 1: 1,99 still to compensate.
After year 2: 1,37 still to compensate.
After year 3: 0,76 still to compensate.
After year 4: 0,15 still to compensate.
PV system amortized within 5 years.
Ich füge hier mal den Code ein und hoffe dass mir vielleicht jemand sagen kann was ich falsch gemacht hab?
Anscheinend is ja nur eine Kommastelle falsch... aber wo? hab schon etwas herumprobiert und komm nie zu dem vorgegeben Ergebnis.
Danke euch schonmal 😄
Ich hab einen Arbeitsauftrag bekommen der den Break Event Point einer Photovoltaikanlage berechnen soll. Soweit hab ich alles geschrieben, nur irgendwo sitzt ein Fehler der die ganze Berechnung am Ende versaut. Jedenfalls hab ich eine Beispielausgabe im Arbeitsauftrag, dort stimmen die Preise einfach nicht mit meiner Ausgabe zusammen. Kann mir einer sagen woran es liegt?
Beispielausgabe:
Number of solar modules: 1
Subsidy in % of the investment: 0
Direction of the photovoltaic system:
1: SOUTH
2: SOUTH-EAST
3: EAST
4: SOUTH-WEST
5: WEST
Please enter the direction: 4
Electricity rate in cents/kWh: 19
------
One module facing SOUTH-WEST.
Achievable total power: 0.38 kWp.
However, due to the suboptimal direction, only 0.36 kWp are achieved.
Investment of 259.99 leads to earnings of 61.26 each year.
After year 1: 198.73 still to compensate.
After year 2: 137.48 still to compensate.
After year 3: 76.22 still to compensate.
After year 4: 14.96 still to compensate.
PV system amortized within 5 years.
Bei mir kommt jedoch wenn ich genau das eingebe, das hier raus:
1 modules facing SOUTH-WEST
Achievable total power: 0,38 kWp.
However, due to the suboptimal direction, only 0,36 kWp are achieved.
Investment of 2,60 leads to earnings of 0,61 each year.
After year 1: 1,99 still to compensate.
After year 2: 1,37 still to compensate.
After year 3: 0,76 still to compensate.
After year 4: 0,15 still to compensate.
PV system amortized within 5 years.
Ich füge hier mal den Code ein und hoffe dass mir vielleicht jemand sagen kann was ich falsch gemacht hab?
Java:
public class PVAnlage {
public static void main(String[] args) {
Scanner user_input_scanner = new Scanner(System.in);
// Reads the following inputs
int modules = 0;
int investment = 0;
int direction = 0;
int electricityrate = 0;
// defines the variables
while(true){
System.out.println("Number of solar modules: ");
modules = user_input_scanner.nextInt();
if(modules > 80 || modules < 1){
System.out.println("Invalid input! The number of solar modules must be an integer greater than or equal to 1 and less than or equal to 80.");
}
else{
break;
}
}
// Loop that requires an input of the solar panels between 1-80
while(true){
System.out.println("Subsidy in % of the investment: ");
investment = user_input_scanner.nextInt();
if (investment > 100 || investment < 0) {
System.out.println("Invalid input! The subsidy must be an integer greater than or equal to 0 and less than or equal to 100.");
} else {
break;
}
}
// Loop requiring input of the State subsidies between 1-100 and repeating if the input is incorrect
while(true) {
System.out.println("Direction of the photovoltaic system:\n" +
"1: SOUTH\n" +
"2: SOUTH-EAST\n" +
"3: EAST\n" +
"4: SOUTH-WEST\n" +
"5: WEST\n" +
"Please enter the direction:");
direction = user_input_scanner.nextInt();
if (direction < 1 || direction > 5) {
System.out.println("Please enter the direction");
}
else{
break;}
}
// Loop that prompts the user to enter the direction of the solar panels until a valid input (between 1 and 5) is made.
while(true) {
System.out.println("Electricity rate in cents/kWh: ");
electricityrate = user_input_scanner.nextInt();
if (electricityrate < 1 || electricityrate > 100 ){
System.out.println("Invalid input! The electricity rate must be an integer which is at least 1 and must not exceed 100 cents/kWh.");
}
else{
break;}
}
// Loop that requires an input of the electricity rate and repeating if the input is incorrect
double totalPower = 0.375 * modules;
String directionString = "";
double performanceFactor = 1.0;
switch(direction) {
case 1: directionString = "SOUTH";
performanceFactor = 1.0;
break;
case 2: directionString = "SOUTH-EAST";
performanceFactor = 0.95;
break;
case 3: directionString = "EAST";
performanceFactor = 0.9;
break;
case 4: directionString = "SOUTH-WEST";
performanceFactor = 0.95;
break;
case 5: directionString = "WEST";
performanceFactor = 0.9;
break;
}
System.out.printf("%d modules facing %s%n", modules, directionString);
double achievedTotalPower = totalPower * performanceFactor;
// switch statement is a control flow statement that allows you to execute different blocks of code based on the value of an expression
// printf is used when the output need to be formatted (number with decimal places or embedding variables in a string). Without automatic line break.
// %d = integer
// %s = is replaced by the value of the variable
// %n = line break
System.out.printf("Achievable total power: %.2f kWp.%n", totalPower);
// %.2f = "f" is a placeholder for a floating-point number,"2" specifies that 2 decimal places should be displayed.
if (performanceFactor < 1.0) {
System.out.printf("However, due to the suboptimal direction, only %.2f kWp are achieved.%n", achievedTotalPower);
}
// Calculates the total power of the solar system based on the number of modules and their direction.
// Sets the performanceFactor based on direction.
// Outputs the total calculated power and adjusted power, based on direction.
double y_spez = 905; // specific yield in kWh/kWp
double annualYield = y_spez * achievedTotalPower;
double annualEarnings = annualYield * electricityrate / 100.0;
double totalCost = modules * 0.26;
double subsidyAmount = totalCost * investment / 100;
double costsAfterSubsidy = totalCost - subsidyAmount;
// Calculates the total cost of the solar system, the amount of government subsidies, and the costs after deduction of subsidies.
System.out.printf("Investment of %.2f leads to earnings of %.2f each year.%n", totalCost / 100, annualEarnings / 100);
double remainingCost = costsAfterSubsidy;
int year = 1;
while (remainingCost > 0) {
if (year == 1 && investment > 0) {
remainingCost -= subsidyAmount;
System.out.printf("After year %d: %.2f still to compensate. (%.2f paid by the government)%n", year, remainingCost / 100, subsidyAmount / 100);
} else {
remainingCost -= annualEarnings;
if (remainingCost > 0) {
System.out.printf("After year %d: %.2f still to compensate.%n", year, remainingCost / 100);
}
}
year++;
}
if (year == 2) {
System.out.println("PV system amortized within a year.");
} else {
System.out.printf("PV system amortized within %d years.%n", year - 1);
}
}
}
Danke euch schonmal 😄