Page 618 - ComputerScience_Class_11
P. 618
Program 26 Design a class Ddate that takes a future date (any date after 01-01-2023) and prints what day
it will be (given the day of 01-01-2023)
class name : Ddate
Data Members
String s : to store the future date in DD-MM-YYYY format
String f : to store the day of 01-01-2023
Member Functions
Ddate() : constructor to initialise data members to null
void accept() : to accept the values of s and f
void find_day() : to find and display the day of the future date
1 import java.util.*;
2
3 class Ddate {
4 String s, f;
5
6 Ddate() {
7 s = f = "";
8 }
9
10 void accept() {
11 Scanner sc = new Scanner(System.in);
12 System.out.print("Enter the Date in DD-MM-YYYY format : ");
13 s = sc.next();
14 System.out.print("Enter the Day of 1st January 2023 : ");
15 f = sc.next();
16 }
17
18 void find_day() {
19 int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
20 String day[] = {"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY",
"FRIDAY", "SATURDAY"};
21
22 int d, m, y, tot = 0, v = -1;
23
24 d = Integer.parseInt(s.substring(0, 2));
25 m = Integer.parseInt(s.substring(3, 5));
616 Touchpad Computer Science (Ver. 3.0)-XI

