BufferedReaderDemo
package bufferedreaderdemo;
/*import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;*/
import java.io.*;
public class BufferedReaderDemo {
public static void main(String[] args) throws IOException {
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter number of pods:");
String podString = keyboard.readLine();
int Pods = Integer.parseInt(podString);
System.out.println("Enter number of peas in a pod:");
String peaString = keyboard.readLine();
int peasPerPod = Integer.parseInt(peaString);
int totalPeas = Pods * peasPerPod;
System.out.print(Pods + "pods and");
System.out.println(peasPerPod + "peas per pod.");
System.out.println("The total number of peas =" + totalPeas);
}
}
/*import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;*/
import java.io.*;
public class BufferedReaderDemo {
public static void main(String[] args) throws IOException {
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter number of pods:");
String podString = keyboard.readLine();
int Pods = Integer.parseInt(podString);
System.out.println("Enter number of peas in a pod:");
String peaString = keyboard.readLine();
int peasPerPod = Integer.parseInt(peaString);
int totalPeas = Pods * peasPerPod;
System.out.print(Pods + "pods and");
System.out.println(peasPerPod + "peas per pod.");
System.out.println("The total number of peas =" + totalPeas);
}
}
0 Comments:
張貼留言
<< Home