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
Orlov [11]
3 years ago
12

Sum of Primes JAVA project

Computers and Technology
1 answer:
vitfil [10]3 years ago
4 0

Answer:

Explanation:

The following code is written in Java and creates the necessary code so that two int inputs are read and looped through all the numbers between them to find all the primes. These primes are counted and summed. Finally, printing out the sum and the number of primes found to the console.

import java.util.ArrayList;

import java.util.Scanner;

class SumPrimes{

   public static void main(final String[] args) {

       Scanner in = new Scanner(System.in);

           ArrayList<Integer> primes = new ArrayList<>();

           int num1, num2, numPrime = 0;

           System.out.println("Enter number 1:");

           num1 = in.nextInt();

           System.out.println("Enter number 2:");

           num2 = in.nextInt();

           for (int x = num1; x <= num2; x++) {

               if (isPrime(x) == true) {

                   primes.add(x);

                   numPrime += 1;

               }

           }

           System.out.println("There are " + numPrime + " primes in the array.");

       System.out.println("Their sum is " + sumArray(primes));

}

   public static int sumArray(ArrayList<Integer> arr) {

       int sum = 0;

       for (int x: arr) {

           sum += x;

       }

       return sum;

   }

   static boolean isPrime(int n) {

       if (n <= 1)

           return false;

       for (int i = 2; i < n; i++)

           if (n % i == 0)

               return false;

       return true;

   }

}

You might be interested in
Malcolm is part of a team developing a new smartphone app to track traffic patterns. Because team members are located throughout
Umnica [9.8K]

Answer:

Virtual team

Explanation:

A virtual team is also known as a remote team, where every member of the team is working from different geographic locations. Usually, the communication channel is through voice/video conferencing or email.

Each member of the team is given unique roles and these roles are delivered optimally within the specified time frame.

For instance, Malcolm does not meet with other members of the team, yet they are working on a project (a smartphone app to track traffic patterns). Following standards that would have applied if they were working at a specific location.

Thanks to Information and Communication Technology (ICT), virtual jobs are on the increase, providing jobs to a lot of people not minding their geographic location.

7 0
3 years ago
window operating system popularly known as. 1) character user interface. 2) computer user interface. 3) graphic user interface.
fredd [130]

Answer:

The window operating system is popularly known as a graphical user interface(GUI)

Explanation:

older operating systems were command line based but window uses a gui

5 0
3 years ago
Jeremy is designing a website for a florist. He intends to discuss the web design with his client. Which tool should Jeremy use
stiv31 [10]

Answer:

C.  layout of each page with its respective elements

Explanation:

A layout  of each page with its respective elements will give the client a good idea of the final product and help him confirm his desires/requests towards the creation of the Web site.  Most people are visual, especially about things they don't fully understand, so a clear and visual representation is best.

<u>A. Bulleted lists and titles</u>... won't give the idea of the full layout of the Web site.

<u>B. chart depicting</u>....  that's more a tool for the programmer than the client, although user flow is important, it isn't as much as the visual aspect of each page.

<u>D. pictures and screenshots of websites of other florists..</u>. That could be a useful aid on the first contact, but the question implied the Web site is already in progress... so that wouldn't help much.

<u>E.  programming code for the website</u>, absolutely not, the client hired Jeremy not to have to deal with that.

5 0
4 years ago
which of the following is not a name of one of the central features of Facebook timeline activity log Graph Search for Daily New
Pani-rosa [81]
The correct answer is Graph Search for Daily News

This does not exist on Facebook, unlike the timeline and the activity log.
3 0
3 years ago
A.<br>Define a computer with its proper meaning.​
Rashid [163]

Answer:

Computer

Explanation:

a programmable electronic device designed to accept data, perform prescribed mathematical and logical operations at high speed, and display the results of these operations.

7 0
3 years ago
Read 2 more answers
Other questions:
  • In microsoft word, when you highlight existing text you want to replace, you’re in
    14·1 answer
  • Benjamin recently issued new mobile phones to the marketing team at his company. Each phone can transmit encrypted information f
    8·1 answer
  • What do you think about the future of computers?​
    14·1 answer
  • How would improving the nutritional health of an entire community impact the overall physical, emotional, and financial health o
    14·1 answer
  • Light the<br> Spark hop<br> Answer if ur a baddie;)))
    9·2 answers
  • The function below takes two parameters: a string parameter: csv_string and an integer index. This string parameter will hold a
    5·1 answer
  • Define a function in Scheme (or relation in Prolog) that checks whether a set of elements (represented as a list) is a subset of
    10·1 answer
  • Which of the following are acceptable to share? Check all of the boxes that apply.
    13·1 answer
  • The ratio of sparrows to bluejays at the bird sanctuary was 5 to 3 If there were 15 bluejays in the sanctuary, how many sparrows
    12·1 answer
  • which explains a method to avoid violation of personal information through phishing? do not carry around your social security ca
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!