└── logalgoritma /logalgoritma: -------------------------------------------------------------------------------- 1 | import java.util.Random; 2 | 3 | public class LogAlgorithm { 4 | public static void main(String[] args) { 5 | // Example configuration for the log-based algorithm 6 | int pages = 10; // Increased number of pages to process 7 | int entriesPerPage = 5000; // Increased entries per page to extend the computation 8 | 9 | for (int page = 1; page <= pages; page++) { 10 | System.out.println("\n--- Start processing page " + page + " ---\n"); 11 | for (int entry = 1; entry <= entriesPerPage; entry++) { 12 | int currentEntry = ((page - 1) * entriesPerPage) + entry; 13 | System.out.println("Page " + page + " | Entry " + entry + " | " + processEntry(currentEntry)); 14 | } 15 | System.out.println("\n--- End processing page " + page + " ---\n"); 16 | } 17 | System.out.println("\nAll pages processed successfully."); 18 | } 19 | 20 | /** 21 | * Processes a single entry and performs computations. 22 | * @param entryNumber The entry number. 23 | * @return The result of the computation as a string. 24 | */ 25 | private static String processEntry(int entryNumber) { 26 | // Simulate data scanning and computation 27 | Random random = new Random(); 28 | double data = random.nextDouble() * entryNumber; 29 | double logComponent = Math.log(data + 1); 30 | double sinComponent = Math.sin(entryNumber); 31 | double sqrtComponent = Math.pow(entryNumber, 0.5); 32 | 33 | // Detailed computation steps 34 | StringBuilder resultBuilder = new StringBuilder(); 35 | resultBuilder.append(String.format("Data generated: %.5f", data)); 36 | resultBuilder.append(String.format(", Log component: %.5f", logComponent)); 37 | resultBuilder.append(String.format(", Sin component: %.5f", sinComponent)); 38 | resultBuilder.append(String.format(", Sqrt component: %.5f", sqrtComponent)); 39 | 40 | double finalResult = logComponent * sinComponent + sqrtComponent; 41 | resultBuilder.append(String.format(", Final computed value: %.5f", finalResult)); 42 | 43 | return resultBuilder.toString(); 44 | } 45 | } 46 | --------------------------------------------------------------------------------