hello i took this answer from you and i paid for this and it doesnt work please tell me what to do exactly.     import java.util.ArrayList; import java.util.Scanner; public class Main {     public static void main(String[] args) {         System.out.print("Enter an integer m: ");         Scanner input = new Scanner(System.in);         int m = input.nextInt();         ArrayList fact = new ArrayList<>();         getFact(m, fact);         int smSquare = smSquare(fact);         System.out.println("The smallest integer n for m * n to be a perfect square is " + smSquare);         System.out.println("m * n = " + (m * smSquare));     }     private static int smSquare(ArrayList fact) {         int[][] occurrences = copy(fact);         for (int i : fact) {             search(occurrences, i);         }         // remove duplicates and get odd sequence factors         ArrayList oddSequenceFactors = removeDup(occurrences);         // get smallest square by multiplying oddSequenceFactors         int smallestSquare = 1;         for (int i : oddSequenceFactors) {             smallestSquare *= i;         }         return smallestSquare;     }     private static ArrayList removeDup(int[][] m) {         ArrayList temp = new ArrayList<>();         for (int i = 0; i < m.length; i++) {             if (m[i][1] % 2 != 0) {                 temp.add(m[i][0]);             }         }         // removing duplicates         ArrayList dupRemoved = new ArrayList<>();         for (int i = 0; i < temp.size(); i++) {             if (!dupRemoved.contains(temp.get(i))) {                 dupRemoved.add(temp.get(i));             }         }         return dupRemoved;     }     private static void search(int[][] m, int number) {         for (int i = 0; i < m.length; i++) {             if (m[i][0] == number) {                 m[i][1]++;             }         }     }     private static int[][] copy(ArrayList fact) {         int[][] temp = new int[fact.size()][2];         for (int i = 0; i < temp.length; i++) {             temp[i][0] = fact.get(i);         }         return temp;     }     private static void getFact(int m, ArrayList fact) {         int count = 2;         while (count <= m) {             if (m % count == 0) {                 fact.add(count);                 m /= count;             } else {                 count++;             }         }     } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

hello i took this answer from you and i paid for this and it doesnt work please tell me what to do exactly.

 

 

import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        System.out.print("Enter an integer m: ");
        Scanner input = new Scanner(System.in);
        int m = input.nextInt();
        ArrayList<Integer> fact = new ArrayList<>();

        getFact(m, fact);

        int smSquare = smSquare(fact);
        System.out.println("The smallest integer n for m * n to be a perfect square is " + smSquare);
        System.out.println("m * n = " + (m * smSquare));
    }

    private static int smSquare(ArrayList<Integer> fact) {

        int[][] occurrences = copy(fact);
        for (int i : fact) {
            search(occurrences, i);
        }

        // remove duplicates and get odd sequence factors
        ArrayList<Integer> oddSequenceFactors = removeDup(occurrences);

        // get smallest square by multiplying oddSequenceFactors
        int smallestSquare = 1;
        for (int i : oddSequenceFactors) {
            smallestSquare *= i;
        }
        return smallestSquare;
    }

    private static ArrayList<Integer> removeDup(int[][] m) {
        ArrayList<Integer> temp = new ArrayList<>();

        for (int i = 0; i < m.length; i++) {
            if (m[i][1] % 2 != 0) {
                temp.add(m[i][0]);
            }
        }

        // removing duplicates
        ArrayList<Integer> dupRemoved = new ArrayList<>();
        for (int i = 0; i < temp.size(); i++) {

            if (!dupRemoved.contains(temp.get(i))) {
                dupRemoved.add(temp.get(i));
            }
        }

        return dupRemoved;
    }

    private static void search(int[][] m, int number) {
        for (int i = 0; i < m.length; i++) {
            if (m[i][0] == number) {
                m[i][1]++;
            }
        }
    }

    private static int[][] copy(ArrayList<Integer> fact) {

        int[][] temp = new int[fact.size()][2];

        for (int i = 0; i < temp.length; i++) {
            temp[i][0] = fact.get(i);
        }
        return temp;
    }

    private static void getFact(int m, ArrayList<Integer> fact) {

        int count = 2;
        while (count <= m) {
            if (m % count == 0) {
                fact.add(count);
                m /= count;
            } else {
                count++;
            }
        }
    }

}

 

 

 

 

 

Main.java
1- import java.util.ArrayList;
2 import java.util.Scanner;
3
4 public class Main {
5
6
7
8
9
10
11
12
13
14
15
HENDAAN~~*~~.
16
17
18
19
20
21
22
23
24
25
▶ Run → Debug
26
27
■ Stop
}
Share H Save
public static void main(String[] args) {
System.out.print("Enter an integer m: ");
Scanner input = new Scanner(System.in);
int m = input.nextInt ();
ArrayList< Integer> fact = new ArrayList<>();
getFact(m, fact);
int smSquare = smSquare (fact);
System.out.println("The smallest integer n for m*n to be a perfect square is " + smSquare);
System.out.println("m * n = " + (m * smSquare));
{} Beautify
search (occurrences, i);
Enter an integer m:
Ž
private static int smSquare(ArrayList<Integer> fact) {
int[][] occurrences = copy (fact);
for (int i fact) {
}
// remove duplicates and get odd sequence factors
ArrayList<Integer> oddSequenceFactors = removeDup(occurrences);
input
Language Java
Transcribed Image Text:Main.java 1- import java.util.ArrayList; 2 import java.util.Scanner; 3 4 public class Main { 5 6 7 8 9 10 11 12 13 14 15 HENDAAN~~*~~. 16 17 18 19 20 21 22 23 24 25 ▶ Run → Debug 26 27 ■ Stop } Share H Save public static void main(String[] args) { System.out.print("Enter an integer m: "); Scanner input = new Scanner(System.in); int m = input.nextInt (); ArrayList< Integer> fact = new ArrayList<>(); getFact(m, fact); int smSquare = smSquare (fact); System.out.println("The smallest integer n for m*n to be a perfect square is " + smSquare); System.out.println("m * n = " + (m * smSquare)); {} Beautify search (occurrences, i); Enter an integer m: Ž private static int smSquare(ArrayList<Integer> fact) { int[][] occurrences = copy (fact); for (int i fact) { } // remove duplicates and get odd sequence factors ArrayList<Integer> oddSequenceFactors = removeDup(occurrences); input Language Java
Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education