Advertisement
Guest User

25b

a guest
Oct 16th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class a6task25b
  4. {
  5. public static void main(String[]args)
  6. {
  7. Scanner cat=new Scanner(System.in);
  8. int g=1;
  9. int sum=0;
  10. int x=0;
  11.  
  12. int max=0;
  13.  
  14. while(g<=7)
  15. {
  16. System.out.println("Enter a number");
  17. int n=cat.nextInt();
  18.  
  19. if(n%2==0)
  20. {g=g+1;}
  21. else
  22. {
  23. sum=sum+n;
  24. max=n;
  25. x=x+1;
  26. g=g+1;
  27. }
  28. while(g<=6)
  29. {
  30. System.out.println("Enter a number");
  31. int y=cat.nextInt();
  32. if(y%2==0)
  33. {}
  34. else
  35. {
  36. sum=sum+y;
  37. x=x+1;
  38. }
  39. if(y>max)
  40. {max=y;}
  41. else{}
  42. g++;
  43. }
  44. System.out.println("Average: "+(sum/x));
  45. System.out.println("Maximum: "+max);
  46. g++;
  47.  
  48. }
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement