1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
umka2103 [35]
3 years ago
8

Design an algorithm for finding all the factors of a positive integer. For example, in the case of the integer 12, your algorith

m should report the values 1, 2, 3, 4, 6, and 12
Computers and Technology
1 answer:
Nadya [2.5K]3 years ago
3 0
As I say to every one requesting programming help on these forums. If you don't specify a language, then it just means you'll have to translate the answer that is given to you, to a different language. Here's what you want in Java:


<span>import java.util.InputMismatchException<span>;
</span>import java.util.Scanner<span>;
</span>
public class Test {
    public static void main(String[] args) {
        int number = numInput()<span>;
</span>        printFactors(Math.abs(number))<span>;
</span>    }

    private static int numInput() {
        Scanner sc = new Scanner(System.in)<span>;
</span>
        System.out.print("Enter number: ")<span>;
</span>
        int input<span>;
</span>        while (true) {
            try {
                input = sc.nextInt()<span>;
</span><span>                break;
</span>            } catch (InputMismatchException e) {
                System.out.println("Not a number.")<span>;
</span>            }
        }

        return input<span>;
</span>    }

    private static void printFactors(int number) {
        if (number == 0) {
            System.out.println("Infinite factors.")<span>;
</span>        } else {
            for (int i = 1; i <= number; i++) {
                for (int j = 1; j <= number; j++) {
                    if (i * j == number) {
                        System.out.print(i + ", ")<span>;
</span>                    }
                }
            }
        }
    }
}</span>
You might be interested in
Investigations involving the preservation, identification, extraction, documentation, and interpretation of computer media for e
Goryan [66]

Answer:

The correct answer to the following question will be "Digital Forensics".

Explanation:

  • Digital forensics is a field of forensics that involves the analysis and retrieval of materials found in electronic devices, sometimes related to cybercrime.
  • The objective of digital forensics methodologies would be to check, maintain and evaluate evidence on computing systems to find possible evidence for a trial. In the initial days of computing, an individual investigator could process files because the power consumption was so small.

Therefore, Digital Forensic is the right answer.

7 0
4 years ago
how write a program to prompt the user for hours and rate per hour using input to computer gross pay Use 35 hours and rate2.75 p
Juli2301 [7.4K]

Answer:

Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Use 35 hours and a rate of 2.75 per hour to test the program (the pay should be 96.25). You should use input to read a string and float() to convert the string to a number. ... #compute gross pay bye hours and rate per hour.

Explanation:

3 0
4 years ago
Emily created her company's first newsletter. She made sure to repeat design elements such as color schemes and
max2010maxim [7]

Answer:

Her goal was to Provide consistency

Explanation:

i dont rly have one

8 0
3 years ago
Which type of operating system is usually used in personal computers?
joja [24]

Answer:

Microsoft Windows

Explanation:

7 0
3 years ago
Read 2 more answers
Please help on both of these questions will give brainliest<br> !!
Alja [10]

I think the first one is All of the above

3 0
3 years ago
Read 2 more answers
Other questions:
  • An organization’s IRP prioritizes containment over eradication. An incident has been discovered where an attacker outside of the
    5·1 answer
  • Which mistakes are NOT highlighted by the spell checker in a word-processing document?
    15·1 answer
  • Should i change my profile pic<br> dont delete
    15·2 answers
  • You need to transmit PII via email and you want to maintain its confidentiality. Which of the following choices is the BEST solu
    8·1 answer
  • What are the correct steps to find the system specifications such as the amount of RAM or system type?
    13·1 answer
  • In the ____ letter style, all components of the letter begin flush with the left margin.
    5·1 answer
  • Public classes are accessible by all objects, which means that public classes can be ____, or used as a basis for any other clas
    10·2 answers
  • Can someone answer this for me will award brainliest lol
    11·2 answers
  • ¿Por qué en Colombia la mayoría de las empresas no son automatizadas (manejadas por computadoras y robots?
    15·1 answer
  • In java language I want the code
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!