Java作業一

星期一, 10月 31, 2005

Lab 10-31 (1) product of N positive numbers

import javax.swing.JOptionPane;
public class Untitled5
{
public static void main(String[] args)
{
int x=1;
String myString = JOptionPane.showInputDialog("數入正整數(當輸入負數時結束運算):");
int n = Integer.parseInt(myString);
while(n>=0)
{
x*=n;
myString = JOptionPane.showInputDialog("數入正整數(當輸入負數時結束運算):");
n = Integer.parseInt(myString);
}
System.out.println(x);
System.exit(0);
}
}


0 Comments:

張貼留言

<< Home