Question
Can someone help me write this code in java? Thanks Input dialog box for initial user prompt with good data and after invalid data How
Can someone help me write this code in java? Thanks
Input dialog box for initial user prompt with good data and after invalid data
How many properties would you like to enter? 5
ERROR please enter a number between 1and 10. How many properties would you like to enter?
Input dialog boxes with sample input for Property 1
Enter the address for property 1: 287 acorn street
Enter the value of property 1: 150000
Input dialog boxes after invalid data entered for Property 1
Error Please enter a number greater than 0. Enter the value for property 1
Console output
Month End Sales Report
Address Price
287 acorn street 150000
12 maple ave 310000
8723 marie ln 6500
222 acorn st 127000
29 bahama ln 450000
Total 1102500
Input dialog box for running another report with good data and after invalid data
Would you like to run another report? Y
Error please enter Y or N. Would you like to run another report?
Submission
Name your Java source code file SalesReportArrayAppXXX.java, where XXX is your initials
Operation
Use a dialog box to ask the user how many properties they would like to enter.
Use dialog boxes to prompt the user to enter the address and the price for each property.
Validate numeric input to make sure it is reasonable.
Display the address and price for each property as it is entered.
Use an accumulator variable to calculate the sum of all the property prices.
Display the accumulator variable after all properties entered.
Use a dialog box to ask the user if theyd like to run another report
Specifications for Project 4
Use pseudocode and/or flowcharts to map out your logic before you start coding!
Declare the following variable and arrays as the specified data types:
o total as an int with an initial value of 0
o numProperties as an int
o counter as an int
o runAnother as a String
o propertyAddress[ ] as an array of String values (used instead of propertyAddress)
o propertyPrice[ ] as an array of int values (used instead of propertyPrice)
o HEADING1 as a String constant with a value of MONTH-END SALES REPORT
o HEADING as a String constant with a value of Address\t\t\tPrice
Use a while loop to determine if the user wants to run another report
o This loop will contain most of the logic in your application
o The variable runAnother will be used as the loop control variable
o Initialize your loop control variable to y
o Test your control variable and loop if it is either y or Y
Use a method that ignores case or a combined decision
o Alter your loop control variable by asking the user if they want to run another report
Construct the propertyAddress[ ] and propertyPrice[ ] arrays using the user input variable numProperties as the size
Use the showInputDialog() method from the JOptionPane class to get user input.
o Use meaningful, descriptive prompts as indicated in the sample above
o For the property prompts, use counter as part of the prompts to indicate which property the user is entering
Validate numProperties, each entry for propertyPrice[ ], and runAnother using while loops:
o numProperties should be >= 1 and <=10
o propertyPrice should be > 0
Do not add propertyPrice to the total unless it is valid
This will all be done inside your for loop
o runAnother should be Y, y, N, or n
Use the !runAnother.equalsIgnoreCase() method to simplify
o Include error messages as indicated in the example above
Use the new line escape character ( ) to put data on two different lines
Use an accumulator variable (total) to add up all the property values.
Use a for loop to get the user input and calculate the total property value
o The user input will be stored in the arrays
o The variable numProperties will be used in your test expression to know when to stop the loop
Use a separate for loop to display the property information
o This loop will look exactly like the previous but this way all of the property information will be printed at one time
Terminate the application.
Console window output:
o Display HEADING1 at the top followed by a blank line
o Display HEADING2 followed by a blank line
o Display the output for each property one line at a time (as its entered) using the tab escape character (\t) to line up the output with the HEADING2 output
o Display another blank line and then the total property value (after the loop to get input is closed)
Include appropriate comments throughout the code, and include a comment header at the top that contains your name, date, filename, and purpose.
Test thoroughly.
Produce output that matches above example.
General application structure
// import for interactive input
public class
public static void
// declare variables, arrays and constants
// initaialze outer loop
// test outer loop
// ask how many properties they want to enter
// vaildate numProperties is >= 1 and <= 10
// construct arrays based on numProperties input from user
// display headings
// use a for loop (initiazle,test, alter)
// to loop the number of times the user requested to get user input, populate the 2 arrays and calculate total
// get user input and populate the arrays
// validate propertyPrice is greater than zero
// calculate total by adding on currert propertyPrice
// use a for loop to display all property information in the arrays
// display total
// alter outer loop- see if user wants to run another report
// vaildate runAnother
// terminate application
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started