DayTester.java 1 public class DayTester 2 ( public static void main(String() args) 34 System.out.printin(exanTwo.toString()); // This is the date for our exan2 System.out.println("Expected: 2022-04-26"); 3 4. // Step 2: Declare three int variables catled // Step 8: Display the number of days between // int days = exanTwo.daysFrom(examOne); 6. // year, month, and day with initial values of 2022, 3, 15. the two exans as a positive integer 41 int year - 2022; int month - 3; int day - 15;: // This is the number of days between our examl // and our exam2 System.out.println("Expected: 42"); 43 44 // Step 3: Construct a Day object using the three int 45 variables and assign it to a variable called exanone 46 // Step 9: Update examOne to the day 69 days later examone.addDays(69); 47 Day exanone - new Day (2022, 03, 15): 48 // Step 4: Display exanone on a line System.out.println{examOne.toString()); 49 // Step 10: Display examone on a line System.out.println(exanOne. toString()); 50 51 I/ This is the date for our exanl Systen.out.println{*Expected: 2022-03-15"); 52 53 I/ Step 5: Reset month to 4 and day to 26 month- 4; day - 26; // This is the date for our final exan System.out.println("Expected: 2822-05-23*); // Step 11: Display the number of days between // Step 6: Construct a Day object using the sane three variables and assign it to a variable called exanTwo examone and examTwo as a positive integer // Note: examOne now holds the date for our final exam
Updated Java code for given question
import java.util.*;
public class DayTester{
public static void main(String[] args){
int year=2022;
int month=3;
int day=15;
Day examOne= new Day(2022, 03, 15);
System.out.println(examOne.toSring());
System.out.println("Expected: 2022-03-15");
month= 4;
day= 26;
Day examTwo= new Day(2022, 04, 26);
System.out.println(examTwo.toString());
System.out.println("Expected: 2022-04-26");
int days= examTwo.daysFrom(examOne);
System.out.println("42");
System.out.println("Expected: 42");
examOne.addDays(69);
System.out.println(examOne.toSring());
System.out.println("2022-05-23");
System.out.println("Expected: 2022-05-23");
System.out.println(examOne);
System.out.println("27");
System.out.println("Expected: 27");
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images