SlideShare a Scribd company logo
1 of 1
Download to read offline
Using the code below:
Part 1: Write a static method called LinkedListToStack that takes a Node reference as a parameter
(which represents a linked list). Add every element in the linked list to a stack and return the stack.
Part 2: Write a static method called avgOfNumbersInStack that takes a stack of Integer as a
parameter. It will return a double value which is the average of all the numbers in the stack.
package activity9;
import java.util.Scanner;
import java.util.*;
public class StackPractice {
public static Node listGenerator(int input)
{
int n;
int count = 0;
Random rand = new Random();
n = rand.nextInt(100);
Node head = null;
head = new Node(n);
count++;
while(count < input) {
Node t1 = new Node(n = rand.nextInt(100), head);
head = t1;
count++;
}
return head;
}
public static void printLinkedList(Node input) {
Node curr = input;
while(curr != null) {
System.out.println(curr.item);
curr = curr.next;
}
}
public static void main(String[] args) {
Scanner kbd = new Scanner(System.in);
int input = 0;
System.out.print("Please enter the starting integer: ");
input = Integer.parseInt(kbd.nextLine());
listGenerator(input);
printLinkedList(listGenerator(input));
}
}

More Related Content

Similar to Using the code below Part 1 Write a static method called L.pdf

Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfrozakashif85
 
