Design a Windows application and write the code that will execute according to t
ID: 2246710 • Letter: D
Question
Design a Windows application and write the code that will execute according to the program requirements in Figure 8-112 and the Use Case Definition in Figure 8-113. Before writing the code, create an event planning document for each event in the program. The completed Windows application and other objects in the user interface are shown in Figure 8-114.
Here is the Use Case Definition
1. The User selects a city to display the individual tax rate range and taps or clicks the Display Tax Range button
The user selects the Display Median Home Prices item to open a second form that displays the current median home prices in the 10 largest U.S. cities
The User select eh Clear menu item to clear the form
The user selects the exit menu item to exit the application
Date: Date Submitted Application Title: Personal Income Tax Comparison by Country Purpose: April 2, 2017 This Windows application opens a text file that lists the personal marginal income tax rate ranges for 17 countries. The user selects a country and displays the personal income tax rate range. A menu selection also can show the entire listing of the countries and the tax rate ranges on a second Windows Form object. (Source: www.gfmag.com/global-data/economic-data/personal-income-tax-rates) Program Procedures In a Windows application, a user can view the individual income tax rate of 17 countries Algorithms, Processing, a Conditions: 1. The user views a Windows application that contains a title, graphic, and a ListBox object displaying the 17 individual tax rate ranges in the many modern countries in the world. The ListBox object is filled from a text file named tax.txt that is opened and read by the application from the USB drive (drive E:). The text file contains each country name with the current individual tax rate range 2. Afier the user selects the country from the ListBox object, and taps or clicks the Display Ta>x Range button, a label displays that the tax rate range in the selected country 3. A File menu displays the Display Tax Rates from Various Countries, Clear, and Exit menu items. When the user selects the Display Tax Rates menu item, a second Windows Form object opens and displays the 17 countries and their individual tax rate ranges. Notes and The user must select a country from the ListBox object before the tax rate of the selected country is displayed. 1. The tax.txt file is available on CengageBrain.com. 2. Obtain an image for this program from CengageBrain.com. The ame of the picture on the Comments: Windows fos Tax. 3. The second Form object displays a Display Countries and Tax Rate button to reopen the initial Form object.Explanation / Answer
HI...
import java.util.Scanner;
public class Taxableincometaxcode
{
public static void main(String[] args){
netincometax();
}
public static double netincometax() {
double incometax = 0;
Scanner in = new Scanner(System.in);
System.out.print("Enter incometax: ");
incometax = in.nextDouble();
System.out.println();
double taxx1 = 0;
double tax2 = 0;
double totalTax = taxx1 + tax2;
// high incometax bracket
if (incometax > 45000) {
double part1 = incometax - 45000; // part = incometax - 45000
taxx1 += part1 * 0.4; // tax = tax + part * 0.4
System.out.println("High Tax Band - Greater than 45000: " + taxx1);
}
// medium incometax bracket
if (incometax > 7500) {
double part2 = incometax - 7500;
tax2 += part2 * 0.2;
System.out.println("Medium Tax Band - Greater than 7500: " + tax2);
}
System.out.println("Total Tax = " + (taxx1 + tax2));
// tax for low incometax is zero, we don't need to compute anything.
return totalTax;
}
}
-------------------------------
Second method
import java.util.Scanner;
import java.text.DecimalFormat;
class incometaxTaxWithBrackets {
public static void main(String[] args) {
double infinity = Double.POSITIVE_INFINITY;
double [] bracket = {0, 7565, 25903, 54987, 121121, 567894, infinity};
double [] rate = {0, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35};
// bracket[0] to bracket[1] are assigned rate[1]
double incometax = 0;
double tax = 0;
System.out.print(" Please enter your incometax: ");
Scanner keyboard = new Scanner (System.in);
DecimalFormat dollar = new DecimalFormat ("$#,##0.00");
incometax = keyboard.nextDouble();
int x,i;
for (i=0; i <= 5; i++) {
if (incometax > bracket[i] && incometax <= bracket[i+1]) {
for (x=0; x<i; ++x) {
tax = tax + (bracket[x+1] - bracket[x]) * rate[x+1];
}
tax = tax + (incometax - bracket[i]) * rate[i+1];
}
}
System.out.println(" With a taxable incometax of "+dollar.format(incometax)+", your personal incometax tax is "+dollar.format(tax));
}
}
-------------------------
Thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.