Question: Your first task in developing the application for tracking contributors is to load a list of the people who are helping the cause. Design and

Your first task in developing the application for tracking contributors is to load a list of the people who are helping the cause. Design and develop a linked list, implemented as a stack, to track all of the contributors. You will read the contributor information from a file provided; it is a comma delimited (CSV) file. Your design should include the following:

Each contributor will have the following Information:

Name: String; //the name of the contributor

City: String; //the city in which the contributor lives

Country: String; //the country in which the contributor lives

Phone: String; //the phone number for the contributor

Contribution: Double; //the amount of the contribution given by the contributor to the zoo

ID: Integer; //identifier key for future needs

Contributor Functions/Methods:

Input constructor: //to accept a string for the name and additional information for each contributor (this should call the Push constructor to implement the stack)

Print constructor: //to print out the contributor data

Pop constructor

Push constructor

public class Contributor { private String name; private String city; private String country; private String phone; private double contribution; private int id;

public Contributor(String name, String city, String country, String phone, double contribution, int id) { //initialize each value in the Contributor object this.name = name; this.city = city; this.country = country; this.phone = phone; this.contribution = contribution; this.id = id; } public void printContributor() { //display the contents of the Contributor object System.out.println("Name: " + name); System.out.println("City: " + city); System.out.println("Country: " + country); System.out.println("Phone: " + phone); System.out.println("Contribution: " + contribution); System.out.println("ID: " + id); System.out.println(); } }

import java.util.Scanner; import java.io.File; import java.util.regex.Pattern;

public class ContributorManager { public static void main(String [] args) { Scanner inputFile = null; String name = null; String city = null; String country = null; String phone = null; double contribution = 0; int id = 0; Contributor c = null; Stack stack = new Stack(); Node node = null; //open contributors file try { inputFile = new Scanner(new File("contributors.csv")); inputFile.useDelimiter(Pattern.compile("(\ )|(\ )|,")); } catch (Exception e) { System.err.println("Error opening file."); } //create contributors object for each row, and add to the stack while (inputFile.hasNext()) { name = inputFile.next(); city = inputFile.next(); country = inputFile.next(); phone = inputFile.next(); contribution = inputFile.nextDouble(); id = inputFile.nextInt(); inputFile.nextLine(); //advance to the next line c = new Contributor(name, city, country, phone, contribution, id); node = new Node(c); //create a node using the contributor object stack.push(node); //add the node to the top of the stack } stack.pop(); //remove the last node from the top of the stack stack.print(); //print the contents of the entire stack } }

public class Node { Contributor c; Node next; public Node(Contributor data){ //initialize member variables }

public void displayNode() { //display the contents of this node c.printContributor(); } } public class Stack { Node first; public Stack(){ //initialize the empty stack } public void push(Node newNode){ //if the stack is empty, make first point to new Node. //if the stack is not empty, loop until we get to the end of the list, //then make the last Node point to new Node } public Node pop() { //if the stack is empty, return null //Handle the case where there is only one Node in the stack //Handle the case where there are at Least two elements in the stack } public void print() { //display the entire stack Node tempDisplay = first; // start at the beginning of linkedList while (tempDisplay != null){ // Executes until we don't find end of list. tempDisplay.displayNode(); tempDisplay = tempDisplay.next; // move to next Node } System.out.println(); } } Please help me fill in the nose and stack code with the image above input.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!