Scanner
package untitled7;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Untitled1 {
public static void main(String [] arg) 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 a pod:");
int numberOfPods=Integer.parseInt(keyboard.readLine());
int peasPerPod=Integer.parseInt(keyboard.readLine());
int totalNumberOfPeas=numberOfPods*peasPerPod;
System.out.print(numberOfPods+" pods and ");
System.out.println(peasPerPod+" peas per pod.");
System.out.println("The total number of peas ="+totalNumberOfPeas);
}
}
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Untitled1 {
public static void main(String [] arg) 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 a pod:");
int numberOfPods=Integer.parseInt(keyboard.readLine());
int peasPerPod=Integer.parseInt(keyboard.readLine());
int totalNumberOfPeas=numberOfPods*peasPerPod;
System.out.print(numberOfPods+" pods and ");
System.out.println(peasPerPod+" peas per pod.");
System.out.println("The total number of peas ="+totalNumberOfPeas);
}
}
0 Comments:
張貼留言
<< Home