-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.java
More file actions
28 lines (24 loc) · 895 Bytes
/
Copy pathtest.java
File metadata and controls
28 lines (24 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package AddingMultiplesOfFour;
import java.util.Scanner;
/**
* @author Fatih ARI - 19.08.2021
*
* A program is designed that accepts inputs from the user until a single number is entered using loops and adds the numbers that are multiples of 4 from the entered values and prints them on the screen.
*
*/
public class test {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int number, sum=0;
do
{
System.out.print("Enter the number: ");
number = input.nextInt();
if (number % 4 == 0)
sum+=number;
} while (number % 2 == 0); //Entering a negative number will terminate the loop.
input.close();
System.out.println("\nThe sum of the entered numbers that are a multiple of 4 is \"" + sum + "\".\n");
}
}