Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/main/java/ip/syssrc/array/CountEach.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ip.syssrc.array;

/**
* CountEach
*
* Assignment 3.1
*
* @author H071171512 - Fitrah Muhammad <[email protected]>
*
*/

public class CountEach {

public static void main(String[] args) {

}
}
16 changes: 16 additions & 0 deletions src/main/java/ip/syssrc/array/RadixConverter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ip.syssrc.array;

/**
* RadixConverter
*
* Assignment 3.2
*
* @author H071171512 - Fitrah Muhammad <[email protected]>
*
*/
public class RadixConverter {

public static void main(String[] args) {

}
}
20 changes: 20 additions & 0 deletions src/main/java/ip/syssrc/array/SumOneThird.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ip.syssrc.array;

/**
* SumOneThird
*
* Assignment 3.3
*
* @author H071171512 - Fitrah Muhammad <[email protected]>
*
*/
public class SumOneThird {

public static void main(String[] args) {
int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

for (int index = 0; index < (arr.length / 3); index++) {
// Your magic is here
}
}
}
4 changes: 4 additions & 0 deletions src/main/java/ip/syssrc/conditional/Cashier.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ip.syssrc.conditional;

import java.util.Scanner;

/**
* Cashier
*
Expand All @@ -11,6 +13,8 @@
public class Cashier {

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);

scan.close();
}
}
97 changes: 97 additions & 0 deletions src/main/java/ip/syssrc/conditional/CashierSolution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package ip.syssrc.conditional;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
* Cashier
*
* Assignment 1.1
*
* @author H071171512 - Fitrah Muhammad <[email protected]>
*
*/
public class CashierSolution {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);
int price = 0;
int payment = 0;

try {
System.out.print("Berapa total harga belanja anda ? ");
price = scan.nextInt();
System.out.print("Berapa total uang yang anda bayarkan ? ");
payment = scan.nextInt();
} catch (InputMismatchException e) {
System.out.println("Maaf, pastikan inputan anda adalah angka");
scan.close();
return;
} finally {
scan.close();
}

if (payment < price) {
System.out.println("Maaf, pembayaran anda belum mencukupi\n");
return;
}

if (payment == price) {
System.out.println("Terima kasih telah membayar dengan uang pas\n");
return;
}

int change = payment - price;

System.out.printf("\nTotal kembalian anda: Rp %d\n", change);
System.out.println("Dengan rincian sebagai berikut:\n");

if (change >= 100_000) {
System.out.printf("%d lembar uang Rp. 100.000\n", change / 100_000);
change %= 100_000;
}
if (change >= 50_000) {
System.out.printf("%d lembar uang Rp. 50.000\n", change / 50_000);
change %= 50_000;
}
if (change >= 20_000) {
System.out.printf("%d lembar uang Rp. 20.000\n", change / 20_000);
change %= 20_000;
}
if (change >= 10_000) {
System.out.printf("%d lembar uang Rp. 10.000\n", change / 10_000);
change %= 10_000;
}
if (change >= 5_000) {
System.out.printf("%d lembar uang Rp. 5.000\n", change / 5_000);
change %= 5_000;
}
if (change >= 2_000) {
System.out.printf("%d lembar uang Rp. 2.000\n", change / 2_000);
change %= 2_000;
}
if (change >= 1_000) {
System.out.printf("%d lembar uang Rp. 1.000\n", change / 1_000);
change %= 1_000;
}
if (change >= 500) {
System.out.printf("%d buah uang Rp. 500\n", change / 500);
change %= 500;
}
if (change >= 200) {
System.out.printf("%d buah uang Rp. 200\n", change / 200);
change %= 200;
}
if (change >= 100) {
System.out.printf("%d buah uang Rp. 100\n", change / 100);
change %= 100;
}

if (change > 0) {
System.out.printf("Dan sebanyak Rp. %d didonasikan\n", change);
}

System.out.println();
}
}
64 changes: 64 additions & 0 deletions src/main/java/ip/syssrc/conditional/RoleAccessSolution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package ip.syssrc.conditional;

/**
* RoleAccess
*
* Assignment 1.2
*
* @author H071171512 - Fitrah Muhammad <[email protected]>
*
*/
public class RoleAccessSolution {

public static void main(String[] args) {

int menuIndex = 0;
int subMenuIndex = 0;
boolean isValidRole = false;

if (args.length == 0) {
System.out.println("What role you want to see ?");
System.out.println("For example, try 'Admin'.");
return;
}

if (args.length > 1) {
System.out.println("Too many argument");
return;
}

switch (args[0]) {
case "Super Admin":
case "Admin":
case "User":
isValidRole = !isValidRole;
break;
}

if (!isValidRole) {
System.out.println("Invalid Role");
System.out.println("Valid Role : Super Admin, Admin, User");
return;
}

switch (args[0]) {
case "Super Admin":
System.out.printf("%d. Super Admin\n", ++menuIndex);
System.out.printf("%2d.%d. CRUD Super Admin\n", menuIndex, ++subMenuIndex);
System.out.printf("%2d.%d. CRUD Admin\n", menuIndex, ++subMenuIndex);
System.out.printf("%2d.%d. CRUD User\n\n", menuIndex, ++subMenuIndex);
subMenuIndex = 0;
case "Admin":
System.out.printf("%d. Admin\n", ++menuIndex);
System.out.printf("%2d.%d. CRUD Admin\n", menuIndex, ++subMenuIndex);
System.out.printf("%2d.%d. CRUD User\n\n", menuIndex, ++subMenuIndex);
subMenuIndex = 0;
default:
System.out.printf("%d. User\n", ++menuIndex);
System.out.printf("%2d.%d. View\n", menuIndex, ++subMenuIndex);
System.out.printf("%2d.%d. Edit\n", menuIndex, ++subMenuIndex);
subMenuIndex = 0;
}

}
}