星期一, 3月 13, 2006

Lab Scanner

import java.io.*;//9224205
public class Lab_Scanner
{
public static void main(String[] args) throws IOException {
BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the number of pods follow by") ;
String inputString1 = keyboard.readLine();

System.out.println("the number of peas in a pod:") ;
String inputString2 = keyboard.readLine();
int numberOfPods = Integer.parseInt(inputString1);
int peasPerpod = Integer.parseInt(inputString2);
int totalNumberOfPeas = numberOfPods*peasPerpod;

System.out.print( numberOfPods+ " pods and ") ;
System.out.println(peasPerpod+ " peasPerpod") ;
System.out.println("The total number of peas = "+ totalNumberOfPeas) ;
}
}

0 Comments:

張貼留言

<< Home

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Taiwan License.