SlideShare a Scribd company logo
1 of 3
Download to read offline
import java.util.Scanner;
public class Digits
{
public static void main(String[] args)
{
int oddCount = 0, evenCount = 0, zeroCount = 0; //digit counters
int value, digit; //stores input value and digit respectively
int copy; //stores copy of entry
Scanner scan = new Scanner(System.in);
//Get value from user
System.out.println("enter number :");
int value=scan.nextInt();
copy=value;
//Make the value positive
value=Math.abs(value);
//What if the value is actually zero?
if(value==0)
zeroCount++;
while(value>0)
{
digit=value10;
if(digit==0)
zerocount++;
if(digit%2==0)
evenCount++;
else
oddCount++;
value=value/10;
}
System.out.println("original value:"+copy);
System.out.println("zero digits :"+zeroCount);
System.out.println("odd digits :"+oddCount);
System.out.println("even digits :"+evenCount)
}
}
Solution
import java.util.Scanner;
public class Digits
{
public static void main(String[] args)
{
int oddCount = 0, evenCount = 0, zeroCount = 0; //digit counters
int value, digit; //stores input value and digit respectively
int copy; //stores copy of entry
Scanner scan = new Scanner(System.in);
//Get value from user
System.out.println("enter number :");
int value=scan.nextInt();
copy=value;
//Make the value positive
value=Math.abs(value);
//What if the value is actually zero?
if(value==0)
zeroCount++;
while(value>0)
{
digit=value10;
if(digit==0)
zerocount++;
if(digit%2==0)
evenCount++;
else
oddCount++;
value=value/10;
}
System.out.println("original value:"+copy);
System.out.println("zero digits :"+zeroCount);
System.out.println("odd digits :"+oddCount);
System.out.println("even digits :"+evenCount)
}
}

More Related Content

