SlideShare a Scribd company logo
1 of 12
Download to read offline
Birthdaydate.java
import java.util.Scanner;
public class Birthdaydate {
public static void main(String[] args) {
//Declaring variables
char ch,ch1,ch2,ch3,ch4,ch5;
//Declaring each card as an 2-Dimensional Array
int card1[][]={{1,3,5,7},{9,11,13,15},{17,19,21,23},{25,27,29,31}};
int card2[][]={{2,3,6,7},{10,11,14,15},{18,19,22,23},{26,27,30,31}};
int card3[][]={{4,5,6,7},{12,13,14,15},{20,21,22,23},{28,29,30,31}};
int card4[][]={{8,9,10,11},{12,13,14,15},{24,25,26,27},{28,29,30,31}};
int card5[][]={{16,17,18,19},{20,21,22,23},{24,25,26,27},{28,29,30,31}};
//Scanner Object is used to get the inputs entered by the user
Scanner sc = new Scanner(System.in);
//This loop continue to execute until user enters 'Y' or 'y'
do
{
//Declaring variable
int sum=0;
//Displaying card1 using nested for loop
System.out.println(":: Card1 ::");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
System.out.printf("%3d",card1[i][j]);
}
System.out.println(" ");
}
//Prompting whether the day of birth is having in card1 or not.
System.out.print("Do card#1 is having Your Birthday (Y/N):");
ch1 = sc.next(".").charAt(0);
//If the day is in card 1,add the first row first column element to sum
if(ch1=='Y' || ch1=='y')
sum+=card1[0][0];
//Displaying card2 using nested for loop
System.out.println(":: Card2 ::");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
System.out.printf("%3d",card2[i][j]);
}
System.out.println(" ");
}
//Prompting whether the day of birth is having in card2 or not.
System.out.print("Do card#2 is having Your Birthday (Y/N):");
ch2 = sc.next(".").charAt(0);
//If the day is in card 2,add the first row first column element to sum
if(ch2=='Y' || ch2=='y')
sum+=card2[0][0];
//Displaying card3 using nested for loop
System.out.println(":: Card3 ::");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
System.out.printf("%3d",card3[i][j]);
}
System.out.println(" ");
}
//Prompting whether the day of birth is having in card3 or not.
System.out.print("Do card#3 is having Your Birthday (Y/N):");
ch3 = sc.next(".").charAt(0);
//If the day is in card 3,add the first row first column element to sum
if(ch3=='Y' || ch3=='y')
sum+=card3[0][0];
//Displaying card4 using nested for loop
System.out.println(":: Card4 ::");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
System.out.printf("%3d",card4[i][j]);
}
System.out.println(" ");
}
//Prompting whether the day of birth is having in card4 or not.
System.out.print("Do card#4 is having Your Birthday (Y/N):");
ch4 = sc.next(".").charAt(0);
//If the day is in card 4,add the first row first column element to sum
if(ch4=='Y' || ch4=='y')
sum+=card4[0][0];
//Displaying card5 using nested for loop
System.out.println(":: Card5 ::");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
System.out.printf("%3d",card5[i][j]);
}
System.out.println(" ");
}
//Prompting whether the day of birth is having in card5 or not.
System.out.print("Do card#5 is having Your Birthday (Y/N):");
ch5 = sc.next(".").charAt(0);
//If the day is in card 5,add the first row first column element to sum
if(ch5=='Y' || ch5=='y')
sum+=card5[0][0];
System.out.println("Your Birthday is "+sum);
System.out.print(" Do You want to continue? (y/n): ");
ch = sc.next(".").charAt(0);
System.out.println("________________________________");
}while(ch=='Y' || ch=='y');
}
}
_________________________________________________
Output:
:: Card1 ::
1 3 5 7
9 11 13 15
17 19 21 23
25 27 29 31
Do card#1 is having Your Birthday (Y/N):y
:: Card2 ::
2 3 6 7
10 11 14 15
18 19 22 23
26 27 30 31
Do card#2 is having Your Birthday (Y/N):y
:: Card3 ::
4 5 6 7
12 13 14 15
20 21 22 23
28 29 30 31
Do card#3 is having Your Birthday (Y/N):n
:: Card4 ::
8 9 10 11
12 13 14 15
24 25 26 27
28 29 30 31
Do card#4 is having Your Birthday (Y/N):n
:: Card5 ::
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
Do card#5 is having Your Birthday (Y/N):n
Your Birthday is 3
Do You want to continue? (y/n):
y
:: Card1 ::
1 3 5 7
9 11 13 15
17 19 21 23
25 27 29 31
Do card#1 is having Your Birthday (Y/N):n
:: Card2 ::
2 3 6 7
10 11 14 15
18 19 22 23
26 27 30 31
Do card#2 is having Your Birthday (Y/N):y
:: Card3 ::
4 5 6 7
12 13 14 15
20 21 22 23
28 29 30 31
Do card#3 is having Your Birthday (Y/N):n
:: Card4 ::
8 9 10 11
12 13 14 15
24 25 26 27
28 29 30 31
Do card#4 is having Your Birthday (Y/N):n
:: Card5 ::
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
Do card#5 is having Your Birthday (Y/N):n
Your Birthday is 2
Do You want to continue? (y/n):
n
______________________________________________________
The reason this works because we are having the numbers of first row first column of cards as 1
2 4 8 16.With these 5 numbers we can amke any day between 1 and 31.Based on the Birthday
present in the cards those corresponding first row first column of every card is getting added to
find the birthday of the user.
______________________________________________________Thank you
Solution
Birthdaydate.java
import java.util.Scanner;
public class Birthdaydate {
public static void main(String[] args) {
//Declaring variables
char ch,ch1,ch2,ch3,ch4,ch5;
//Declaring each card as an 2-Dimensional Array
int card1[][]={{1,3,5,7},{9,11,13,15},{17,19,21,23},{25,27,29,31}};
int card2[][]={{2,3,6,7},{10,11,14,15},{18,19,22,23},{26,27,30,31}};
int card3[][]={{4,5,6,7},{12,13,14,15},{20,21,22,23},{28,29,30,31}};
int card4[][]={{8,9,10,11},{12,13,14,15},{24,25,26,27},{28,29,30,31}};
int card5[][]={{16,17,18,19},{20,21,22,23},{24,25,26,27},{28,29,30,31}};
//Scanner Object is used to get the inputs entered by the user
Scanner sc = new Scanner(System.in);
//This loop continue to execute until user enters 'Y' or 'y'
do
{
//Declaring variable
int sum=0;
//Displaying card1 using nested for loop
System.out.println(":: Card1 ::");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
System.out.printf("%3d",card1[i][j]);
}
System.out.println(" ");
}
//Prompting whether the day of birth is having in card1 or not.
System.out.print("Do card#1 is having Your Birthday (Y/N):");
ch1 = sc.next(".").charAt(0);
//If the day is in card 1,add the first row first column element to sum
if(ch1=='Y' || ch1=='y')
sum+=card1[0][0];
//Displaying card2 using nested for loop
System.out.println(":: Card2 ::");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
System.out.printf("%3d",card2[i][j]);
}
System.out.println(" ");
}
//Prompting whether the day of birth is having in card2 or not.
System.out.print("Do card#2 is having Your Birthday (Y/N):");
ch2 = sc.next(".").charAt(0);
//If the day is in card 2,add the first row first column element to sum
if(ch2=='Y' || ch2=='y')
sum+=card2[0][0];
//Displaying card3 using nested for loop
System.out.println(":: Card3 ::");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
System.out.printf("%3d",card3[i][j]);
}
System.out.println(" ");
}
//Prompting whether the day of birth is having in card3 or not.
System.out.print("Do card#3 is having Your Birthday (Y/N):");
ch3 = sc.next(".").charAt(0);
//If the day is in card 3,add the first row first column element to sum
if(ch3=='Y' || ch3=='y')
sum+=card3[0][0];
//Displaying card4 using nested for loop
System.out.println(":: Card4 ::");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
System.out.printf("%3d",card4[i][j]);
}
System.out.println(" ");
}
//Prompting whether the day of birth is having in card4 or not.
System.out.print("Do card#4 is having Your Birthday (Y/N):");
ch4 = sc.next(".").charAt(0);
//If the day is in card 4,add the first row first column element to sum
if(ch4=='Y' || ch4=='y')
sum+=card4[0][0];
//Displaying card5 using nested for loop
System.out.println(":: Card5 ::");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
System.out.printf("%3d",card5[i][j]);
}
System.out.println(" ");
}
//Prompting whether the day of birth is having in card5 or not.
System.out.print("Do card#5 is having Your Birthday (Y/N):");
ch5 = sc.next(".").charAt(0);
//If the day is in card 5,add the first row first column element to sum
if(ch5=='Y' || ch5=='y')
sum+=card5[0][0];
System.out.println("Your Birthday is "+sum);
System.out.print(" Do You want to continue? (y/n): ");
ch = sc.next(".").charAt(0);
System.out.println("________________________________");
}while(ch=='Y' || ch=='y');
}
}
_________________________________________________
Output:
:: Card1 ::
1 3 5 7
9 11 13 15
17 19 21 23
25 27 29 31
Do card#1 is having Your Birthday (Y/N):y
:: Card2 ::
2 3 6 7
10 11 14 15
18 19 22 23
26 27 30 31
Do card#2 is having Your Birthday (Y/N):y
:: Card3 ::
4 5 6 7
12 13 14 15
20 21 22 23
28 29 30 31
Do card#3 is having Your Birthday (Y/N):n
:: Card4 ::
8 9 10 11
12 13 14 15
24 25 26 27
28 29 30 31
Do card#4 is having Your Birthday (Y/N):n
:: Card5 ::
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
Do card#5 is having Your Birthday (Y/N):n
Your Birthday is 3
Do You want to continue? (y/n):
y
:: Card1 ::
1 3 5 7
9 11 13 15
17 19 21 23
25 27 29 31
Do card#1 is having Your Birthday (Y/N):n
:: Card2 ::
2 3 6 7
10 11 14 15
18 19 22 23
26 27 30 31
Do card#2 is having Your Birthday (Y/N):y
:: Card3 ::
4 5 6 7
12 13 14 15
20 21 22 23
28 29 30 31
Do card#3 is having Your Birthday (Y/N):n
:: Card4 ::
8 9 10 11
12 13 14 15
24 25 26 27
28 29 30 31
Do card#4 is having Your Birthday (Y/N):n
:: Card5 ::
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
Do card#5 is having Your Birthday (Y/N):n
Your Birthday is 2
Do You want to continue? (y/n):
n
______________________________________________________
The reason this works because we are having the numbers of first row first column of cards as 1
2 4 8 16.With these 5 numbers we can amke any day between 1 and 31.Based on the Birthday
present in the cards those corresponding first row first column of every card is getting added to
find the birthday of the user.
______________________________________________________Thank you

