JOptionPane.showMessageDialog("#1", "#2", "Total", "Result");
试图显示创建结果的显示,但是我得到了以下说法的错误:“字符串无法转换为组件。
答案 0 :(得分:0)
该方法的第一个参数是using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using System.Numerics;
namespace Tarea_4_Programa_1
{
// Formula = n^2 - 100n + 900
class Program
{
static void Main(string[] args)
{
double n = 1; // n in n^2 - 100n + 900
double y = 0; // result of the formula
double firstchange =0; // first change of sign
double secondchange = 0; //second change of sign
// Iterates the formula n^2 - 100n + 900 with n = 1 to 1000
for (int i = 0; i <=1000; i++)
{
y = Math.Pow(n, 2) - 100*n + 900;
n = n + 1;
if (y < 0)
{
firstchange = n;
}
else if (y > 0)
{
secondchange = n;
}
Console.WriteLine("When n is " + (n - 1)+ " the result is " + y);
}
Console.WriteLine("------------------------------------------------------");
Console.WriteLine("When n is " + firstchange + " result becomes negative");
Console.WriteLine("When n is " + secondchange + "result becomes positive");
Console.ReadLine();
}
}
}
Component
您传递的是 showMessageDialog(Component parentComponent, Object message, String title, int messageType)
(#1),而不是String
。