Similar to import java.util.Scanner;public class Digits { public static v.pdf

Assume you have a scanner object (called input).Declare an integer.pdf
Assume you have a scanner object (called input).Declare an integer.pdfAssume you have a scanner object (called input).Declare an integer.pdf
Assume you have a scanner object (called input).Declare an integer.pdfezzi552
 
I need to create a data type that implement the following interface -.docx
I need to create a data type that implement the following interface -.docxI need to create a data type that implement the following interface -.docx
I need to create a data type that implement the following interface -.docxmckerliejonelle
 
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdf
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdfArrayTest.java import java.util.Arrays; import java.util.Scann.pdf
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdfdeepua8
 
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfMagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfanjanacottonmills
 
Import java
Import javaImport java
Import javaheni2121
 
import java.util.Scanner;public class ArrayOperation {    inp.pdf
import java.util.Scanner;public class ArrayOperation {     inp.pdfimport java.util.Scanner;public class ArrayOperation {     inp.pdf
import java.util.Scanner;public class ArrayOperation {    inp.pdfangelsfashion1
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docxKatecate1
 
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docxdorisc7
 

Similar to import java.util.Scanner;public class Digits { public static v.pdf (9)

Assume you have a scanner object (called input).Declare an integer.pdf
Assume you have a scanner object (called input).Declare an integer.pdfAssume you have a scanner object (called input).Declare an integer.pdf
Assume you have a scanner object (called input).Declare an integer.pdf
 
I need to create a data type that implement the following interface -.docx
I need to create a data type that implement the following interface -.docxI need to create a data type that implement the following interface -.docx
I need to create a data type that implement the following interface -.docx
 
Oot practical
Oot practicalOot practical
Oot practical
 
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdf
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdfArrayTest.java import java.util.Arrays; import java.util.Scann.pdf
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdf
 
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfMagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
 
Import java
Import javaImport java
Import java
 
import java.util.Scanner;public class ArrayOperation {    inp.pdf
import java.util.Scanner;public class ArrayOperation {     inp.pdfimport java.util.Scanner;public class ArrayOperation {     inp.pdf
import java.util.Scanner;public class ArrayOperation {    inp.pdf
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docx
 
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
 

More from apexelectronices01

Yes, its true that most mutations are deleterious however there ar.pdf
Yes, its true that most mutations are deleterious however there ar.pdfYes, its true that most mutations are deleterious however there ar.pdf
Yes, its true that most mutations are deleterious however there ar.pdfapexelectronices01
 
we found sp3 hybrid orbitals on the central atom in NH3Solution.pdf
we found sp3 hybrid orbitals on the central atom in NH3Solution.pdfwe found sp3 hybrid orbitals on the central atom in NH3Solution.pdf
we found sp3 hybrid orbitals on the central atom in NH3Solution.pdfapexelectronices01
 
The definitions of process just given could just as easily apply to .pdf
The definitions of process just given could just as easily apply to .pdfThe definitions of process just given could just as easily apply to .pdf
The definitions of process just given could just as easily apply to .pdfapexelectronices01
 
SolutionThe string which has two different syntax trees is -id-id.pdf
SolutionThe string which has two different syntax trees is -id-id.pdfSolutionThe string which has two different syntax trees is -id-id.pdf
SolutionThe string which has two different syntax trees is -id-id.pdfapexelectronices01
 
RhizopusRhizopus is a genus of common saprophytic fungi on plants .pdf
RhizopusRhizopus is a genus of common saprophytic fungi on plants .pdfRhizopusRhizopus is a genus of common saprophytic fungi on plants .pdf
RhizopusRhizopus is a genus of common saprophytic fungi on plants .pdfapexelectronices01
 
Small interfering RNA (siRNA) and microRNA silence genes at the tran.pdf
Small interfering RNA (siRNA) and microRNA silence genes at the tran.pdfSmall interfering RNA (siRNA) and microRNA silence genes at the tran.pdf
Small interfering RNA (siRNA) and microRNA silence genes at the tran.pdfapexelectronices01
 
private int func(int m, int n){if(mn)return 0;else return1+.pdf
private int func(int m, int n){if(mn)return 0;else return1+.pdfprivate int func(int m, int n){if(mn)return 0;else return1+.pdf
private int func(int m, int n){if(mn)return 0;else return1+.pdfapexelectronices01
 
Questions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfQuestions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfapexelectronices01
 
Ques-1 How would agriculture be impacted in this country if the soi.pdf
Ques-1 How would agriculture be impacted in this country if the soi.pdfQues-1 How would agriculture be impacted in this country if the soi.pdf
Ques-1 How would agriculture be impacted in this country if the soi.pdfapexelectronices01
 
Percentile RanksStandard Scores and Scaled ScoresSolutionPer.pdf
Percentile RanksStandard Scores and Scaled ScoresSolutionPer.pdfPercentile RanksStandard Scores and Scaled ScoresSolutionPer.pdf
Percentile RanksStandard Scores and Scaled ScoresSolutionPer.pdfapexelectronices01
 
I hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdfI hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdfapexelectronices01
 
H3PO4(aq) + NaOH(aq) -- H2O(aq) + H2PO4(2-)(aq) + Na+ (aq) Hl(aq).pdf
H3PO4(aq) + NaOH(aq) -- H2O(aq) + H2PO4(2-)(aq) + Na+ (aq) Hl(aq).pdfH3PO4(aq) + NaOH(aq) -- H2O(aq) + H2PO4(2-)(aq) + Na+ (aq) Hl(aq).pdf
H3PO4(aq) + NaOH(aq) -- H2O(aq) + H2PO4(2-)(aq) + Na+ (aq) Hl(aq).pdfapexelectronices01
 
(a) tetrabromocuprate(II)[Cu(Br)4]2-(b) potassiumtrioxalatochrom.pdf
(a) tetrabromocuprate(II)[Cu(Br)4]2-(b) potassiumtrioxalatochrom.pdf(a) tetrabromocuprate(II)[Cu(Br)4]2-(b) potassiumtrioxalatochrom.pdf
(a) tetrabromocuprate(II)[Cu(Br)4]2-(b) potassiumtrioxalatochrom.pdfapexelectronices01
 
Consuming both E.coli and Salmonella are risky. But Salmonella is mu.pdf
Consuming both E.coli and Salmonella are risky. But Salmonella is mu.pdfConsuming both E.coli and Salmonella are risky. But Salmonella is mu.pdf
Consuming both E.coli and Salmonella are risky. But Salmonella is mu.pdfapexelectronices01
 
Debt-equity ratio=DebtequityHence debt=0.65equityLet equity be .pdf
Debt-equity ratio=DebtequityHence debt=0.65equityLet equity be .pdfDebt-equity ratio=DebtequityHence debt=0.65equityLet equity be .pdf
Debt-equity ratio=DebtequityHence debt=0.65equityLet equity be .pdfapexelectronices01
 
As we move from left to right in a period the E.N valuesincreases & .pdf
As we move from left to right in a period the E.N valuesincreases & .pdfAs we move from left to right in a period the E.N valuesincreases & .pdf
As we move from left to right in a period the E.N valuesincreases & .pdfapexelectronices01
 
Answernondiversifiable riskmeaningRisk of an investment asset .pdf
Answernondiversifiable riskmeaningRisk of an investment asset .pdfAnswernondiversifiable riskmeaningRisk of an investment asset .pdf
Answernondiversifiable riskmeaningRisk of an investment asset .pdfapexelectronices01
 
The population distribution is normal.Solution The population.pdf
 The population distribution is normal.Solution The population.pdf The population distribution is normal.Solution The population.pdf
The population distribution is normal.Solution The population.pdfapexelectronices01
 
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
 PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdfapexelectronices01
 
Let v be the number of vertices. Then Eulers formula tells,.pdf
 Let v be the number of vertices. Then Eulers formula tells,.pdf Let v be the number of vertices. Then Eulers formula tells,.pdf
Let v be the number of vertices. Then Eulers formula tells,.pdfapexelectronices01
 

More from apexelectronices01 (20)

Yes, its true that most mutations are deleterious however there ar.pdf
Yes, its true that most mutations are deleterious however there ar.pdfYes, its true that most mutations are deleterious however there ar.pdf
Yes, its true that most mutations are deleterious however there ar.pdf
 
we found sp3 hybrid orbitals on the central atom in NH3Solution.pdf
we found sp3 hybrid orbitals on the central atom in NH3Solution.pdfwe found sp3 hybrid orbitals on the central atom in NH3Solution.pdf
we found sp3 hybrid orbitals on the central atom in NH3Solution.pdf
 
The definitions of process just given could just as easily apply to .pdf
The definitions of process just given could just as easily apply to .pdfThe definitions of process just given could just as easily apply to .pdf
The definitions of process just given could just as easily apply to .pdf
 
SolutionThe string which has two different syntax trees is -id-id.pdf
SolutionThe string which has two different syntax trees is -id-id.pdfSolutionThe string which has two different syntax trees is -id-id.pdf
SolutionThe string which has two different syntax trees is -id-id.pdf
 
RhizopusRhizopus is a genus of common saprophytic fungi on plants .pdf
RhizopusRhizopus is a genus of common saprophytic fungi on plants .pdfRhizopusRhizopus is a genus of common saprophytic fungi on plants .pdf
RhizopusRhizopus is a genus of common saprophytic fungi on plants .pdf
 
Small interfering RNA (siRNA) and microRNA silence genes at the tran.pdf
Small interfering RNA (siRNA) and microRNA silence genes at the tran.pdfSmall interfering RNA (siRNA) and microRNA silence genes at the tran.pdf
Small interfering RNA (siRNA) and microRNA silence genes at the tran.pdf
 
private int func(int m, int n){if(mn)return 0;else return1+.pdf
private int func(int m, int n){if(mn)return 0;else return1+.pdfprivate int func(int m, int n){if(mn)return 0;else return1+.pdf
private int func(int m, int n){if(mn)return 0;else return1+.pdf
 
Questions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfQuestions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdf
 
Ques-1 How would agriculture be impacted in this country if the soi.pdf
Ques-1 How would agriculture be impacted in this country if the soi.pdfQues-1 How would agriculture be impacted in this country if the soi.pdf
Ques-1 How would agriculture be impacted in this country if the soi.pdf
 
Percentile RanksStandard Scores and Scaled ScoresSolutionPer.pdf
Percentile RanksStandard Scores and Scaled ScoresSolutionPer.pdfPercentile RanksStandard Scores and Scaled ScoresSolutionPer.pdf
Percentile RanksStandard Scores and Scaled ScoresSolutionPer.pdf
 
I hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdfI hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdf
 
H3PO4(aq) + NaOH(aq) -- H2O(aq) + H2PO4(2-)(aq) + Na+ (aq) Hl(aq).pdf
H3PO4(aq) + NaOH(aq) -- H2O(aq) + H2PO4(2-)(aq) + Na+ (aq) Hl(aq).pdfH3PO4(aq) + NaOH(aq) -- H2O(aq) + H2PO4(2-)(aq) + Na+ (aq) Hl(aq).pdf
H3PO4(aq) + NaOH(aq) -- H2O(aq) + H2PO4(2-)(aq) + Na+ (aq) Hl(aq).pdf
 
(a) tetrabromocuprate(II)[Cu(Br)4]2-(b) potassiumtrioxalatochrom.pdf
(a) tetrabromocuprate(II)[Cu(Br)4]2-(b) potassiumtrioxalatochrom.pdf(a) tetrabromocuprate(II)[Cu(Br)4]2-(b) potassiumtrioxalatochrom.pdf
(a) tetrabromocuprate(II)[Cu(Br)4]2-(b) potassiumtrioxalatochrom.pdf
 
Consuming both E.coli and Salmonella are risky. But Salmonella is mu.pdf
Consuming both E.coli and Salmonella are risky. But Salmonella is mu.pdfConsuming both E.coli and Salmonella are risky. But Salmonella is mu.pdf
Consuming both E.coli and Salmonella are risky. But Salmonella is mu.pdf
 
Debt-equity ratio=DebtequityHence debt=0.65equityLet equity be .pdf
Debt-equity ratio=DebtequityHence debt=0.65equityLet equity be .pdfDebt-equity ratio=DebtequityHence debt=0.65equityLet equity be .pdf
Debt-equity ratio=DebtequityHence debt=0.65equityLet equity be .pdf
 
As we move from left to right in a period the E.N valuesincreases & .pdf
As we move from left to right in a period the E.N valuesincreases & .pdfAs we move from left to right in a period the E.N valuesincreases & .pdf
As we move from left to right in a period the E.N valuesincreases & .pdf
 
Answernondiversifiable riskmeaningRisk of an investment asset .pdf
Answernondiversifiable riskmeaningRisk of an investment asset .pdfAnswernondiversifiable riskmeaningRisk of an investment asset .pdf
Answernondiversifiable riskmeaningRisk of an investment asset .pdf
 
The population distribution is normal.Solution The population.pdf
 The population distribution is normal.Solution The population.pdf The population distribution is normal.Solution The population.pdf
The population distribution is normal.Solution The population.pdf
 
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
 PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
 
Let v be the number of vertices. Then Eulers formula tells,.pdf
 Let v be the number of vertices. Then Eulers formula tells,.pdf Let v be the number of vertices. Then Eulers formula tells,.pdf
Let v be the number of vertices. Then Eulers formula tells,.pdf
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 

Recently uploaded (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 

import java.util.Scanner;public class Digits { public static v.pdf

  • 1. import java.util.Scanner; public class Digits { public static void main(String[] args) { int oddCount = 0, evenCount = 0, zeroCount = 0; //digit counters int value, digit; //stores input value and digit respectively int copy; //stores copy of entry Scanner scan = new Scanner(System.in); //Get value from user System.out.println("enter number :"); int value=scan.nextInt(); copy=value; //Make the value positive value=Math.abs(value); //What if the value is actually zero? if(value==0) zeroCount++; while(value>0) { digit=value10; if(digit==0) zerocount++; if(digit%2==0) evenCount++; else oddCount++; value=value/10; } System.out.println("original value:"+copy); System.out.println("zero digits :"+zeroCount); System.out.println("odd digits :"+oddCount); System.out.println("even digits :"+evenCount) }
  • 2. } Solution import java.util.Scanner; public class Digits { public static void main(String[] args) { int oddCount = 0, evenCount = 0, zeroCount = 0; //digit counters int value, digit; //stores input value and digit respectively int copy; //stores copy of entry Scanner scan = new Scanner(System.in); //Get value from user System.out.println("enter number :"); int value=scan.nextInt(); copy=value; //Make the value positive value=Math.abs(value); //What if the value is actually zero? if(value==0) zeroCount++; while(value>0) { digit=value10; if(digit==0) zerocount++; if(digit%2==0) evenCount++; else oddCount++; value=value/10; } System.out.println("original value:"+copy); System.out.println("zero digits :"+zeroCount);