Guest User

Untitled

a guest
Jul 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. import java.io.*;
  2. public class Tennumbers {
  3. static public void main (String args [])throws IOException{
  4. double num,lowNum;
  5. double average=0;
  6. double sum = 0;
  7. String numString;
  8. final String TERMINATE="stop";
  9. BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  10. System.out.println("This program will determine if average of 10 numbers is above 10 or not, and the smallest number");
  11. System.out.println("Please input your numbers, type stop to terminate the program");
  12. numString = br.readLine();
  13. num = (Double.valueOf(numString)).doubleValue();
  14. lowNum=num;
  15. while(!numString.equals(TERMINATE)){
  16. for (byte count = 2;count<=10;count++) {
  17. numString = br.readLine();
  18. num = Double.parseDouble (numString);
  19. sum+= num;
  20. average = sum/10;
  21. if (num<lowNum)
  22. lowNum=num;
  23. }
  24. if(average==10){
  25. System.out.println("Right On");
  26. System.out.println("The smallest number is "+lowNum);
  27. }
  28. else if (average>10){
  29. System.out.println("Above 10");
  30. System.out.println("The smallest number is "+lowNum);
  31. }
  32. else if (average<10){
  33. System.out.println("Better luck next time!");
  34. System.out.println("The smallest number is "+lowNum);
  35.  
  36. }
  37. if (numString.equals(TERMINATE));
  38. break;
  39. }
  40. System.out.println("Thank you come again");
  41. }
  42. }
Add Comment
Please, Sign In to add comment