SlideShare a Scribd company logo
1 of 3
Download to read offline
Please use Netbeans Write a program that teals the integers between 1 and 100 and counts the
occurrences of each. Assume the input etuis with 0. Here sample run of the program: Enter the
integers between 1 and 100 2 occurs 2 times 3 occurs 1 time 4 occurs 1 time 5 occurs 2 times
6 occurs 1 time 23 occurs 1 time 43 occurs 1 time
Solution
import java.util.Scanner;
//hi this scanner is to scan the input from user
public class Exercise {
public static void main(String[] args) {
Scanner cinput = new Scanner(System.in);
int[] numbers = new int[0];
int number;
System.out.print("Enter the integers between 1 and 100:");
// Take inputs and increase array size to accept more input until the
// input is 0
//when the input is 0 the while loop breaks
while ((number = cinput.nextInt()) != 0) {
numbers = add2Array(numbers, number);
}
int searchNumber = 0, searchCount = 0;
// going through the array
for (int j = 0; j < numbers.length; j++) {
// Define new search term if needed
if (searchNumber != numbers[j] && numbers[j] != 0) {
searchNumber = numbers[j];
// Search the array for the new terms starting from position of
// the new term to the end
for (int i = j; i < numbers.length; i++) {
if (searchNumber == numbers[i]) {
searchCount++;
numbers[i] = 0; // reset the found counted item to zero
// so it would not be seen again in the
// outer loop
}
}
System.out.print(searchNumber + " occurs " + searchCount
+ " time");
if (searchCount > 1) {
System.out.println("s");
} else {
System.out.println();
}
searchCount = 0;
}
}
}
// Copy array numbers1 to array numbers2
// If the length of array numbers2 is less then array numbers2, return false
public static boolean copyArray(int[] source, int[] dest) {
if (source.length > dest.length)
return false;
for (int i = 0; i < source.length; i++) {
dest[i] = source[i];
}
return true;
}
// Increase array size by one and add integer to the end of array
// Return new array
public static int[] add2Array(int[] source, int data) {
int[] dest = new int[source.length + 1];
copyArray(source, dest);
dest[source.length] = data;
return dest;
}
}
open a new project in netbeans ide and keep the name of class as Exercise and copy paste the
code given.If you still have any doughts regarding explanation you can comment below
Thank you

More Related Content

Similar to Please use Netbeans Write a program that teals the integers betwe.pdf

Import java
Import javaImport java
Import javaheni2121
 
Programming in Java: Arrays
Programming in Java: ArraysProgramming in Java: Arrays
Programming in Java: ArraysMartin Chapman
 
when I compile to get the survey title the overload constructor asks.docx
when I compile to get the survey title the overload constructor asks.docxwhen I compile to get the survey title the overload constructor asks.docx
when I compile to get the survey title the overload constructor asks.docxlashandaotley
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerAiman Hud
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfarihantmum
 
Please copy and paste the code and explain why it won't work- It is su.docx
Please copy and paste the code and explain why it won't work- It is su.docxPlease copy and paste the code and explain why it won't work- It is su.docx
Please copy and paste the code and explain why it won't work- It is su.docxcgraciela1
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptxKimVeeL
 
ch07-arrays.ppt
ch07-arrays.pptch07-arrays.ppt
ch07-arrays.pptMahyuddin8
 
import java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdfimport java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdfapexelectronices01
 
Visual Programing basic lectures 7.pptx
Visual Programing basic lectures  7.pptxVisual Programing basic lectures  7.pptx
Visual Programing basic lectures 7.pptxMrhaider4
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxamrit47
 
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfDigits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfannapurnnatextailes
 

Similar to Please use Netbeans Write a program that teals the integers betwe.pdf (13)

Import java
Import javaImport java
Import java
 
Programming in Java: Arrays
Programming in Java: ArraysProgramming in Java: Arrays
Programming in Java: Arrays
 
when I compile to get the survey title the overload constructor asks.docx
when I compile to get the survey title the overload constructor asks.docxwhen I compile to get the survey title the overload constructor asks.docx
when I compile to get the survey title the overload constructor asks.docx
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
 
Please copy and paste the code and explain why it won't work- It is su.docx
Please copy and paste the code and explain why it won't work- It is su.docxPlease copy and paste the code and explain why it won't work- It is su.docx
Please copy and paste the code and explain why it won't work- It is su.docx
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
 
ch07-arrays.ppt
ch07-arrays.pptch07-arrays.ppt
ch07-arrays.ppt
 
import java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdfimport java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdf
 
