Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws IOException {
- System.out.println("Enter number of variables:");
- numberOfBits = in.nextInt();
- System.out.println("Enter minterms in decimal <-1 to finish>:");
- while (true) {
- int input;
- input = in.nextInt();
- if (input == -1)
- break;
- minterms.add(input);
- }
- System.out.println("Enter don'tcares in decimal <-1 to finish>:");
- while (true) {
- int input;
- input = in.nextInt();
- if (input == -1)
- break;
- dontcares.add(input);
- }
- }
- fillArrayList();
- decimalToBinary();
- doComparisons();
- System.out.println("________________________________________________________________" + "\n");
- System.out.println("Grouping:");
- System.out.println();
- for (int k = 0; k < comparisons.size(); k++) {
- boolean comparisonHasElements = false;
- for (int i = 0; i < comparisons.get(k).size(); i++) {
- if (comparisons.get(k).get(i).isEmpty())
- continue;
- for (int j = 0; j < comparisons.get(k).get(i).size(); j++) {
- String binaryRepresentation = comparisons.get(k).get(i).get(j).split(" ", 2)[0];
- String numericRepresentation = comparisons.get(k).get(i).get(j).split(" ", 2)[1];
- System.out.println(binaryRepresentation + "\t" + "(" + numericRepresentation + ")");
- }
- comparisonHasElements = true;
- System.out.println("-----------------");
- }
- if (comparisonHasElements) {
- System.out.println("_________________" + "\n");
- }
- }
- if (minterms.isEmpty()==true)
- {
- System.out.println("Expression = 0");
- System.exit(0);
- }
- System.out.println("Prime Implicants:" + "\n");
- for (int i = 0; i < primeImplicants.size(); i++) {
- String binaryRepresentation = primeImplicants.get(i).split(" ", 2)[0];
- String numericRepresentation = primeImplicants.get(i).split(" ", 2)[1];
- System.out.println(binaryRepresentation + "\t" + "(" + numericRepresentation + ")");
- }
- System.out.println("\n" + "Expression:");
- System.out.println(findExpression(primeImplicants));
- System.out.println("_________________" + "\n");
- System.out.println("Coverage Table:");
- System.out.println();
- printCoverageTable();
- System.out.println("_________________" + "\n" + "\n" + "Essential Prime Implicants:" + "\n");
- countAppearances();
- if (containsOne()) {
- getReducedEssentialImplicants();
- if (!needsCombinations()) {
- for (int i = 1; i <= primeImplicants.size() && !foundCombination; i++)
- generateCombinations(1, 0, i);
- }
- else {
- for(int i=0; i<essentialPrimeImplicantsContainingOne.size(); i++) {
- String binaryRepresentation = essentialPrimeImplicantsContainingOne.get(i).split(" ",2)[0];
- String numericRepresentation = essentialPrimeImplicantsContainingOne.get(i).split(" ",2)[0];
- System.out.println(binaryRepresentation + "\t" + "(" + numericRepresentation + ")");
- }
- System.out.println("\n" + "Expression:");
- System.out.println(findExpression(essentialPrimeImplicantsContainingOne));
- }
- }
- else {
- for (int i = 1; i <= primeImplicants.size() && !foundCombination; i++)
- generateCombinations(1, 0, i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement