import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class LabKeyboardinput
{
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 of peas in the pod:");
String numberOfPods = keyboard.readLine();
String peasPerPod = keyboard.readLine();
double totalNumberOfPeas = Double.parseDouble (numberOfPods)*Double.parseDouble (peasPerPod);
System.out.print(numberOfPods+"pods and");
System.out.println(peasPerPod+"peas per pod.");
System.out.println("The total number of peas ="+totalNumberOfPeas);
}
}
結果:
沒有留言:
張貼留言