Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ForExample {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int c = 0;
- int sum = 0;
- int i;
- for (i = 0; i < 4; i += 1) {
- System.out.print("Enter a number: ");
- int x = in.nextInt();
- if (x > 7) {
- c = c + 1;
- sum = sum + x;
- }
- }
- System.out.println("Count = " + c);
- System.out.println("percentage = " + 100.0 * c / i + "%");
- System.out.println("\nSum = " + sum);
- double avg = (double) sum / c;
- avg = Math.round(avg); // (int)(avg*10)/10.0;
- System.out.println("Average = " + avg);
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement