Question
Turn this code into basic GUI with JTextfield and JTextarea for the input output. Also, screenshot the program how it works. I appreciate your help;
Turn this code into basic GUI with JTextfield and JTextarea for the input output. Also, screenshot the program how it works. I appreciate your help; thank you. Java language
Here's the context of the code.
import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.Set;
import javax.swing.JFrame; import javax.swing.JOptionPane;
public class Triplesum {
static int triplets(int[] a, int[] b, int[] c) {
int[] Adist = nodups(a); int[] Bdist = nodups(b); int[] Cdist = nodups(c);
int distinctTripletCount = 0;
Arrays.parallelSort(Adist); Arrays.parallelSort(Bdist); Arrays.parallelSort(Cdist);
for (int q : Bdist) { long c1 = getValidIndex(Adist, q) + 1; long c3 = getValidIndex(Cdist, q) + 1; distinctTripletCount += c1 * c3; } return distinctTripletCount; }
private static int [] nodups(int[] a) { Set
int result[] = new int [len]; int i = 0; for (int item : set) { result[i++] = item; } return result; }
static int getValidIndex(int[] distinctA, int key) { int low = 0; int high = distinctA.length - 1; int count = -1;
while (low
public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int lena = sc.nextInt(); int lenb = sc.nextInt(); int lenc = sc.nextInt();
int a[] = new int[lena]; int b[] = new int[lenb]; int c[] = new int[lenc];
for (int i = 0; i
JOptionPane.showMessageDialog(new JFrame(),answer);//System.out.println(answer); sc.close();
}
}
Given 3 arrays a, b, c of different sizes, find the number of distinct triplets (p, q, r) where pis an element of a, written as pea, q E b, and rec, satisfying the criteria: pr. For example, given a = [3, 5, 7], b = [3,6], and [4, 6, 9), we find four distinct triplets: (3, 6, 4), (3, 6, 6), (5, 6, 4), (5,6,6). C= Function Description Complete the triplets function in the editor below. It must return the number of distinct triplets that can be formed from the given arrays. triplets has the following parameter(s): a, b, c: three arrays of integers. Input Format The first line contains 3 integers lena, lenb, and lenc, the sizes of the three arrays. The next 3 lines contain space-separated integers numbering lena, lenb, and lenc Constraints 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started