(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manualChandrapriya Jayabal
 
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfherminaherman
 
Removal Of Recursion
Removal Of RecursionRemoval Of Recursion
Removal Of RecursionRicha Sharma
 
There are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdfThere are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdfaamousnowov
 
ObjectivesMore practice with recursion.Practice writing some tem.docx
ObjectivesMore practice with recursion.Practice writing some tem.docxObjectivesMore practice with recursion.Practice writing some tem.docx
ObjectivesMore practice with recursion.Practice writing some tem.docxvannagoforth
 
Stack linked list
Stack linked listStack linked list
Stack linked listbhargav0077
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to ArraysTareq Hasan
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxBrianGHiNewmanv
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfConint29
 
Objective Min-heap queue with customized comparatorHospital emerg.pdf
Objective Min-heap queue with customized comparatorHospital emerg.pdfObjective Min-heap queue with customized comparatorHospital emerg.pdf
Objective Min-heap queue with customized comparatorHospital emerg.pdfezhilvizhiyan
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfmail931892
 
Write an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdfWrite an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdfArrowdeepak
 
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfkostikjaylonshaewe47
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data StructureZidny Nafan
 

Similar to Using the code below Part 1 Write a static method called L.pdf (20)

Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
 
Applet
AppletApplet
Applet
 
(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual(674335607) cs2309 java-lab-manual
(674335607) cs2309 java-lab-manual
 
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdf
 
Oot practical
Oot practicalOot practical
Oot practical
 
Removal Of Recursion
Removal Of RecursionRemoval Of Recursion
Removal Of Recursion
 
Lab-2.4 101.pdf
Lab-2.4 101.pdfLab-2.4 101.pdf
Lab-2.4 101.pdf
 
There are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdfThere are a couple of new methods that you will be writing for this pr.pdf
There are a couple of new methods that you will be writing for this pr.pdf
 
ObjectivesMore practice with recursion.Practice writing some tem.docx
ObjectivesMore practice with recursion.Practice writing some tem.docxObjectivesMore practice with recursion.Practice writing some tem.docx
ObjectivesMore practice with recursion.Practice writing some tem.docx
 
Array in Java
Array in JavaArray in Java
Array in Java
 
Array Cont
Array ContArray Cont
Array Cont
 
Stack linked list
Stack linked listStack linked list
Stack linked list
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
 
Objective Min-heap queue with customized comparatorHospital emerg.pdf
Objective Min-heap queue with customized comparatorHospital emerg.pdfObjective Min-heap queue with customized comparatorHospital emerg.pdf
Objective Min-heap queue with customized comparatorHospital emerg.pdf
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
 
Write an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdfWrite an algorithm that reads a list of integers from the keyboard, .pdf
Write an algorithm that reads a list of integers from the keyboard, .pdf
 
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 

More from picscamshoppe

VAKA ALIMASI 100 Hassas kaynak snrl projelerde bo zaman .pdf
VAKA ALIMASI 100  Hassas kaynak snrl projelerde bo zaman .pdfVAKA ALIMASI 100  Hassas kaynak snrl projelerde bo zaman .pdf
VAKA ALIMASI 100 Hassas kaynak snrl projelerde bo zaman .pdfpicscamshoppe
 
Vaka 8 Patagonya Tutkulu alanlar ekmek ve Glendirmek .pdf
Vaka 8 Patagonya Tutkulu alanlar ekmek ve Glendirmek .pdfVaka 8 Patagonya Tutkulu alanlar ekmek ve Glendirmek .pdf
Vaka 8 Patagonya Tutkulu alanlar ekmek ve Glendirmek .pdfpicscamshoppe
 
Uyumluluk denetimi genellikle denetimlerin tesine geerek a.pdf
Uyumluluk denetimi genellikle denetimlerin tesine geerek a.pdfUyumluluk denetimi genellikle denetimlerin tesine geerek a.pdf
Uyumluluk denetimi genellikle denetimlerin tesine geerek a.pdfpicscamshoppe
 
Uzun vadeli yatrm kararlar ile ilgilenen finans alan olarak .pdf
Uzun vadeli yatrm kararlar ile ilgilenen finans alan olarak .pdfUzun vadeli yatrm kararlar ile ilgilenen finans alan olarak .pdf
Uzun vadeli yatrm kararlar ile ilgilenen finans alan olarak .pdfpicscamshoppe
 
Vaka 101 Zappos Yneticileri Ortadan Kaldryor evrimii ay.pdf
Vaka 101 Zappos Yneticileri Ortadan Kaldryor  evrimii ay.pdfVaka 101 Zappos Yneticileri Ortadan Kaldryor  evrimii ay.pdf
Vaka 101 Zappos Yneticileri Ortadan Kaldryor evrimii ay.pdfpicscamshoppe
 
Utilizacin de la inteligencia emocional en el lugar de trab.pdf
Utilizacin de la inteligencia emocional en el lugar de trab.pdfUtilizacin de la inteligencia emocional en el lugar de trab.pdf
Utilizacin de la inteligencia emocional en el lugar de trab.pdfpicscamshoppe
 
Utilizando el concepto de conocimiento metacognitivo los pr.pdf
Utilizando el concepto de conocimiento metacognitivo los pr.pdfUtilizando el concepto de conocimiento metacognitivo los pr.pdf
Utilizando el concepto de conocimiento metacognitivo los pr.pdfpicscamshoppe
 
Usted es miembro del grupo de relaciones con los empleados d.pdf
Usted es miembro del grupo de relaciones con los empleados d.pdfUsted es miembro del grupo de relaciones con los empleados d.pdf
Usted es miembro del grupo de relaciones con los empleados d.pdfpicscamshoppe
 
Usted es consultor comercial de People for the Ethical Treat.pdf
Usted es consultor comercial de People for the Ethical Treat.pdfUsted es consultor comercial de People for the Ethical Treat.pdf
Usted es consultor comercial de People for the Ethical Treat.pdfpicscamshoppe
 
usptrerl the following recerd was krpe ale 50PA a the .pdf
usptrerl the following recerd was krpe ale 50PA a the .pdfusptrerl the following recerd was krpe ale 50PA a the .pdf
usptrerl the following recerd was krpe ale 50PA a the .pdfpicscamshoppe
 
Using Ubuntu write a progam in C that do this A Wait for .pdf
Using Ubuntu write a progam in C that do this A Wait for .pdfUsing Ubuntu write a progam in C that do this A Wait for .pdf
Using Ubuntu write a progam in C that do this A Wait for .pdfpicscamshoppe
 
Using Ubuntu write a program uin C that do this A Wait for.pdf
Using Ubuntu write a program uin C that do this A Wait for.pdfUsing Ubuntu write a program uin C that do this A Wait for.pdf
Using Ubuntu write a program uin C that do this A Wait for.pdfpicscamshoppe
 
Using the RamseyCassKoopmans Model what policy would best.pdf
Using the RamseyCassKoopmans Model what policy would best.pdfUsing the RamseyCassKoopmans Model what policy would best.pdf
Using the RamseyCassKoopmans Model what policy would best.pdfpicscamshoppe
 
Using the pypcaptile library already available in the VLE.pdf
Using the pypcaptile library already available in the VLE.pdfUsing the pypcaptile library already available in the VLE.pdf
Using the pypcaptile library already available in the VLE.pdfpicscamshoppe
 
Using the Mpgcsv dataset b Run a basic linear regression.pdf
Using the Mpgcsv dataset b  Run a basic linear regression.pdfUsing the Mpgcsv dataset b  Run a basic linear regression.pdf
Using the Mpgcsv dataset b Run a basic linear regression.pdfpicscamshoppe
 
Using the payoffs for the HawkDove game that we discussed i.pdf
Using the payoffs for the HawkDove game that we discussed i.pdfUsing the payoffs for the HawkDove game that we discussed i.pdf
Using the payoffs for the HawkDove game that we discussed i.pdfpicscamshoppe
 
Using the line for the Annual mean calculate the average .pdf
Using the line for the Annual mean calculate the average .pdfUsing the line for the Annual mean calculate the average .pdf
Using the line for the Annual mean calculate the average .pdfpicscamshoppe
 
Using the information below to answer the following two ques.pdf
Using the information below to answer the following two ques.pdfUsing the information below to answer the following two ques.pdf
Using the information below to answer the following two ques.pdfpicscamshoppe
 
Using the information below to answer the following three qu.pdf
Using the information below to answer the following three qu.pdfUsing the information below to answer the following three qu.pdf
Using the information below to answer the following three qu.pdfpicscamshoppe
 
Using the following UML please create this java code I spe.pdf
Using the following UML please create this java code  I spe.pdfUsing the following UML please create this java code  I spe.pdf
Using the following UML please create this java code I spe.pdfpicscamshoppe
 

More from picscamshoppe (20)

VAKA ALIMASI 100 Hassas kaynak snrl projelerde bo zaman .pdf
VAKA ALIMASI 100  Hassas kaynak snrl projelerde bo zaman .pdfVAKA ALIMASI 100  Hassas kaynak snrl projelerde bo zaman .pdf
VAKA ALIMASI 100 Hassas kaynak snrl projelerde bo zaman .pdf
 
Vaka 8 Patagonya Tutkulu alanlar ekmek ve Glendirmek .pdf
Vaka 8 Patagonya Tutkulu alanlar ekmek ve Glendirmek .pdfVaka 8 Patagonya Tutkulu alanlar ekmek ve Glendirmek .pdf
Vaka 8 Patagonya Tutkulu alanlar ekmek ve Glendirmek .pdf
 
Uyumluluk denetimi genellikle denetimlerin tesine geerek a.pdf
Uyumluluk denetimi genellikle denetimlerin tesine geerek a.pdfUyumluluk denetimi genellikle denetimlerin tesine geerek a.pdf
Uyumluluk denetimi genellikle denetimlerin tesine geerek a.pdf
 
Uzun vadeli yatrm kararlar ile ilgilenen finans alan olarak .pdf
Uzun vadeli yatrm kararlar ile ilgilenen finans alan olarak .pdfUzun vadeli yatrm kararlar ile ilgilenen finans alan olarak .pdf
Uzun vadeli yatrm kararlar ile ilgilenen finans alan olarak .pdf
 
Vaka 101 Zappos Yneticileri Ortadan Kaldryor evrimii ay.pdf
Vaka 101 Zappos Yneticileri Ortadan Kaldryor  evrimii ay.pdfVaka 101 Zappos Yneticileri Ortadan Kaldryor  evrimii ay.pdf
Vaka 101 Zappos Yneticileri Ortadan Kaldryor evrimii ay.pdf
 
Utilizacin de la inteligencia emocional en el lugar de trab.pdf
Utilizacin de la inteligencia emocional en el lugar de trab.pdfUtilizacin de la inteligencia emocional en el lugar de trab.pdf
Utilizacin de la inteligencia emocional en el lugar de trab.pdf
 
Utilizando el concepto de conocimiento metacognitivo los pr.pdf
Utilizando el concepto de conocimiento metacognitivo los pr.pdfUtilizando el concepto de conocimiento metacognitivo los pr.pdf
Utilizando el concepto de conocimiento metacognitivo los pr.pdf
 
Usted es miembro del grupo de relaciones con los empleados d.pdf
Usted es miembro del grupo de relaciones con los empleados d.pdfUsted es miembro del grupo de relaciones con los empleados d.pdf
Usted es miembro del grupo de relaciones con los empleados d.pdf
 
Usted es consultor comercial de People for the Ethical Treat.pdf
Usted es consultor comercial de People for the Ethical Treat.pdfUsted es consultor comercial de People for the Ethical Treat.pdf
Usted es consultor comercial de People for the Ethical Treat.pdf
 
usptrerl the following recerd was krpe ale 50PA a the .pdf
usptrerl the following recerd was krpe ale 50PA a the .pdfusptrerl the following recerd was krpe ale 50PA a the .pdf
usptrerl the following recerd was krpe ale 50PA a the .pdf
 
Using Ubuntu write a progam in C that do this A Wait for .pdf
Using Ubuntu write a progam in C that do this A Wait for .pdfUsing Ubuntu write a progam in C that do this A Wait for .pdf
Using Ubuntu write a progam in C that do this A Wait for .pdf
 
Using Ubuntu write a program uin C that do this A Wait for.pdf
Using Ubuntu write a program uin C that do this A Wait for.pdfUsing Ubuntu write a program uin C that do this A Wait for.pdf
Using Ubuntu write a program uin C that do this A Wait for.pdf
 
Using the RamseyCassKoopmans Model what policy would best.pdf
Using the RamseyCassKoopmans Model what policy would best.pdfUsing the RamseyCassKoopmans Model what policy would best.pdf
Using the RamseyCassKoopmans Model what policy would best.pdf
 
Using the pypcaptile library already available in the VLE.pdf
Using the pypcaptile library already available in the VLE.pdfUsing the pypcaptile library already available in the VLE.pdf
Using the pypcaptile library already available in the VLE.pdf
 
Using the Mpgcsv dataset b Run a basic linear regression.pdf
Using the Mpgcsv dataset b  Run a basic linear regression.pdfUsing the Mpgcsv dataset b  Run a basic linear regression.pdf
Using the Mpgcsv dataset b Run a basic linear regression.pdf
 
Using the payoffs for the HawkDove game that we discussed i.pdf
Using the payoffs for the HawkDove game that we discussed i.pdfUsing the payoffs for the HawkDove game that we discussed i.pdf
Using the payoffs for the HawkDove game that we discussed i.pdf
 
Using the line for the Annual mean calculate the average .pdf
Using the line for the Annual mean calculate the average .pdfUsing the line for the Annual mean calculate the average .pdf
Using the line for the Annual mean calculate the average .pdf
 
Using the information below to answer the following two ques.pdf
Using the information below to answer the following two ques.pdfUsing the information below to answer the following two ques.pdf
Using the information below to answer the following two ques.pdf
 
Using the information below to answer the following three qu.pdf
Using the information below to answer the following three qu.pdfUsing the information below to answer the following three qu.pdf
Using the information below to answer the following three qu.pdf
 
Using the following UML please create this java code I spe.pdf
Using the following UML please create this java code  I spe.pdfUsing the following UML please create this java code  I spe.pdf
Using the following UML please create this java code I spe.pdf
 

Recently uploaded

internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
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
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
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
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
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
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 

Recently uploaded (20)

internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
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
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
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...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
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
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 

Using the code below Part 1 Write a static method called L.pdf

  • 1. Using the code below: Part 1: Write a static method called LinkedListToStack that takes a Node reference as a parameter (which represents a linked list). Add every element in the linked list to a stack and return the stack. Part 2: Write a static method called avgOfNumbersInStack that takes a stack of Integer as a parameter. It will return a double value which is the average of all the numbers in the stack. package activity9; import java.util.Scanner; import java.util.*; public class StackPractice { public static Node listGenerator(int input) { int n; int count = 0; Random rand = new Random(); n = rand.nextInt(100); Node head = null; head = new Node(n); count++; while(count < input) { Node t1 = new Node(n = rand.nextInt(100), head); head = t1; count++; } return head; } public static void printLinkedList(Node input) { Node curr = input; while(curr != null) { System.out.println(curr.item); curr = curr.next; } } public static void main(String[] args) { Scanner kbd = new Scanner(System.in); int input = 0; System.out.print("Please enter the starting integer: "); input = Integer.parseInt(kbd.nextLine()); listGenerator(input); printLinkedList(listGenerator(input)); } }