Untitled
unknown
java
3 years ago
888 B
9
Indexable
// Check if transactions are correct
int transactionsSum = 0;
for (int i = 0; i < transactions.size(); i++) {
// Kui mõni tehing ületas tunnilimiiti
if (Math.abs(transactions.get(i)) > hourLimit) {
throw new IllegalArgumentException("Sold or bought more than the hour limit");
} else {
// Liida kõik tehingud kokku
transactionsSum = transactionsSum + transactions.get(i);
if (transactionsSum > capacitance) {
throw new IllegalArgumentException("Exceeded the capacitance");
}
if (transactionsSum < 0) {
throw new IllegalArgumentException("Sold more than you have");
}
}
}
System.out.println("Tehingute kogusumma: " + transactionsSum);Editor is loading...