Computer Science, asked by student2016, 4 months ago

Write a program to accept 20 different numbers in a Single Dimensional
Array (SDA). Display the sum of all the numbers which are divisible by
either 3 or 5
S (SDA)
either 3 or 5.

Answers

Answered by rohitandm16
11

Answer:

import java.io*;

class Array

{

public static void main (String args[ ] ) throws IOException

{

Data Input Stream in = new Data Input Stream( system.in);

int a [ ] = new[10]

int i , s=0;

System.out.println("Enter Twenty Elements");

for ( i=0; i<20; i++ )

{

a[ i ] = Integer.parse Int ( in.read line() );

s=s+a[ i ];

}

if ( s%3 == 0 && s%5 == 0)

system.out.println( Divisible by both 3 and 5);

else if ( s%3 == 0)

system.out.println( Divisible by 3 );

else if ( s%5 == 0)

system.out.println( Divisible by 5 );

else

system.out.println( Not Divisible by 3 and 5 );

}

}

Answered by deepasubhas123
0

Answer:

o

Explanation:

Similar questions