第4次作業
Lab window input dialog
LabScanner
package untitled6;
import java.io.*;
public class Untitled1 {
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");
String inputString = keyboard.readLine();
int numberOfPods= Integer.parseInt(inputString);
System.out.println("the number of peas in a pod:");
String inputString2 = keyboard.readLine();
int peasPerPod= Integer.parseInt(inputString2);
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);
}
}
LabScanner
package untitled6;
import java.io.*;
public class Untitled1 {
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");
String inputString = keyboard.readLine();
int numberOfPods= Integer.parseInt(inputString);
System.out.println("the number of peas in a pod:");
String inputString2 = keyboard.readLine();
int peasPerPod= Integer.parseInt(inputString2);
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:
Post a Comment
<< Home