More Related Content

More from sudhinjv

14 = disease ff24 = carriers Ff25 chances that they will pro.pdf
14 = disease ff24 = carriers Ff25  chances that they will pro.pdf14 = disease ff24 = carriers Ff25  chances that they will pro.pdf
14 = disease ff24 = carriers Ff25 chances that they will pro.pdfsudhinjv
 
Mosses, lichens are great indicators of radioactive pollution. They .pdf
  Mosses, lichens are great indicators of radioactive pollution. They .pdf  Mosses, lichens are great indicators of radioactive pollution. They .pdf
Mosses, lichens are great indicators of radioactive pollution. They .pdfsudhinjv
 
10 million.Sensory conflict theory argues , The brightest light at.pdf
10 million.Sensory conflict theory argues , The brightest light at.pdf10 million.Sensory conflict theory argues , The brightest light at.pdf
10 million.Sensory conflict theory argues , The brightest light at.pdfsudhinjv
 
We first find the slopes of the two lines 2M an.pdf
                     We first find the slopes of the two lines 2M an.pdf                     We first find the slopes of the two lines 2M an.pdf
We first find the slopes of the two lines 2M an.pdfsudhinjv
 
SO2 is a gas that mixes with water to form sulfur.pdf
                     SO2 is a gas that mixes with water to form sulfur.pdf                     SO2 is a gas that mixes with water to form sulfur.pdf
