Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use input.txt and output.txt and show your output and the input file Homework - Topic 9 - Donations: Write a complete program to do

image text in transcribed

please use input.txt and output.txt

and show your output and the input file

Homework - Topic 9 - Donations: Write a complete program to do the following: The main program calls a method to read in ifrom an input file) a set of people's three-digit. Trs numbers and their donations to a charity (hint: use parallel arrays). Then the main program calas a method to sort the ID numbers into numerical orcer, being sure to carry along the corresponding donations. The main program then calls a method to print the sorted lishs in tabular form, giving both ID numbers and donations. Ther. the main frogram calls another method to sort the donation amounts into ascending order, carrying along the corresponding ID numbers. It ther, once agair. prints the sorted :ists, giving both ID numbers and donations. Here are the details: (a) The main program calis a method to read in the data from a file. The data consists of sets of data, each of which contains a person's three-digit integer ID number and a donation in dollars and cents. (e.g., 456230. co or 123302.34). The file is read until end-of-file is reached. The method returns how many sets of data were read in. The main program calls the return value donorcount. The main program calls these arrays idnumbers and donations, A separate prirting method prints the original set of data in the form of a reat table. When the arrays print, there should be an overall heading, plus headings for the columns of ID numbers and donations. (b) Then the main program sends the array of Trs numbers, the array of donations, and the size donorCount to a sorting methoo. This method sorts the ID numbers into numerical order using a selectionsort. Be sure to maintair. the match-rp of ID numbers and donations. For example, 456 should always be associaled with 200.00, no mather where 456 moves in rumerical order; similarly, 123 should stay with 302.34. Wher the sorting methcd finishes and returns control to the main program, the main program calls the printing method to once again print the two arrays. (c) Next, the main program sends the same three parameters to the second sorting method, which sorts the donations into numerical order (using a bubbleSort), being sure to maintain the linkup of ID numbers and donations. Wher: Lhis sortirg telhod finishes and returns control to the main program, the main progran, once again, calls the printing method to print the two arrays with appropriate headings. Your arrays sholid have room for up to 50 entries. To test the program, have a set of data with at least 15 to 20 values in cach array. Make sure that your original order in not close to nunerical order for eitier array and that the twc numerical crders are not olose to eact other. Required Submission: 1. The Java source code file (e.g., HW9.java) 2. The data input file of donors and donations(e.g, input.txt) 3. The program generated output file (e.g., output.txt)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions