Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA// Follow directions below:) Write a program named StateSales that has the following data for the following states double] sales ={23000,14000,120000,43000,67000,86000,29800,59000,120000}; String[] state ={ AZ,CA,VA,SC,

JAVA// Follow directions below:) image text in transcribed
Write a program named StateSales that has the following data for the following states double] sales ={23000,14000,120000,43000,67000,86000,29800,59000,120000}; String[] state ={ "AZ","CA","VA","SC", "RI","TX","NM", "WI","NC" }; (NOTE: For a real application, it would be better to have a blueprint of Sales and have two fields, amount and state...but we need practice with primitive and String arrays so we will approach it this way). Write methods and method calls that print the following: a) the average sales b) a list of states below the average sales c) the maximum sales amount b) the state(s) that has the maximum sales. There may be more than one. Make certain to use methods. Make certain you do the input validation. If I change one of the values in the top array to a negative and run my version of the program, it prints You have some bad data so I am ending your program! Sample output The average sales were $62,422.22 States below average: AZ: $23,000.00 CA: $14,000.00 SC: $43,000.00 NM:$29,800.00 WI: $59,000.00 The maximum sales amount was $120,000.00 The maximum sales occurred in the following state(s) : VA NC NOTE: Make certain most of the work goes into the methods. Here is my main method (without the validation added) public static void main(String[] args) \{ NumberFormat nf= NumberFormat.getCurrencylnstance(); double] sales ={23000,14000,120000,43000,67000,86000,29800,59000,120000}; String[] states = { "AZ", "CA","VA", "SC","RI", "TX", "NM", "WI","NC" }; double avg = salesAvg(sales); System.out.printin("The average sales were " +nf.format(avg)); belowAvg(sales, states); double high = highSales(sales); System.out.printin("The maximum sales amount was " +nf.format(high)); highState(sales, states)

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

1 . Television News channels importantance of our Life pattern ?

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago