SlideShare a Scribd company logo
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.pdf
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
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
sudhinjv
 
#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
sudhinjv
 
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
sudhinjv
 

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

Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 

Recently uploaded (20)

Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 

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