SO2 is a gas that mixes with water to form sulfur.pdfsudhinjv
 
1. Heterozygosity by migration calculated using the below formulaH.pdf
1. Heterozygosity by migration calculated using the below formulaH.pdf1. Heterozygosity by migration calculated using the below formulaH.pdf
1. Heterozygosity by migration calculated using the below formulaH.pdfsudhinjv
 
1).Monohybrid cross between true breeding parents. Assume that the.pdf
1).Monohybrid cross between true breeding parents. Assume that the.pdf1).Monohybrid cross between true breeding parents. Assume that the.pdf
1).Monohybrid cross between true breeding parents. Assume that the.pdfsudhinjv
 
1. Moving down a group, the electronegativity decreases due to the l.pdf
  1. Moving down a group, the electronegativity decreases due to the l.pdf  1. Moving down a group, the electronegativity decreases due to the l.pdf
1. Moving down a group, the electronegativity decreases due to the l.pdfsudhinjv
 
The mercury liquid and the mercury(II) oxide are .pdf
                     The mercury liquid and the mercury(II) oxide are .pdf                     The mercury liquid and the mercury(II) oxide are .pdf
The mercury liquid and the mercury(II) oxide are .pdfsudhinjv
 
1 Ans Bacteria are unicellular organisms that reproduce by cell divi.pdf
1 Ans Bacteria are unicellular organisms that reproduce by cell divi.pdf1 Ans Bacteria are unicellular organisms that reproduce by cell divi.pdf
1 Ans Bacteria are unicellular organisms that reproduce by cell divi.pdfsudhinjv
 
