Lab 10-31 (1) product of N positive numbers
import java.io.*;
public class ananfish{
public static void main(String[] args) throws IOException {
BufferedReader keyboard =
new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number.");
String number = keyboard.readLine();
int input = Integer.parseInt(number);
int sum=1;
do
{
sum=input*sum;
System.out.println("Enter a number.");
number = keyboard.readLine();
input = Integer.parseInt(number);
}while(input>=0);
System.out.println("Answer:"+sum);
}
}
http://140.135.112.9/~u9340135/ananfish.jpg
0 Comments:
Post a Comment
<< Home