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;
}
}
Answer:
Varies. Read explanation.
Explanation:
Many different things can be used to help maintain data during a power outage.
A common thing is to have a backup generator/power bank always connected to maintain server status even during times of a blackout. Along with this, she could back up her data periodically to a hard drive that is in a completely separate location. This can help maintain data even during a blackout.
Answer:
To be able to explain what’s wrong and what needs to be done
Explanation:
So if your looking at a worksheet and the costumer needs help they are gonna ask you about it so your gonna need to be able to explain what’s going on and what needs to be/get done
A colon goes after every if/else statement in python. For instance:
if 1 < 5:
# do something.
As we can see, a colon is placed after the 5.