//This Java program keeps accepting numbers from the
//user till the user enters a negative number. This program
//can by modified to do something meaningful with the
//entered data.
import java.io.*;
class noNegative
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n;
System.out.println("Enter the numbers");
n=Integer.parseInt(br.readLine());
for(;n>=0;)
{
n=Integer.parseInt(br.readLine());
}
System.out.println("You entered a negative number.");
}
}
//Author : Mayank Rajoria
//user till the user enters a negative number. This program
//can by modified to do something meaningful with the
//entered data.
import java.io.*;
class noNegative
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n;
System.out.println("Enter the numbers");
n=Integer.parseInt(br.readLine());
for(;n>=0;)
{
n=Integer.parseInt(br.readLine());
}
System.out.println("You entered a negative number.");
}
}
//Author : Mayank Rajoria
No comments:
Post a Comment