import java.io.*;
class Ex33
{
public static void main(String[] args)
{
Console console=System.console();
System.out.println("Please enter the next number");
String input;
input=console.readLine();
int n1;
n1=Integer.parseInt(input);
int sum=0;
int sum2=0;
int input2=0;
input2=n1;
int count=1;
char dot=',';
String Number="";
int RealNumber2=0;
String All="";
String RealNumber="";
while(count<5)
{
System.out.println("Please enter the next number");
input=console.readLine();
n1=Integer.parseInt(input);
sum=(n1+sum);
All+=n1+","; // here i should get a string of all numbers that were fed into the application
count++;
}
sum2=sum/4; // the sum of all the numbers is divided by amount of numbers put in, giving the average
System.out.println("Your average is"+" "+sum2);
System.out.println(All);
for(int count2=0;count2<All.length();count2++)
{
char c=All.charAt(count2);
if(c!=dot)
{
Number+=c; // this should add each number till it reaches dot
}
else
{
RealNumber2=Integer.parseInt(Number);//here i should get a string of numbers and it should be converted to a number
}
if(RealNumber2<sum2)
System.out.println(RealNumber2); // a number should be printed out , that is smaller than the sum
}
}
}
i am stuck on the last part, . my task is to print all the numbers put into the applications which are smaller than the sum.
the last part is problematic..what the last part should do is count through all the characters in teh string "All", and save the numbers before dot. then convert those numbers and compare them to the average..
but what i get at the end...is few irrelevant numbers such as 0 0 12 ..for example