PSI 3 Integration
PSI 3 IntegrationPSI 3 Integration
PSI 3 Integration
 
Visual Programing basic lectures 7.pptx
Visual Programing basic lectures  7.pptxVisual Programing basic lectures  7.pptx
Visual Programing basic lectures 7.pptx
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
 
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfDigits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
 

More from montybachawat

Congestive heart failure is a common condition. What would be an ini.pdf
Congestive heart failure is a common condition. What would be an ini.pdfCongestive heart failure is a common condition. What would be an ini.pdf
Congestive heart failure is a common condition. What would be an ini.pdfmontybachawat
 
How many binary digits are needed to create 1024 combinationsA. 8.pdf
How many binary digits are needed to create 1024 combinationsA. 8.pdfHow many binary digits are needed to create 1024 combinationsA. 8.pdf
How many binary digits are needed to create 1024 combinationsA. 8.pdfmontybachawat
 
How does convection differ from conductionA) In convection, magnet.pdf
How does convection differ from conductionA) In convection, magnet.pdfHow does convection differ from conductionA) In convection, magnet.pdf
How does convection differ from conductionA) In convection, magnet.pdfmontybachawat
 
Circle ALL (if any) applicable terms for the events described.1.pdf
Circle ALL (if any) applicable terms for the events described.1.pdfCircle ALL (if any) applicable terms for the events described.1.pdf
Circle ALL (if any) applicable terms for the events described.1.pdfmontybachawat
 
Ed stays on Earth, and watches his twin Rob fly away in a rocket. E.pdf
Ed stays on Earth, and watches his twin Rob fly away in a rocket. E.pdfEd stays on Earth, and watches his twin Rob fly away in a rocket. E.pdf
Ed stays on Earth, and watches his twin Rob fly away in a rocket. E.pdfmontybachawat
 
Explain why the notochord is an evolutionary advacement. (what is a .pdf
Explain why the notochord is an evolutionary advacement. (what is a .pdfExplain why the notochord is an evolutionary advacement. (what is a .pdf
Explain why the notochord is an evolutionary advacement. (what is a .pdfmontybachawat
 
Describe 5 factors that could affect the quality of building and con.pdf
Describe 5 factors that could affect the quality of building and con.pdfDescribe 5 factors that could affect the quality of building and con.pdf
Describe 5 factors that could affect the quality of building and con.pdfmontybachawat
 
An anayzer is a device used to a. measure or control flow, temperatur.pdf
An anayzer is a device used to a. measure or control flow, temperatur.pdfAn anayzer is a device used to a. measure or control flow, temperatur.pdf
An anayzer is a device used to a. measure or control flow, temperatur.pdfmontybachawat
 
Can someone explain why the correct answer is D and while the other .pdf
Can someone explain why the correct answer is D and while the other .pdfCan someone explain why the correct answer is D and while the other .pdf
Can someone explain why the correct answer is D and while the other .pdfmontybachawat
 
At what layer of the OSI model would you find framingA. Transport.pdf
At what layer of the OSI model would you find framingA. Transport.pdfAt what layer of the OSI model would you find framingA. Transport.pdf
At what layer of the OSI model would you find framingA. Transport.pdfmontybachawat
 
You get a call from a home computer user saying her computer is very.pdf
You get a call from a home computer user saying her computer is very.pdfYou get a call from a home computer user saying her computer is very.pdf
You get a call from a home computer user saying her computer is very.pdfmontybachawat
 
Trace the path the red blood cell would take as it travels between t.pdf
Trace the path the red blood cell would take as it travels between t.pdfTrace the path the red blood cell would take as it travels between t.pdf
Trace the path the red blood cell would take as it travels between t.pdfmontybachawat
 
Which of the following represents a difference between viruses and vi.pdf
Which of the following represents a difference between viruses and vi.pdfWhich of the following represents a difference between viruses and vi.pdf
Which of the following represents a difference between viruses and vi.pdfmontybachawat
 
What is Impact Factor Derive a relationship between static and Dynam.pdf
What is Impact Factor Derive a relationship between static and Dynam.pdfWhat is Impact Factor Derive a relationship between static and Dynam.pdf
What is Impact Factor Derive a relationship between static and Dynam.pdfmontybachawat
 
What happens when a non-native species (plant or animal) is introduc.pdf
What happens when a non-native species (plant or animal) is introduc.pdfWhat happens when a non-native species (plant or animal) is introduc.pdf
What happens when a non-native species (plant or animal) is introduc.pdfmontybachawat
 
What are the techniques used in nanomanifacturing What are th.pdf
What are the techniques used in nanomanifacturing  What are th.pdfWhat are the techniques used in nanomanifacturing  What are th.pdf
What are the techniques used in nanomanifacturing What are th.pdfmontybachawat
 
What is the definition of hybrid system Could you give an example o.pdf
What is the definition of hybrid system Could you give an example o.pdfWhat is the definition of hybrid system Could you give an example o.pdf
What is the definition of hybrid system Could you give an example o.pdfmontybachawat
 
Using the phylogeny shown, which of the following is a shared derived.pdf
Using the phylogeny shown, which of the following is a shared derived.pdfUsing the phylogeny shown, which of the following is a shared derived.pdf
Using the phylogeny shown, which of the following is a shared derived.pdfmontybachawat
 
The systemic circuit delivers oxygenated blood to _ and returns blo.pdf
The systemic circuit delivers oxygenated blood to _ and returns blo.pdfThe systemic circuit delivers oxygenated blood to _ and returns blo.pdf
The systemic circuit delivers oxygenated blood to _ and returns blo.pdfmontybachawat
 
Categories. Use the .05 significance levelWhat is the null hypothe.pdf
Categories. Use the .05 significance levelWhat is the null hypothe.pdfCategories. Use the .05 significance levelWhat is the null hypothe.pdf
Categories. Use the .05 significance levelWhat is the null hypothe.pdfmontybachawat
 

More from montybachawat (20)

Congestive heart failure is a common condition. What would be an ini.pdf
Congestive heart failure is a common condition. What would be an ini.pdfCongestive heart failure is a common condition. What would be an ini.pdf
Congestive heart failure is a common condition. What would be an ini.pdf
 
How many binary digits are needed to create 1024 combinationsA. 8.pdf
How many binary digits are needed to create 1024 combinationsA. 8.pdfHow many binary digits are needed to create 1024 combinationsA. 8.pdf
How many binary digits are needed to create 1024 combinationsA. 8.pdf
 
How does convection differ from conductionA) In convection, magnet.pdf
How does convection differ from conductionA) In convection, magnet.pdfHow does convection differ from conductionA) In convection, magnet.pdf
How does convection differ from conductionA) In convection, magnet.pdf
 
