Test class
to for newDate class
testclasstofornewdateclass.java
/*
Test class to for newDate class
Programm will prompt user for imputs and
printout the the julian dates of two dates
if they are leap years and the number of
days between two dates */
import java.io.*;
public class TestnewDate
{
public static void main ( String args []) throws
IOException
{
int day1, day2, month1, month2, year1, year2;
String Repeat; /* used for the continuing loop
*/
String s; // used for reading in the values
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.flush();
do
{
System.out.println("The following program
will prompt you the user for two dates");
System.out.println("Please enter two valid
dates one after the other ");
System.out.println("The first date needs
to be greater than the second date");
System.out.println("The program will the
tell you the julian dates , the day of the week, ");
System.out.println("and the difference between
the two dates ");
System.out.println("Enter two valid dates.
Please follow promts :"); // prompts the user
System.out.flush();
System.out.println(" Please enter the first
date eg 12th as 12");
s = in.readLine(); // reads the value in
day1 = Integer.parseInt(s); // converts
the string input to an integer
System.out.flush();
System.out.println(" Please enter the first
Month eg May as 5");
s = in.readLine(); // reads the value in
month1 = Integer.parseInt(s); // converts
the string input to an integer
System.out.flush();
System.out.println(" Please enter the first
year in full eg 1976");
s = in.readLine(); // reads the value in
year1 = Integer.parseInt(s); // converts
the string input to an integer
System.out.flush();
System.out.println(" Please enter the second
date eg 12th as 12");
s = in.readLine(); // reads the value in
day2 = Integer.parseInt(s); // converts
the string input to an integer
System.out.flush();
System.out.println(" Please enter the second
Month eg May as 5");
s = in.readLine(); // reads the value in
month2 = Integer.parseInt(s); // converts
the string input to an integer
System.out.flush();
System.out.println(" Please enter the second
year in full eg 1976");
s = in.readLine(); // reads the value in
year2 = Integer.parseInt(s); // converts
the string input to an integer
System.out.flush();
newDate d1 = new newDate(day1,month1,year1,day2,month2,year2);
// initialises a new instance of the class newDate
System.out.println("The dates entered were:
\n" + d1.getDateName1() + " and\n" + d1.getDateName2());
System.out.println("The julian dates for
these are: \n" + d1.getJulianDay1() + " and \n" + d1.getJulianDay2());
System.out.println( d1.getDaysElapsed());
System.out.println("Enter a Y to continue
or anything else to quit");
Repeat = in.readLine();
}while(Repeat.equalsIgnoreCase("Y"));
}
}
Do you have a Java Problem?
Ask It in The Java
Forum
Java Books
Java Certification,
Programming, JavaBean and Object Oriented Reference Books
Return to : Java
Programming Hints and Tips
All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
All product names are trademarks of their respective
companies.
The site www.erpgreat.com is not affiliated with or endorsed
by any company listed at this site.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
The content on this site may not be reproduced
or redistributed without the express written permission of
www.erpgreat.com or the content authors.
|