Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class number2 {
- public static void main(String[] args) {
- /*
- *Write a program to read in twelve numbers. Find and print the sum of the numbers and count
- * the number of numbers that are smaller than 25
- */
- Scanner input = new Scanner (System.in);
- int h, num, num_count = 0, sum = 0;
- System.out.println("Please enter a number: ");
- //num = input.nextInt();
- for(h=1; h<=12; h++) {
- System.out.println("Please enter a number: ");
- num = input.nextInt();
- sum += num;
- if (num < 25) {
- num_count++;
- }
- }
- System.out.println("Sum: " +sum);
- System.out.println("Amount of numbers under 25: " +num_count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement