SlideShare a Scribd company logo
1 of 2
An input file A1.txt is given which contains a list of integer values. Write a program that reads
all the values from A1.txt and save them into an array. Prompt the user for an integer number and
count the frequency of that number within that array.
Sample input:
51 27 44 50 99 74 58 28 62 84 45 75 71 97 71
Enter the number you want to search: 71
Sample Output:
71 appeared 2 times
Solution
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;
public class CountFrequency {
public static void main(String[] args) throws NumberFormatException, IOException{
Scanner scanner;
Scanner sc;
int [] tall = new int[20];
try {
scanner = new Scanner(new File("A1.txt"));
sc = new Scanner(System.in);
int i = 0;
tall = new int [20];
while(scanner.hasNextInt())
{
tall[i++] = scanner.nextInt();
}
i=0;
System.out.println("Enter the number you want to search:");
int searchnumber= sc.nextInt();
int count=0;
for(i=0;i<15;i++){
if(tall[i]==searchnumber){
count++;
i++;
}else
i++;
}
System.out.println(searchnumber+" appeared "+count+" times.");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

More Related Content

Similar to An input file A1-txt is given which contains a list of integer values-.docx

Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptxKimVeeL
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfaioils
 
Modify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdfModify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdfsaxenaavnish1
 
Write a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxWrite a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxlez31palka
 
Here is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfHere is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfpratyushraj61
 
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
 
Codeimport java.util.Random; import java.util.Scanner;public .pdf
Codeimport java.util.Random; import java.util.Scanner;public .pdfCodeimport java.util.Random; import java.util.Scanner;public .pdf
Codeimport java.util.Random; import java.util.Scanner;public .pdfanupamfootwear
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptxKimVeeL
 
Anjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjaliSoorej
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntuKhurshid Asghar
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfrajeshjangid1865
 
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docxWrite a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docxlez31palka
 
Write the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdfWrite the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdfarihanthtoysandgifts
 
Demonstrating bully algorithm in java
Demonstrating bully algorithm in javaDemonstrating bully algorithm in java
Demonstrating bully algorithm in javaNagireddy Dwarampudi
 

Similar to An input file A1-txt is given which contains a list of integer values-.docx (16)

Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdf
 
Modify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdfModify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdf
 
Write a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxWrite a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docx
 
Java final lab
Java final labJava final lab
Java final lab
 
Here is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfHere is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.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
 
3.Lesson Plan - Input.pdf.pdf
3.Lesson Plan - Input.pdf.pdf3.Lesson Plan - Input.pdf.pdf
3.Lesson Plan - Input.pdf.pdf
 
Codeimport java.util.Random; import java.util.Scanner;public .pdf
Codeimport java.util.Random; import java.util.Scanner;public .pdfCodeimport java.util.Random; import java.util.Scanner;public .pdf
Codeimport java.util.Random; import java.util.Scanner;public .pdf
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
 
Anjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjalisoorej imca133 assignment
Anjalisoorej imca133 assignment
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntu
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
 
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docxWrite a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
 
Write the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdfWrite the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdf
 
Demonstrating bully algorithm in java
Demonstrating bully algorithm in javaDemonstrating bully algorithm in java
Demonstrating bully algorithm in java
 

More from lauracallander

Match the cell structure with the cell function- - Plasma Membrane A-.docx
Match the cell structure with the cell function- - Plasma Membrane A-.docxMatch the cell structure with the cell function- - Plasma Membrane A-.docx
Match the cell structure with the cell function- - Plasma Membrane A-.docxlauracallander
 
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docx
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docxMatrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docx
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docxlauracallander
 
Modify function partition so that it groups together all elements dupl.docx
Modify function partition so that it groups together all elements dupl.docxModify function partition so that it groups together all elements dupl.docx
Modify function partition so that it groups together all elements dupl.docxlauracallander
 
Michelle Walker- a college junior- normally prides herself on keeping.docx
Michelle Walker- a college junior- normally prides herself on keeping.docxMichelle Walker- a college junior- normally prides herself on keeping.docx
Michelle Walker- a college junior- normally prides herself on keeping.docxlauracallander
 
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docx
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docxMechanisms of Developmental Patterning 1- Explain how cell fate specif.docx
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docxlauracallander
 
Match each of the options above to the items below- The analysis and r.docx
Match each of the options above to the items below- The analysis and r.docxMatch each of the options above to the items below- The analysis and r.docx
Match each of the options above to the items below- The analysis and r.docxlauracallander
 
Match the term with its definition- Drag and drop options on the right.docx
Match the term with its definition- Drag and drop options on the right.docxMatch the term with its definition- Drag and drop options on the right.docx
Match the term with its definition- Drag and drop options on the right.docxlauracallander
 
Match the type of cell to cell signaling with its description- Contact.docx
Match the type of cell to cell signaling with its description- Contact.docxMatch the type of cell to cell signaling with its description- Contact.docx
Match the type of cell to cell signaling with its description- Contact.docxlauracallander
 
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docx
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docxMatch the soil order to its defining characteristic- Ultisol Oxisol Mo.docx
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docxlauracallander
 
Match the horizon with its indicative characteristics- O horizon A hor.docx
Match the horizon with its indicative characteristics- O horizon A hor.docxMatch the horizon with its indicative characteristics- O horizon A hor.docx
Match the horizon with its indicative characteristics- O horizon A hor.docxlauracallander
 
Match the term with its function in the body- Note- Terms may only be.docx
Match the term with its function in the body- Note- Terms may only be.docxMatch the term with its function in the body- Note- Terms may only be.docx
Match the term with its function in the body- Note- Terms may only be.docxlauracallander
 
Match each description to the correct term- Describes how a system wor.docx
Match each description to the correct term- Describes how a system wor.docxMatch each description to the correct term- Describes how a system wor.docx
Match each description to the correct term- Describes how a system wor.docxlauracallander
 
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docx
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docxMikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docx
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docxlauracallander
 
Mike writes a letter detailing how his roommate cheated on his exam- H.docx
Mike writes a letter detailing how his roommate cheated on his exam- H.docxMike writes a letter detailing how his roommate cheated on his exam- H.docx
Mike writes a letter detailing how his roommate cheated on his exam- H.docxlauracallander
 
Michael Jones recorded the following transactions during the month of.docx
Michael Jones recorded the following transactions during the month of.docxMichael Jones recorded the following transactions during the month of.docx
Michael Jones recorded the following transactions during the month of.docxlauracallander
 
microbiology List and explain the five characteristics of the adaptive.docx
microbiology List and explain the five characteristics of the adaptive.docxmicrobiology List and explain the five characteristics of the adaptive.docx
microbiology List and explain the five characteristics of the adaptive.docxlauracallander
 
Nova lab The date ranges for each of the hominins in this puzzle are g.docx
Nova lab The date ranges for each of the hominins in this puzzle are g.docxNova lab The date ranges for each of the hominins in this puzzle are g.docx
Nova lab The date ranges for each of the hominins in this puzzle are g.docxlauracallander
 
Marlin Company has the following projected costs for manufacturing and.docx
Marlin Company has the following projected costs for manufacturing and.docxMarlin Company has the following projected costs for manufacturing and.docx
Marlin Company has the following projected costs for manufacturing and.docxlauracallander
 
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docx
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docxNote the Borel sets are countably generated 13-11- 2-9 Show that- if f.docx
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docxlauracallander
 
Not all experience the COVID-19 pandemic the same way- There are facto.docx
Not all experience the COVID-19 pandemic the same way- There are facto.docxNot all experience the COVID-19 pandemic the same way- There are facto.docx
Not all experience the COVID-19 pandemic the same way- There are facto.docxlauracallander
 

More from lauracallander (20)

Match the cell structure with the cell function- - Plasma Membrane A-.docx
Match the cell structure with the cell function- - Plasma Membrane A-.docxMatch the cell structure with the cell function- - Plasma Membrane A-.docx
Match the cell structure with the cell function- - Plasma Membrane A-.docx
 
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docx
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docxMatrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docx
Matrice -nligs- int -ncols- int -matrice----- int +SELONLIGNES- int +S.docx
 
Modify function partition so that it groups together all elements dupl.docx
Modify function partition so that it groups together all elements dupl.docxModify function partition so that it groups together all elements dupl.docx
Modify function partition so that it groups together all elements dupl.docx
 
Michelle Walker- a college junior- normally prides herself on keeping.docx
Michelle Walker- a college junior- normally prides herself on keeping.docxMichelle Walker- a college junior- normally prides herself on keeping.docx
Michelle Walker- a college junior- normally prides herself on keeping.docx
 
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docx
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docxMechanisms of Developmental Patterning 1- Explain how cell fate specif.docx
Mechanisms of Developmental Patterning 1- Explain how cell fate specif.docx
 
Match each of the options above to the items below- The analysis and r.docx
Match each of the options above to the items below- The analysis and r.docxMatch each of the options above to the items below- The analysis and r.docx
Match each of the options above to the items below- The analysis and r.docx
 
Match the term with its definition- Drag and drop options on the right.docx
Match the term with its definition- Drag and drop options on the right.docxMatch the term with its definition- Drag and drop options on the right.docx
Match the term with its definition- Drag and drop options on the right.docx
 
Match the type of cell to cell signaling with its description- Contact.docx
Match the type of cell to cell signaling with its description- Contact.docxMatch the type of cell to cell signaling with its description- Contact.docx
Match the type of cell to cell signaling with its description- Contact.docx
 
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docx
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docxMatch the soil order to its defining characteristic- Ultisol Oxisol Mo.docx
Match the soil order to its defining characteristic- Ultisol Oxisol Mo.docx
 
Match the horizon with its indicative characteristics- O horizon A hor.docx
Match the horizon with its indicative characteristics- O horizon A hor.docxMatch the horizon with its indicative characteristics- O horizon A hor.docx
Match the horizon with its indicative characteristics- O horizon A hor.docx
 
Match the term with its function in the body- Note- Terms may only be.docx
Match the term with its function in the body- Note- Terms may only be.docxMatch the term with its function in the body- Note- Terms may only be.docx
Match the term with its function in the body- Note- Terms may only be.docx
 
Match each description to the correct term- Describes how a system wor.docx
Match each description to the correct term- Describes how a system wor.docxMatch each description to the correct term- Describes how a system wor.docx
Match each description to the correct term- Describes how a system wor.docx
 
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docx
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docxMikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docx
Mikhail's Portfolio- Mikhail Khodorkovsky was one of the infamous Russ.docx
 
Mike writes a letter detailing how his roommate cheated on his exam- H.docx
Mike writes a letter detailing how his roommate cheated on his exam- H.docxMike writes a letter detailing how his roommate cheated on his exam- H.docx
Mike writes a letter detailing how his roommate cheated on his exam- H.docx
 
Michael Jones recorded the following transactions during the month of.docx
Michael Jones recorded the following transactions during the month of.docxMichael Jones recorded the following transactions during the month of.docx
Michael Jones recorded the following transactions during the month of.docx
 
microbiology List and explain the five characteristics of the adaptive.docx
microbiology List and explain the five characteristics of the adaptive.docxmicrobiology List and explain the five characteristics of the adaptive.docx
microbiology List and explain the five characteristics of the adaptive.docx
 
Nova lab The date ranges for each of the hominins in this puzzle are g.docx
Nova lab The date ranges for each of the hominins in this puzzle are g.docxNova lab The date ranges for each of the hominins in this puzzle are g.docx
Nova lab The date ranges for each of the hominins in this puzzle are g.docx
 
Marlin Company has the following projected costs for manufacturing and.docx
Marlin Company has the following projected costs for manufacturing and.docxMarlin Company has the following projected costs for manufacturing and.docx
Marlin Company has the following projected costs for manufacturing and.docx
 
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docx
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docxNote the Borel sets are countably generated 13-11- 2-9 Show that- if f.docx
Note the Borel sets are countably generated 13-11- 2-9 Show that- if f.docx
 
Not all experience the COVID-19 pandemic the same way- There are facto.docx
Not all experience the COVID-19 pandemic the same way- There are facto.docxNot all experience the COVID-19 pandemic the same way- There are facto.docx
Not all experience the COVID-19 pandemic the same way- There are facto.docx
 

Recently uploaded

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
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
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
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
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
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
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
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
 

Recently uploaded (20)

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
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
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
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
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
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
 

An input file A1-txt is given which contains a list of integer values-.docx

  • 1. An input file A1.txt is given which contains a list of integer values. Write a program that reads all the values from A1.txt and save them into an array. Prompt the user for an integer number and count the frequency of that number within that array. Sample input: 51 27 44 50 99 74 58 28 62 84 45 75 71 97 71 Enter the number you want to search: 71 Sample Output: 71 appeared 2 times Solution import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Scanner; public class CountFrequency { public static void main(String[] args) throws NumberFormatException, IOException{ Scanner scanner; Scanner sc; int [] tall = new int[20]; try { scanner = new Scanner(new File("A1.txt")); sc = new Scanner(System.in); int i = 0; tall = new int [20]; while(scanner.hasNextInt()) { tall[i++] = scanner.nextInt(); } i=0; System.out.println("Enter the number you want to search:"); int searchnumber= sc.nextInt(); int count=0; for(i=0;i<15;i++){
  • 2. if(tall[i]==searchnumber){ count++; i++; }else i++; } System.out.println(searchnumber+" appeared "+count+" times."); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }