Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package proj16122022;
- import java.util.Scanner;
- public class Ex01 {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- double x;
- int count=0;
- double sum=0;
- double max=Double.MIN_VALUE;
- double min=Double.MAX_VALUE;
- int count55To100=0;
- System.out.print("Eneter a positive number: ");
- x = in.nextDouble();
- while (x>0) {
- // process
- count++; // add one to counter
- sum = sum + x; // add x to sum of numbers
- if (x>max) {
- max = x;
- if (x<min) {
- min = x;
- }
- if (x>=55 && x <=100 ) {
- count55To100++;
- }
- // get a new number
- System.out.print("Eneter a positive number: ");
- x = in.nextDouble();
- }
- System.out.println("End of data");
- System.out.println("count = " + count);
- System.out.println("sum = " + sum);
- //double avg = sum/count;
- //System.out.println("average = " + avg);
- System.out.println("average = " + sum/count);
- System.out.println("max = " + max);
- System.out.println("min = " + min);
- System.out.println("count55To100 = " + count55To100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement