Page 1 of 1

Exercise 4 This program is like program in "File 10" video. Create a text file, (input.in) and enter the "contributions"

Posted: Tue May 24, 2022 7:49 am
by answerhappygod
Exercise 4 This Program Is Like Program In File 10 Video Create A Text File Input In And Enter The Contributions 1
Exercise 4 This Program Is Like Program In File 10 Video Create A Text File Input In And Enter The Contributions 1 (80.4 KiB) Viewed 18 times
Exercise 4 This program is like program in "File 10" video. Create a text file, (input.in) and enter the "contributions". Sum of all entries should be greater than or equal to ten million. The default location for data file in browxy.com is the "data" subfolder. In Eclipse, it is the root/project folder. I have attached a separate file (Browxy ExlipseDFL.pdf) with instructions on how to create these files. Pseudocode. //Declare most as 'double' variables, initialize to zero numberOfContributions //declare as integer maxContribution minContribution //initialize to 10 million avgContribution totalContributions inputDataFromFile //Objects to read and write to data file Create File and Scanner objects to read from input.in data file Create File and PrintWriter objects to write to results.out data file //do-while loop to INPUT and PROCESS data Do Read data from input.in to inputDataFromFile with nextDouble() method. Add one to numberOfContributions //Count number of contributions //Find maximum contribution If maxContribution is less than inputDataFromFile Then maxContribution = inputDataFromFile; End if //Find minimum contribution If minContribution is greater than inputDataFromFile Then minContribition = inputDataFromFile End if Add inputDataFromFile to totalContributions //Total contributions While totalContributions < 10000000 //End of do-while loop

avgContribution = totalContributions/numberOfContributions //Find average contribution //OUTPUT data //Write values in variables within formatted strings to result.out file as seen in assignment details Write data to result.out file: numberOfContributions maxContribution minContribution avgContribution totalContributions For example: PrintWriterObject.printf("It took %.Of contributions to reach the goal.%n", numberOfContributions); //Close objects Close Scanner object Close PrintWriter object