The assignment is to hard code the data below to match the output. The first sec
ID: 3621585 • Letter: T
Question
The assignment is to hard code the data below to match the output.The first section of the report should use nested for loops to display the sales by quarter for each region. Use tabs to line up columns for this section.
The second section of the report should use nested for loops to calculate the sales by region adding up the quarterly sales for each region.
The third section of the report should use nested for loops to calculate the sales by quarter by adding up the individual region sales for each quarter.
The fourth section of the report should use nested for loops to calculate the total annual sales for the entire company.
Use the NumberFormat class to format the sales numbers using the currency format.
**I am stuck on being able to hard code the data in an array, I've tried a couple of different things but I can't figure out. Any help will be greatly appreciated!!**
*******************************************************************************************************
Welcome to the Sales Report Application.
Region Q1 Q2 Q3 Q4
1 $1,540.00 $2,010.00 $2,450.00 $1,845.00
2 $1,130.00 $1,168.00 $1,847.00 $1,491.00
3 $1,580.00 $2,305.00 $2,710.00 $1,284.00
4 $1,105.00 $4,102.00 $2,391.00 $1,576.00
Sales by region:
Region 1: $7,845.00
Region 2: $5,636.00
Region 3: $7,879.00
Region 4: $9,174.00
Sales by quarter:
Q1: $5,355.00
Q2: $9,585.00
Q3: $9,398.00
Q4: $6,196.00
Total annual sales, all regions: $30,534.00
Press any key to continue . . .
*******************************************************************************************************
Explanation / Answer
Hope this helps. Let me know if if you have any questions. Please rate. :) import java.text.NumberFormat; public class Sales { // first index gives region, second index gives quarter // e.g. data[1][3] gives the sales for region 1 in quarter 3 public static double[][] data = { {1540, 2010, 2450, 1845}, {1130, 1168, 1847, 1491}, {1580, 2305, 2710, 1284}, {1105, 4102, 2391, 1576} }; public static void main(String[] args) { System.out.println("Welcome to the Sales Report Application."); System.out.println("Region Q1 Q2 Q3 Q4"); for (int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.