Circle ALL (if any) applicable terms for the events described.1.pdf
Circle ALL (if any) applicable terms for the events described.1.pdfCircle ALL (if any) applicable terms for the events described.1.pdf
Circle ALL (if any) applicable terms for the events described.1.pdf
 
Ed stays on Earth, and watches his twin Rob fly away in a rocket. E.pdf
Ed stays on Earth, and watches his twin Rob fly away in a rocket. E.pdfEd stays on Earth, and watches his twin Rob fly away in a rocket. E.pdf
Ed stays on Earth, and watches his twin Rob fly away in a rocket. E.pdf
 
Explain why the notochord is an evolutionary advacement. (what is a .pdf
Explain why the notochord is an evolutionary advacement. (what is a .pdfExplain why the notochord is an evolutionary advacement. (what is a .pdf
Explain why the notochord is an evolutionary advacement. (what is a .pdf
 
Describe 5 factors that could affect the quality of building and con.pdf
Describe 5 factors that could affect the quality of building and con.pdfDescribe 5 factors that could affect the quality of building and con.pdf
Describe 5 factors that could affect the quality of building and con.pdf
 
An anayzer is a device used to a. measure or control flow, temperatur.pdf
An anayzer is a device used to a. measure or control flow, temperatur.pdfAn anayzer is a device used to a. measure or control flow, temperatur.pdf
An anayzer is a device used to a. measure or control flow, temperatur.pdf
 
Can someone explain why the correct answer is D and while the other .pdf
Can someone explain why the correct answer is D and while the other .pdfCan someone explain why the correct answer is D and while the other .pdf
Can someone explain why the correct answer is D and while the other .pdf
 
At what layer of the OSI model would you find framingA. Transport.pdf
At what layer of the OSI model would you find framingA. Transport.pdfAt what layer of the OSI model would you find framingA. Transport.pdf
At what layer of the OSI model would you find framingA. Transport.pdf
 
You get a call from a home computer user saying her computer is very.pdf
You get a call from a home computer user saying her computer is very.pdfYou get a call from a home computer user saying her computer is very.pdf
You get a call from a home computer user saying her computer is very.pdf
 
Trace the path the red blood cell would take as it travels between t.pdf
Trace the path the red blood cell would take as it travels between t.pdfTrace the path the red blood cell would take as it travels between t.pdf
Trace the path the red blood cell would take as it travels between t.pdf
 
Which of the following represents a difference between viruses and vi.pdf
Which of the following represents a difference between viruses and vi.pdfWhich of the following represents a difference between viruses and vi.pdf
Which of the following represents a difference between viruses and vi.pdf
 
What is Impact Factor Derive a relationship between static and Dynam.pdf
What is Impact Factor Derive a relationship between static and Dynam.pdfWhat is Impact Factor Derive a relationship between static and Dynam.pdf
What is Impact Factor Derive a relationship between static and Dynam.pdf
 
What happens when a non-native species (plant or animal) is introduc.pdf
What happens when a non-native species (plant or animal) is introduc.pdfWhat happens when a non-native species (plant or animal) is introduc.pdf
What happens when a non-native species (plant or animal) is introduc.pdf
 
What are the techniques used in nanomanifacturing What are th.pdf
What are the techniques used in nanomanifacturing  What are th.pdfWhat are the techniques used in nanomanifacturing  What are th.pdf
What are the techniques used in nanomanifacturing What are th.pdf
 
What is the definition of hybrid system Could you give an example o.pdf
What is the definition of hybrid system Could you give an example o.pdfWhat is the definition of hybrid system Could you give an example o.pdf
What is the definition of hybrid system Could you give an example o.pdf
 
Using the phylogeny shown, which of the following is a shared derived.pdf
Using the phylogeny shown, which of the following is a shared derived.pdfUsing the phylogeny shown, which of the following is a shared derived.pdf
Using the phylogeny shown, which of the following is a shared derived.pdf
 
The systemic circuit delivers oxygenated blood to _ and returns blo.pdf
The systemic circuit delivers oxygenated blood to _ and returns blo.pdfThe systemic circuit delivers oxygenated blood to _ and returns blo.pdf
The systemic circuit delivers oxygenated blood to _ and returns blo.pdf
 
Categories. Use the .05 significance levelWhat is the null hypothe.pdf
Categories. Use the .05 significance levelWhat is the null hypothe.pdfCategories. Use the .05 significance levelWhat is the null hypothe.pdf
Categories. Use the .05 significance levelWhat is the null hypothe.pdf
 

Recently uploaded

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
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
 

Recently uploaded (20)

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
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
 

Please use Netbeans Write a program that teals the integers betwe.pdf

  • 1. Please use Netbeans Write a program that teals the integers between 1 and 100 and counts the occurrences of each. Assume the input etuis with 0. Here sample run of the program: Enter the integers between 1 and 100 2 occurs 2 times 3 occurs 1 time 4 occurs 1 time 5 occurs 2 times 6 occurs 1 time 23 occurs 1 time 43 occurs 1 time Solution import java.util.Scanner; //hi this scanner is to scan the input from user public class Exercise { public static void main(String[] args) { Scanner cinput = new Scanner(System.in); int[] numbers = new int[0]; int number; System.out.print("Enter the integers between 1 and 100:"); // Take inputs and increase array size to accept more input until the // input is 0 //when the input is 0 the while loop breaks while ((number = cinput.nextInt()) != 0) { numbers = add2Array(numbers, number); } int searchNumber = 0, searchCount = 0; // going through the array for (int j = 0; j < numbers.length; j++) { // Define new search term if needed if (searchNumber != numbers[j] && numbers[j] != 0) { searchNumber = numbers[j];
  • 2. // Search the array for the new terms starting from position of // the new term to the end for (int i = j; i < numbers.length; i++) { if (searchNumber == numbers[i]) { searchCount++; numbers[i] = 0; // reset the found counted item to zero // so it would not be seen again in the // outer loop } } System.out.print(searchNumber + " occurs " + searchCount + " time"); if (searchCount > 1) { System.out.println("s"); } else { System.out.println(); } searchCount = 0; } } } // Copy array numbers1 to array numbers2 // If the length of array numbers2 is less then array numbers2, return false public static boolean copyArray(int[] source, int[] dest) { if (source.length > dest.length) return false; for (int i = 0; i < source.length; i++) { dest[i] = source[i]; } return true;
  • 3. } // Increase array size by one and add integer to the end of array // Return new array public static int[] add2Array(int[] source, int data) { int[] dest = new int[source.length + 1]; copyArray(source, dest); dest[source.length] = data; return dest; } } open a new project in netbeans ide and keep the name of class as Exercise and copy paste the code given.If you still have any doughts regarding explanation you can comment below Thank you