Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class Tennumbers {
- static public void main (String args [])throws IOException{
- double num,lowNum;
- double average=0;
- double sum = 0;
- String numString;
- final String TERMINATE="stop";
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("This program will determine if average of 10 numbers is above 10 or not, and the smallest number");
- System.out.println("Please input your numbers, type stop to terminate the program");
- numString = br.readLine();
- num = (Double.valueOf(numString)).doubleValue();
- lowNum=num;
- while(!numString.equals(TERMINATE)){
- for (byte count = 2;count<=10;count++) {
- numString = br.readLine();
- num = Double.parseDouble (numString);
- sum+= num;
- average = sum/10;
- if (num<lowNum)
- lowNum=num;
- }
- if(average==10){
- System.out.println("Right On");
- System.out.println("The smallest number is "+lowNum);
- }
- else if (average>10){
- System.out.println("Above 10");
- System.out.println("The smallest number is "+lowNum);
- }
- else if (average<10){
- System.out.println("Better luck next time!");
- System.out.println("The smallest number is "+lowNum);
- }
- if (numString.equals(TERMINATE));
- break;
- }
- System.out.println("Thank you come again");
- }
- }
Add Comment
Please, Sign In to add comment