2008年3月23日 星期日
Lab Keyboard input
package homework;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class ScannerDemo
{
public static void main(String[] args) throws IOException
{
BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the number of pods followed by");
System.out.println("the number if peas in a pods");
String numberOfPods = keyboard.readLine();
String peasPerPod = keyboard.readLine();
int a,b;
a = Integer.parseInt(numberOfPods);
b = Integer.parseInt(peasPerPod);
int totalNumberOfPeas = a * b;
System.out.println(numberOfPods + " pods and ");
System.out.println(peasPerPod + " peas per pod ");
System.out.println("The tolal number of peas = " +totalNumberOfPeas);
}
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言