- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.java
More file actions
Latest commit
24 lines (20 loc) · 567 Bytes
/
Copy pathloop.java
File metadata and controls
24 lines (20 loc) · 567 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
importjava.util.Scanner;
publicclassloop {
publicstaticvoidmain(String[] args) {
intnum;
Scannerinp = newScanner(System.in);
System.out.println("enter a number:");
num = inp.nextInt();
intcount=0,total = 0 ;
doubleaverage=0;
for (inti = 0; i < num; i++) {
if(i % 3 == 0 || i % 4 == 0){
total += i;
count++;
}
}
average = total/count;
System.out.println("average is :"+average);
inp.close();
}
}