gpt4 book ai didi

java - 如何在处理中的 JOptionPane.showMessageDialog() 中显示形状?

转载 作者:行者123 更新时间:2023-12-01 23:24:12 25 4
gpt4 key购买 nike

部分要求是复制/image/avmED.jpg中的条形图。

我尝试这样做是为了看看是否可以在对话窗口中绘制矩形(显然它不起作用):

rectMode(CENTER);

// Alberta
if ( prov_id.equals("AB") || prov_id.equals("ab"))
{
if (gross_income>=0&&gross_income<=40000)
{
tax_rate=0.25;
JOptionPane.showMessageDialog(frame,"Province: "+ prov_id + "\nGross Income: "+ gross_income + "\nTax Rate: "+ tax_rate+ "\nTax Amount: "+ tax_amount+"\nNet Income: "+ net_income + rect(10,10,10,10));

}

我的其余代码:

import javax.swing.JOptionPane;


//Input Variables
String prov_id = ""; //province_id will contain the user input for the province (E.g. 'AB').
float gross_income = 0; //gorss_income contains the user input for gross income (E.g. 30000).

//Output Variables:
//You will store the result of your analysis and calculations in these variables
float tax_rate = 0; //Variable tax_rate will hold the tax_rate percentage. You will assign a value for tax_rate based on the Taxable Income (Table 1) table given in the studio project document.
//The value of tax ranges between 0 to 1 (E.g. for Alberta, income of equal or less than $40000 tax = 0.25)

float net_income = 0; //Net income is calculated based on tax_rate. It is the take-home income after taxes are deducted.
//i.e. net_income = gross_income * (1 - tax_rate);

float tax_amount = 0; //tax amount is the amount of taxes paid based on gross income depending on the province.
//i.e. tax_amount = gross_income * tax_rate;

// prompt for and read the province id
prov_id = JOptionPane.showInputDialog("Please enter your province's two-letter abbreviation (e.g., AB for Alberta): ");

// prompt for and read the gross income
String answer = JOptionPane.showInputDialog("Please enter your taxable income: ");

//convert user input to folat
gross_income = Float.parseFloat(answer);


net_income=gross_income*(1-tax_rate);
tax_amount=gross_income*tax_rate;
rectMode(CENTER);

// Alberta
if ( prov_id.equals("AB") || prov_id.equals("ab"))
{
if (gross_income>=0&&gross_income<=40000)
{
tax_rate=0.25;
JOptionPane.showMessageDialog(frame,"Province: "+ prov_id + "\nGross Income: "+ gross_income + "\nTax Rate: "+ tax_rate+ "\nTax Amount: "+ tax_amount+"\nNet Income: "+ net_income);

}

}

预期的输出应该是这样的:/image/avmED.jpg

到目前为止,我的代码显示:/image/avmED.jpg

最佳答案

显示条形图的窗口不是来自 JOptionPane.showMessageDialog() 的处理窗口,因为该窗口名为“TaxCalculator_key”,我认为这是文件名,而不是“Message”。

关于java - 如何在处理中的 JOptionPane.showMessageDialog() 中显示形状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58311826/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com