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)...

  • Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one me...

    Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one menu item called Search. Clicking on search should prompt the user using a JOptionPane input dialog to enter a car make. The GUI should then display only cars of that make. You will need to write a second menu...

  • 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)....

  • LAB1 PART 1 FOR THE DATA TYPE CLASS: If you do not have UML of class...

    LAB1 PART 1 FOR THE DATA TYPE CLASS: If you do not have UML of class Account_yourLastName, you should do that first Basesd on the UML, provide the code of data type class Account_yourLastName to hold the information of an account with account number (String), name (String), balance (double), with no-argument constructor, parameter constructor Also, define some methods to handle the tasks: open account, check current balance, deposit, withdraw, and print monthly statement. At the end of each task we...

  • 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 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...

  • In Java Which of the following statements declares Salaried as a subclass of payType? Public class...

    In Java Which of the following statements declares Salaried as a subclass of payType? Public class Salaried implements PayType Public class Salaried derivedFrom(payType) Public class PayType derives Salaried Public class Salaried extends PayType If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method. False True When a subclass overloads a superclass method………. Only the subclass method may be called with a subclass object Only the superclass method...

  • **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....

  • Java Painter Class This is the class that will contain main. Main will create a new...

    Java Painter Class This is the class that will contain main. Main will create a new Painter object - and this is the only thing it will do. Most of the work is done in Painter’s constructor. The Painter class should extend JFrame in its constructor.  Recall that you will want to set its size and the default close operation. You will also want to create an overall holder JPanel to add the various components to. It is this JPanel that...

  • Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such...

    Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such as declaration, initialization, storing, retrieving, and processing elements. • Effectively manipulating and using ArrayList objects. • Becoming familiar with the use of arrays as method arguments and how array elements are passed to and returned from the called method. • Mastering the use of various debugging tools available on the Eclipse IDU. Important: EVERY one of the following Activities MUST be in a separate...

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
ADVERTISEMENT