Skip to content

Commit ac84c2d

Browse files
authored
Add files via upload
1 parent 2587a16 commit ac84c2d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

JavaArray.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*Write a Java program that takes 10 inputs from the user in a loop, and displays the sum, average, minimum and maximum of Only the positive odd numbers from those numbers. If no such numbers are found, then display the message “No odd positive numbers found”.*/
2+
3+
import java.util.Scanner;
4+
public class JavaArray{
5+
public static void main(String[]args){
6+
Scanner sc=new Scanner(System.in);
7+
int sum=0;
8+
int min=0;
9+
int max=0;
10+
int count=0;
11+
for(int i=0;i<10;i++){
12+
int num= sc.nextInt();
13+
if(num%2!=0&&num>0){
14+
sum+=num;
15+
count++;
16+
if(num>max){
17+
max=num;}
18+
else{
19+
min=num;}}}
20+
if(count!=0){
21+
System.out.println("Sum = "+sum);
22+
System.out.println("Minimum = "+min);
23+
System.out.println("Maximum = "+max);
24+
System.out.println("Average = "+(double)sum/count);}
25+
else{
26+
System.out.println("No odd positive numbers found");}
27+
}
28+
}

0 commit comments

Comments
 (0)