Monday, October 17, 2005

JAVA Display 2.6

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Untitled1 {
public static void main(String[] args ) throws IOException
{
BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the number of pods follwed by");
System.out.println("the number of peas in a pod");
int b = Integer.parseInt(keyboard.readLine());
int c = Integer.parseInt(keyboard.readLine());
int d=b*c;
System.out.println(b+" pods and");
System.out.println(c+" peas per pod");
System.out.println("the total number of peas=" +d);
}

}

結果

0 Comments:

Post a Comment

<< Home