CSCI 141 University of Central Florida 2D Array Java Program Project

User Generated

enivd21

Programming

CSCI 141

University of Central Florida

CSCI

Description

(CHECK ATTACHED)

This program is meant to give you practice with a 2D array and defining your own functions. You will create a 2D array filled with random sales figures and the tax per sale. Then you will write 2 functions (methods), one to print the information out, and one to sum up all the totals and print those out as well.

(CHECK ATTACHED)

Unformatted Attachment Preview

Joe Del Rocco CSCI 141 Professor of Practice, Computer Science jdelrocco [at] stetson [dot] edu Stetson University 421 N Woodland Blvd, DeLand, FL, 32723 www.stetson.edu (all sections) Fall 2020 Assignment Assignment 3 Due: Monday 9/28/2020 11:59pm Contents Program (a) . . (b) . . (c) . . (d) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 2 2 2 Submission 3 Rubric 3 Example Output 3 1 Joe Del Rocco CSCI 141: Assignment 3 Program This program is meant to give you practice with a 2D array and defining your own functions. You will create a 2D array filled with random sales figures and the tax per sale. Then you will write 2 functions (methods), one to print the information out, and one to sum up all the totals and print those out as well. See the Example Output. Here is the link to the GitHub Classroom assignment: https://classroom.github.com/a/Ec9CLYrS (a) First create your Random and Scanner objects, as you will need both in this program. (b) Next, ask the user for the number of sales they want to load (generate). Use their answer to create a 2D array where the number of rows is the number of sales, and the number of columns is 2. This array will hold both randomly generated sales figures (in the first column) and the computed tax per sale (in the second column). Next, create a float variable to hold the tax rate. Ask the user which state these figures are coming from. If the user specifies “FL” (case insensitive), then the tax rate should be 6% (0.06f). If any other state or input, just make the tax rate 0. (c) Next, it’s time to populate your 2D array of sales figures with actual random numbers and taxes. Use a definite loop (for) to loop through the number of sales (the number of rows of the 2D array). For each loop iteration, set each sale’s column 0 to a random double between 0.0 and 100.0, and set column 1 to the value of column 0 multiplied by the tax rate. In other words, for each sale, column 0 holds the sale amount, and column 1 holds the computed tax for that sale. Tip You can generate a random double between 0.0 and 100.0 by calling your Random object’s .nextDouble() method and multiplying the returned double by 100.0. (d) Now you will write 2 separate functions (methods). Write a function called listSales() which takes a 2D double array as an argument and returns nothing. This function will loop through all the provided sales and print out each sale, its tax, and the total of sale + tax per line. Next, write a function called runTotals() which takes a 2D double array as an argument and returns nothing. This function will loop through all the sales and sum up three values: (1) the total of all sales (without tax), (2) the total of all taxes, and (3) the total of all sales with tax. Then you will display these final totals in a single line just under the full list of sales. Call both of these functions from main() passing your array of sales to each. Tip To format a display String with a double value rounded to 2 decimal places right-aligned and filling at least 7 digits of whitespace, do this: String str = String.format("%7.2f", value); // values is a double System.out.println(str); Page 2 of 4 Joe Del Rocco CSCI 141: Assignment 3 Program Submission You will commit and push your changes to your specific GitHub Classroom repository for this assignment. Although you are encouraged to use an IDE for development, we will compile and run your program using the shell during grading. So it isn’t a bad idea to test it in the shell. Please follow the directions below, make the requested code changes, and commit and push your changes any time before the due date. Your final output should have the functionality displayed in the Example Output below. Rubric Task General attempt at solving the problem Program compiles and runs Properly creating and filling the 2D array Printing out all sales figures Computing and printing totals Total Percentage 30% 20% 20% 20% 10% 100% Example Output Example Output continued on next page. . . Page 3 of 4 Joe Del Rocco CSCI 141: Assignment 3 Example Output (continued) Page 4 of 4
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

At...


Anonymous
Really great stuff, couldn't ask for more.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags