星期一, 10月 31, 2005

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

import javax.swing.JOptionPane;
public class q1031
{
public static void main(String[] args)
{
double ans=1,one, count,i=1;
while(i>0)
{
String myString2=JOptionPane.showInputDialog("Enter a number: ");
int sum1 = Integer.parseInt(myString2);
one=sum1;
while(one>0)
{
ans=ans*one;
System.out.print( sum1 + " , ");

i++;
}

System.out.print( one + " , ");
System.out.println("Ans= "+ans);
System.exit(0);
}
}
}

0 Comments:

張貼留言

<< Home