Question

We have studied the following topics: How to interact with users via dialog boxes. Super class...

We have studied the following topics:

  1. How to interact with users via dialog boxes.
  2. Super class and sub class.
  3. One- and two-dimensional arrays in Java.

In this SLP assignment, we will make changes to our previous programs based on what we have learned. Write a Java application program to calculate property tax. Your program should have the following functions:

  1. Prompt users for the number of properties.
  2. Prompt users for property tax.
  3. Prompt users to input the value for each property
  4. Calculate the TOTAL amount of all property tax combined
  5. User must press "E" to terminate the program.

Hint: one dimensional array is sufficient for this program, assuming all properties are in the same city, hence, the property tax is the same.

You will also need to write pseudo code for this assignment.

Using your knowledge of arrays, repetition statement, selection statement, and other Java fundamentals, write a property tax calculator program. The following items will be assessed in particular:

  1. Arrays used in the program.
  2. GUI feature used to allow users interaction.
  3. Whether the program has bugs.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*
The java program that prompts user to enter the number of properties to enter the cost. Then read the properties into an array of double type. The find the tax of each property and add to the total tax. The program continues either user enters E to exit or all properties are entered. Then finally display the property tax collected on message dialog
* */

//Main.java
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Main
{
   public static void main(String[] args)
   {
       /*declare variables */
       int numProperties;
       double totalPropertyCost=0;
       int counter=0;
       final double PROPERTY_TAX=0.10; //Set 10 % =0.1 as property tax
      
       /*Prompt for number of properties */
       numProperties=Integer.parseInt(JOptionPane.showInputDialog(null, "Enter the number of properies :"));
       /*create an array of double type */
       double[] cost_array=new double[numProperties];

       String userInput="";

       do
       {
           //prompt for the cost of the property
           userInput=JOptionPane.showInputDialog(null, "Enter the cost of the property :"+(counter+1));
           if(userInput.equals("E"))
               break;
           else
           {
               //Parset the user input to double and add assign the tot the cost array
               cost_array[counter]=Double.parseDouble(userInput);
               //calcuate the tax on the property cost
               totalPropertyCost+=cost_array[counter]*PROPERTY_TAX;
               //increment the counter by 1
               counter=counter+1;
           }
          
       }while(!userInput.equals("E") &&counter<numProperties);


       /*Display the total property tax on the message dialog window*/
       JOptionPane.showMessageDialog(null, "TOTAL amount of all property tax combined:$"+Math.round(totalPropertyCost),
               "Property Cost",
               JOptionPane.INFORMATION_MESSAGE);
   } //end of the main method
} //end of the java program

--------------------------------------------------------*--------------------------------------------------------

Sample Output:

Add a comment
Know the answer?
Add Answer to:
We have studied the following topics: How to interact with users via dialog boxes. Super class...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a complete Java program to do the following Your code should have: A super class...

    Write a complete Java program to do the following Your code should have: A super class named Home Properties address SF (this is the number of Square feet) value (this is the dollar value of the home) PPSF (price per square foot) you will calculate this in a method Methods Set and get methods for all properties CalcPPSF - (PPSF is the value/SF) A sub class named Condo, which has one more HOA property: Property: HOAfee (home owners association fee)...

  • Summary Write a program that demonstrates the skills you’ve learned throughout this quarter. This type of...

    Summary Write a program that demonstrates the skills you’ve learned throughout this quarter. This type of project offers only a few guidelines and requirements, allowing you to invest as much time, effort and imagination as you want.  Submit your java programs (*.java) and any other I/O (*.txt) via Canvas  You’ve worked quite hard to make it this far, so have a bit of fun with this project! Design Brief: Use Case Scenario You are hired to develop a...

  • Lab #7 CSE110 - Arizona State University Topics • Basic arrays Coding Guidelines • Give identifiers...

    Lab #7 CSE110 - Arizona State University Topics • Basic arrays Coding Guidelines • Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc). • Keep identifiers to a reasonably short length. • Use upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects). • Use tabs or spaces to indent code within blocks (code surrounded by braces)....

  • Lab Topics • The basics of Array object Use the following Coding Guidelines • When declaring...

    Lab Topics • The basics of Array object Use the following Coding Guidelines • When declaring a variable, you usually want to initialize it. Remember you cannot initialize a number with a string. Remember variable names are case sensitive. Use tabs or spaces to indent code within blocks (code surrounded by braces). Use white space to make your program more readable. Use comments after the ending brace of classes, methods, and blocks to identify to which block it belongs. Problem...

  • **JAVA PLEASE!!** CSE205 Assignment 2 ASCII Terrain Generator 5Opts Topics: Arrays Multidimensional Arrays Metho...

    **JAVA PLEASE!!** CSE205 Assignment 2 ASCII Terrain Generator 5Opts Topics: Arrays Multidimensional Arrays Methods Loops and Conditionals Description The goal of this assignment is for you to produce a simple procedurally generated terrain map out of ASCII character symbols. This will be done through simple probability distributions and arrays Use the following Guideline s: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc) Keep identifiers to a reasonably short length. User upper case for constants....

  • Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an...

    Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...

  • These are my answere to the following questions: are they right? 1. B 2. T 3....

    These are my answere to the following questions: are they right? 1. B 2. T 3. T 4. T 5. F 6. T 7. A 8. D 9. E 10. B 11. B 12. A 13. A 14. D 15. C 16. D 17. T 18. C 19. T 20. T 21. T 22. A 23. T 24. D 25. B 26. A 27. A 28. A 29. T 30. C 31. D 32. A 33. T 34. F 35....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT