NAMA : MUHAMMAD HELGA YUDHI MIQAILLA
NIM : 225150701111017
PRODI : TEKNOLOGI INFORMASI
CODE 1
import [Link].*;
public class ATM {
public static void main(String[] args) {
Scanner input = new Scanner([Link]);
int choice;
int id;
Account[] accounts = new Account[10];
for (int i = 0; i < [Link]; i++) {
accounts[i] = new Account(i, 100);
}
while (true) {
do {
[Link]("Enter an account id: ");
id = [Link]();
if (id < 0 || id > 9) {
[Link]("Invalid account id. Please try again.");
}
}while(id > 9);
do {
[Link]("\nMain menu");
[Link]("1: Check balance");
[Link]("2: Withdraw");
[Link]("3: Deposit");
[Link]("4: Exit");
[Link]("Enter a choice: ");
choice = [Link]();
if (choice == 1) {
[Link]("The balance is " + accounts[id].getBalance());
} else if (choice == 2) {
[Link]("Enter the amount to withdraw: ");
double amount = [Link]();
if (amount < accounts[id].getBalance()) {
accounts[id].withdraw(amount);
[Link]("Withdrawal successful");
} else {
[Link]("Insufficient funds");
}
} else if (choice == 3) {
[Link]("Enter the amount to deposit: ");
double amount = [Link]();
accounts[id].deposit(amount);
[Link]("Deposit successful");
} else if (choice == 4) {
break;
} else {
[Link]("Invalid choice");
}
} while (choice < 4 );
[Link]("\nTransaction complete.\n");
}
}
}
OUTPUT
CODE 2
import [Link];
public class Square {
public static void main(String[] args) {
BigInteger maxLong = [Link](Long.MAX_VALUE);
BigInteger n = sqrt(maxLong).add([Link]);
for (int i = 0; i < 10; i++) {
BigInteger square = [Link](n);
[Link](square);
n = [Link]([Link]);
}
}
public static BigInteger sqrt(BigInteger n) {
BigInteger a = [Link];
BigInteger b = [Link](5).add([Link](8));
while ([Link](a) >= 0) {
BigInteger mid = [Link](b).shiftRight(1);
if ([Link](mid).compareTo(n) > 0) {
b = [Link]([Link]);
} else {
a = [Link]([Link]);
}
}
return [Link]([Link]);
}
}
OUTPUT 2