You are about to write a simple Java program to calculate the architect's fee based on the cost of the building. Follow the instructions below:

1. Prompt the user to enter the cost of the building.
Example: Enter building cost: 250000

2. Prompt the user to enter the type of the building (L/C/A).
Example: Enter building type: L/C/A

3. Calculate the fee using the following rules:
- 7% for the first $20,000.
- 3% on the remainder if the total cost is less than or equal to $150,000.
- 2% on the remainder if the total cost is more than $150,000.

4. Add an extra cost fee based on the building type:
- L (landed): Extra $3,000
- C (condominium): Extra $5,000

5. You are required to use an if block and a switch block in your implementation.

6. Print out the result in a dialog box with 2 decimal places for the architect fee.
Example output: "The architect fee is: $000.00"

Answer :

Here is the Java program to calculate the architect's fee based on the cost of the building. The program prompts the user to enter the cost of the building and the type of the building and prints out the result in a dialog box with 2 decimal places for the architect's cost.

The program uses an if block and a switch block in its implementation. Program: import javax.swing.JOptionPane;public class Main { public static void main(String[] args) { String cost String = JOption Pane.showInput Dialog("Enter building cost:"); double cost = Double.parse Double(costString); String type String = JOptionPane.show Input Dialog("Enter building type (L/C/A):"); char type = type String.charAt(0); double fee = 0.0; if (cost <= 20000) { fee = cost * 0.07; } else if (cost <= 170000) { fee = 20000 * 0.07 + (cost - 20000) * 0.03; } else { fee = 20000 * 0.07 + 150000 * 0.03 + (cost - 170000) * 0.02; } switch (type) { case 'L': fee += 3000.0; break; case 'C': fee += 5000.0; break; } String message = String.format("The architect fee is: $%.2f", fee); J Option Pane. show Message Dialog(null, message); }}

In the above program, we first prompt the user to enter the cost of the building and the type of the building using the J Option Pane. show Input Dialog() method. Then, we parse the user inputs into the variables cost and type. Next, we calculate the architect's fee based on the cost of the building using an if block and a switch block. The if block checks whether the cost is less than or equal to $20,000 and calculates the fee accordingly.

If the cost is greater than $20,000, the switch block adds an extra cost fee based on the building type.L (landed) buildings have an extra cost of $3,000 and C (Condominium) buildings have an extra cost of $5,000.

Finally, we format the architect's fee as a string with 2 decimal places using the String.format() method and display it in a dialog box using the J Option Pane.show Message Dialog() method.

For more information on Java program visit:

brainly.com/question/2266606

#SPJ11