Lab7
import java.io.*;
public class DateSecondTry {
public static void main(String[] args) throws IOException
{ DemoOfDateSecondTry date = new DemoOfDateSecondTry();
date.readInput();
date.writeOutput();}}
===============================================
import java.io.*;
public class DemoOfDateSecondTry
{ public String month;
public int day,year;
public void writeOutput()
{System.out.println(month+" "+ day +", " + year);}
public void readInput() throws IOException
{ BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter month, day, and year.");
System.out.println("Don't use a comma.");
month = keyboard.readLine();
String days = keyboard.readLine();
day = Integer.parseInt(days);
String years = keyboard.readLine();
year = Integer.parseInt(years); }}
結果:
Enter month, day, and year.
Don't use a comma.
12
31
2006
12 31, 2006
public class DateSecondTry {
public static void main(String[] args) throws IOException
{ DemoOfDateSecondTry date = new DemoOfDateSecondTry();
date.readInput();
date.writeOutput();}}
===============================================
import java.io.*;
public class DemoOfDateSecondTry
{ public String month;
public int day,year;
public void writeOutput()
{System.out.println(month+" "+ day +", " + year);}
public void readInput() throws IOException
{ BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter month, day, and year.");
System.out.println("Don't use a comma.");
month = keyboard.readLine();
String days = keyboard.readLine();
day = Integer.parseInt(days);
String years = keyboard.readLine();
year = Integer.parseInt(years); }}
結果:
Enter month, day, and year.
Don't use a comma.
12
31
2006
12 31, 2006
0 Comments:
張貼留言
<< Home