1#include stdio.h#include stdlib.h#include assert.h .pdf
1#include stdio.h#include stdlib.h#include assert.h .pdf1#include stdio.h#include stdlib.h#include assert.h .pdf
1#include stdio.h#include stdlib.h#include assert.h .pdfsudhinjv
 
Ques-6 answerThe clinical significance of beta-hemolytic (on blo.pdf
Ques-6 answerThe clinical significance of beta-hemolytic (on blo.pdfQues-6 answerThe clinical significance of beta-hemolytic (on blo.pdf
Ques-6 answerThe clinical significance of beta-hemolytic (on blo.pdfsudhinjv
 
Valence electrons electrons at outer-most energy level.Effective.pdf
Valence electrons  electrons at outer-most energy level.Effective.pdfValence electrons  electrons at outer-most energy level.Effective.pdf
Valence electrons electrons at outer-most energy level.Effective.pdfsudhinjv
 
What is storage mediaAns-C. the physical material on which a co.pdf
What is storage mediaAns-C. the physical material on which a co.pdfWhat is storage mediaAns-C. the physical material on which a co.pdf
What is storage mediaAns-C. the physical material on which a co.pdfsudhinjv
 
Transactional model of communication states that if people are conne.pdf
Transactional model of communication states that if people are conne.pdfTransactional model of communication states that if people are conne.pdf
Transactional model of communication states that if people are conne.pdfsudhinjv
 
What is the measure of the strength of the relationship between inde.pdf
What is the measure of the strength of the relationship between inde.pdfWhat is the measure of the strength of the relationship between inde.pdf
What is the measure of the strength of the relationship between inde.pdfsudhinjv
 
Some of the SO32- is oxidized by atmospheric oxygen in air into SO42.pdf
Some of the SO32- is oxidized by atmospheric oxygen in air into SO42.pdfSome of the SO32- is oxidized by atmospheric oxygen in air into SO42.pdf
Some of the SO32- is oxidized by atmospheric oxygen in air into SO42.pdfsudhinjv
 
Should begin with a letter and may contain additional letters and di.pdf
Should begin with a letter and may contain additional letters and di.pdfShould begin with a letter and may contain additional letters and di.pdf
Should begin with a letter and may contain additional letters and di.pdfsudhinjv
 
#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdfsudhinjv
 
Prostomes are mollusca, annelids and arthropods while deuterostomes .pdf
Prostomes are mollusca, annelids and arthropods while deuterostomes .pdfProstomes are mollusca, annelids and arthropods while deuterostomes .pdf
Prostomes are mollusca, annelids and arthropods while deuterostomes .pdfsudhinjv
 

More from sudhinjv (20)

14 = disease ff24 = carriers Ff25 chances that they will pro.pdf
14 = disease ff24 = carriers Ff25  chances that they will pro.pdf14 = disease ff24 = carriers Ff25  chances that they will pro.pdf
14 = disease ff24 = carriers Ff25 chances that they will pro.pdf
 
Mosses, lichens are great indicators of radioactive pollution. They .pdf
  Mosses, lichens are great indicators of radioactive pollution. They .pdf  Mosses, lichens are great indicators of radioactive pollution. They .pdf
Mosses, lichens are great indicators of radioactive pollution. They .pdf
 
10 million.Sensory conflict theory argues , The brightest light at.pdf
10 million.Sensory conflict theory argues , The brightest light at.pdf10 million.Sensory conflict theory argues , The brightest light at.pdf
10 million.Sensory conflict theory argues , The brightest light at.pdf
 
We first find the slopes of the two lines 2M an.pdf
                     We first find the slopes of the two lines 2M an.pdf                     We first find the slopes of the two lines 2M an.pdf
We first find the slopes of the two lines 2M an.pdf
 
SO2 is a gas that mixes with water to form sulfur.pdf
                     SO2 is a gas that mixes with water to form sulfur.pdf                     SO2 is a gas that mixes with water to form sulfur.pdf
SO2 is a gas that mixes with water to form sulfur.pdf
 
1. Heterozygosity by migration calculated using the below formulaH.pdf
1. Heterozygosity by migration calculated using the below formulaH.pdf1. Heterozygosity by migration calculated using the below formulaH.pdf
1. Heterozygosity by migration calculated using the below formulaH.pdf
 
1).Monohybrid cross between true breeding parents. Assume that the.pdf
1).Monohybrid cross between true breeding parents. Assume that the.pdf1).Monohybrid cross between true breeding parents. Assume that the.pdf
1).Monohybrid cross between true breeding parents. Assume that the.pdf
 
1. Moving down a group, the electronegativity decreases due to the l.pdf
  1. Moving down a group, the electronegativity decreases due to the l.pdf  1. Moving down a group, the electronegativity decreases due to the l.pdf
1. Moving down a group, the electronegativity decreases due to the l.pdf
 
The mercury liquid and the mercury(II) oxide are .pdf
                     The mercury liquid and the mercury(II) oxide are .pdf                     The mercury liquid and the mercury(II) oxide are .pdf
The mercury liquid and the mercury(II) oxide are .pdf
 
1 Ans Bacteria are unicellular organisms that reproduce by cell divi.pdf
1 Ans Bacteria are unicellular organisms that reproduce by cell divi.pdf1 Ans Bacteria are unicellular organisms that reproduce by cell divi.pdf
1 Ans Bacteria are unicellular organisms that reproduce by cell divi.pdf
 
1#include stdio.h#include stdlib.h#include assert.h .pdf
1#include stdio.h#include stdlib.h#include assert.h .pdf1#include stdio.h#include stdlib.h#include assert.h .pdf
1#include stdio.h#include stdlib.h#include assert.h .pdf
 
Ques-6 answerThe clinical significance of beta-hemolytic (on blo.pdf
Ques-6 answerThe clinical significance of beta-hemolytic (on blo.pdfQues-6 answerThe clinical significance of beta-hemolytic (on blo.pdf
Ques-6 answerThe clinical significance of beta-hemolytic (on blo.pdf
 
Valence electrons electrons at outer-most energy level.Effective.pdf
Valence electrons  electrons at outer-most energy level.Effective.pdfValence electrons  electrons at outer-most energy level.Effective.pdf
Valence electrons electrons at outer-most energy level.Effective.pdf
 
What is storage mediaAns-C. the physical material on which a co.pdf
What is storage mediaAns-C. the physical material on which a co.pdfWhat is storage mediaAns-C. the physical material on which a co.pdf
What is storage mediaAns-C. the physical material on which a co.pdf
 
Transactional model of communication states that if people are conne.pdf
Transactional model of communication states that if people are conne.pdfTransactional model of communication states that if people are conne.pdf
Transactional model of communication states that if people are conne.pdf
 
What is the measure of the strength of the relationship between inde.pdf
What is the measure of the strength of the relationship between inde.pdfWhat is the measure of the strength of the relationship between inde.pdf
What is the measure of the strength of the relationship between inde.pdf
 
Some of the SO32- is oxidized by atmospheric oxygen in air into SO42.pdf
Some of the SO32- is oxidized by atmospheric oxygen in air into SO42.pdfSome of the SO32- is oxidized by atmospheric oxygen in air into SO42.pdf
Some of the SO32- is oxidized by atmospheric oxygen in air into SO42.pdf
 
Should begin with a letter and may contain additional letters and di.pdf
Should begin with a letter and may contain additional letters and di.pdfShould begin with a letter and may contain additional letters and di.pdf
Should begin with a letter and may contain additional letters and di.pdf
 
#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf
 
Prostomes are mollusca, annelids and arthropods while deuterostomes .pdf
Prostomes are mollusca, annelids and arthropods while deuterostomes .pdfProstomes are mollusca, annelids and arthropods while deuterostomes .pdf
Prostomes are mollusca, annelids and arthropods while deuterostomes .pdf
 

Recently uploaded

MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MysoreMuleSoftMeetup
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 

Birthdaydate.javaimport java.util.Scanner;public class Birthdayd.pdf

  • 1. Birthdaydate.java import java.util.Scanner; public class Birthdaydate { public static void main(String[] args) { //Declaring variables char ch,ch1,ch2,ch3,ch4,ch5; //Declaring each card as an 2-Dimensional Array int card1[][]={{1,3,5,7},{9,11,13,15},{17,19,21,23},{25,27,29,31}}; int card2[][]={{2,3,6,7},{10,11,14,15},{18,19,22,23},{26,27,30,31}}; int card3[][]={{4,5,6,7},{12,13,14,15},{20,21,22,23},{28,29,30,31}}; int card4[][]={{8,9,10,11},{12,13,14,15},{24,25,26,27},{28,29,30,31}}; int card5[][]={{16,17,18,19},{20,21,22,23},{24,25,26,27},{28,29,30,31}}; //Scanner Object is used to get the inputs entered by the user Scanner sc = new Scanner(System.in); //This loop continue to execute until user enters 'Y' or 'y' do { //Declaring variable int sum=0; //Displaying card1 using nested for loop System.out.println(":: Card1 ::"); for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { System.out.printf("%3d",card1[i][j]); } System.out.println(" "); } //Prompting whether the day of birth is having in card1 or not.
  • 2. System.out.print("Do card#1 is having Your Birthday (Y/N):"); ch1 = sc.next(".").charAt(0); //If the day is in card 1,add the first row first column element to sum if(ch1=='Y' || ch1=='y') sum+=card1[0][0]; //Displaying card2 using nested for loop System.out.println(":: Card2 ::"); for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { System.out.printf("%3d",card2[i][j]); } System.out.println(" "); } //Prompting whether the day of birth is having in card2 or not. System.out.print("Do card#2 is having Your Birthday (Y/N):"); ch2 = sc.next(".").charAt(0); //If the day is in card 2,add the first row first column element to sum if(ch2=='Y' || ch2=='y') sum+=card2[0][0]; //Displaying card3 using nested for loop System.out.println(":: Card3 ::"); for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { System.out.printf("%3d",card3[i][j]); } System.out.println(" "); }
  • 3. //Prompting whether the day of birth is having in card3 or not. System.out.print("Do card#3 is having Your Birthday (Y/N):"); ch3 = sc.next(".").charAt(0); //If the day is in card 3,add the first row first column element to sum if(ch3=='Y' || ch3=='y') sum+=card3[0][0]; //Displaying card4 using nested for loop System.out.println(":: Card4 ::"); for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { System.out.printf("%3d",card4[i][j]); } System.out.println(" "); } //Prompting whether the day of birth is having in card4 or not. System.out.print("Do card#4 is having Your Birthday (Y/N):"); ch4 = sc.next(".").charAt(0); //If the day is in card 4,add the first row first column element to sum if(ch4=='Y' || ch4=='y') sum+=card4[0][0]; //Displaying card5 using nested for loop System.out.println(":: Card5 ::"); for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { System.out.printf("%3d",card5[i][j]); } System.out.println(" ");
  • 4. } //Prompting whether the day of birth is having in card5 or not. System.out.print("Do card#5 is having Your Birthday (Y/N):"); ch5 = sc.next(".").charAt(0); //If the day is in card 5,add the first row first column element to sum if(ch5=='Y' || ch5=='y') sum+=card5[0][0]; System.out.println("Your Birthday is "+sum); System.out.print(" Do You want to continue? (y/n): "); ch = sc.next(".").charAt(0); System.out.println("________________________________"); }while(ch=='Y' || ch=='y'); } } _________________________________________________ Output: :: Card1 :: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 Do card#1 is having Your Birthday (Y/N):y :: Card2 :: 2 3 6 7 10 11 14 15 18 19 22 23 26 27 30 31 Do card#2 is having Your Birthday (Y/N):y :: Card3 :: 4 5 6 7 12 13 14 15 20 21 22 23
  • 5. 28 29 30 31 Do card#3 is having Your Birthday (Y/N):n :: Card4 :: 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31 Do card#4 is having Your Birthday (Y/N):n :: Card5 :: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Do card#5 is having Your Birthday (Y/N):n Your Birthday is 3 Do You want to continue? (y/n): y :: Card1 :: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 Do card#1 is having Your Birthday (Y/N):n :: Card2 :: 2 3 6 7 10 11 14 15 18 19 22 23 26 27 30 31 Do card#2 is having Your Birthday (Y/N):y :: Card3 :: 4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31 Do card#3 is having Your Birthday (Y/N):n :: Card4 ::
  • 6. 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31 Do card#4 is having Your Birthday (Y/N):n :: Card5 :: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Do card#5 is having Your Birthday (Y/N):n Your Birthday is 2 Do You want to continue? (y/n): n ______________________________________________________ The reason this works because we are having the numbers of first row first column of cards as 1 2 4 8 16.With these 5 numbers we can amke any day between 1 and 31.Based on the Birthday present in the cards those corresponding first row first column of every card is getting added to find the birthday of the user. ______________________________________________________Thank you Solution Birthdaydate.java import java.util.Scanner; public class Birthdaydate { public static void main(String[] args) { //Declaring variables char ch,ch1,ch2,ch3,ch4,ch5; //Declaring each card as an 2-Dimensional Array int card1[][]={{1,3,5,7},{9,11,13,15},{17,19,21,23},{25,27,29,31}}; int card2[][]={{2,3,6,7},{10,11,14,15},{18,19,22,23},{26,27,30,31}}; int card3[][]={{4,5,6,7},{12,13,14,15},{20,21,22,23},{28,29,30,31}}; int card4[][]={{8,9,10,11},{12,13,14,15},{24,25,26,27},{28,29,30,31}}; int card5[][]={{16,17,18,19},{20,21,22,23},{24,25,26,27},{28,29,30,31}};
  • 7. //Scanner Object is used to get the inputs entered by the user Scanner sc = new Scanner(System.in); //This loop continue to execute until user enters 'Y' or 'y' do { //Declaring variable int sum=0; //Displaying card1 using nested for loop System.out.println(":: Card1 ::"); for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { System.out.printf("%3d",card1[i][j]); } System.out.println(" "); } //Prompting whether the day of birth is having in card1 or not. System.out.print("Do card#1 is having Your Birthday (Y/N):"); ch1 = sc.next(".").charAt(0); //If the day is in card 1,add the first row first column element to sum if(ch1=='Y' || ch1=='y') sum+=card1[0][0]; //Displaying card2 using nested for loop System.out.println(":: Card2 ::"); for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { System.out.printf("%3d",card2[i][j]);
  • 8. } System.out.println(" "); } //Prompting whether the day of birth is having in card2 or not. System.out.print("Do card#2 is having Your Birthday (Y/N):"); ch2 = sc.next(".").charAt(0); //If the day is in card 2,add the first row first column element to sum if(ch2=='Y' || ch2=='y') sum+=card2[0][0]; //Displaying card3 using nested for loop System.out.println(":: Card3 ::"); for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { System.out.printf("%3d",card3[i][j]); } System.out.println(" "); } //Prompting whether the day of birth is having in card3 or not. System.out.print("Do card#3 is having Your Birthday (Y/N):"); ch3 = sc.next(".").charAt(0); //If the day is in card 3,add the first row first column element to sum if(ch3=='Y' || ch3=='y') sum+=card3[0][0]; //Displaying card4 using nested for loop System.out.println(":: Card4 ::"); for(int i=0;i<4;i++) { for(int j=0;j<4;j++)
  • 9. { System.out.printf("%3d",card4[i][j]); } System.out.println(" "); } //Prompting whether the day of birth is having in card4 or not. System.out.print("Do card#4 is having Your Birthday (Y/N):"); ch4 = sc.next(".").charAt(0); //If the day is in card 4,add the first row first column element to sum if(ch4=='Y' || ch4=='y') sum+=card4[0][0]; //Displaying card5 using nested for loop System.out.println(":: Card5 ::"); for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { System.out.printf("%3d",card5[i][j]); } System.out.println(" "); } //Prompting whether the day of birth is having in card5 or not. System.out.print("Do card#5 is having Your Birthday (Y/N):"); ch5 = sc.next(".").charAt(0); //If the day is in card 5,add the first row first column element to sum if(ch5=='Y' || ch5=='y') sum+=card5[0][0]; System.out.println("Your Birthday is "+sum); System.out.print(" Do You want to continue? (y/n): "); ch = sc.next(".").charAt(0);
  • 10. System.out.println("________________________________"); }while(ch=='Y' || ch=='y'); } } _________________________________________________ Output: :: Card1 :: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 Do card#1 is having Your Birthday (Y/N):y :: Card2 :: 2 3 6 7 10 11 14 15 18 19 22 23 26 27 30 31 Do card#2 is having Your Birthday (Y/N):y :: Card3 :: 4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31 Do card#3 is having Your Birthday (Y/N):n :: Card4 :: 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31 Do card#4 is having Your Birthday (Y/N):n :: Card5 :: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Do card#5 is having Your Birthday (Y/N):n
  • 11. Your Birthday is 3 Do You want to continue? (y/n): y :: Card1 :: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 Do card#1 is having Your Birthday (Y/N):n :: Card2 :: 2 3 6 7 10 11 14 15 18 19 22 23 26 27 30 31 Do card#2 is having Your Birthday (Y/N):y :: Card3 :: 4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31 Do card#3 is having Your Birthday (Y/N):n :: Card4 :: 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31 Do card#4 is having Your Birthday (Y/N):n :: Card5 :: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Do card#5 is having Your Birthday (Y/N):n Your Birthday is 2 Do You want to continue? (y/n): n
  • 12. ______________________________________________________ The reason this works because we are having the numbers of first row first column of cards as 1 2 4 8 16.With these 5 numbers we can amke any day between 1 and 31.Based on the Birthday present in the cards those corresponding first row first column of every card is getting added to find the birthday of the user. ______________________________________________________Thank you