几道JAVA编程题,急!每道题都是编写两个类。。。

来源:百度知道 编辑:UC知道 时间:2024/06/07 08:18:54
1编写求N阶乘的类以及应用程序类。
要求应用程序类是图形用户界面,输入N的值,并显示其结果
2自然数前N项和的类以及应用程序类。要求同上
3任意两个数相加的和以及应用程序类。同样是图形用户界面,输入两个数,并显示其结果。
4对文件的操作
往磁盘里存储数个数,逆序输出,按照逆序读取并显示。用switch语句。也是两个类。。。

急速求解。请高手帮忙。。。谢谢。。。

/*1编写求N阶乘的类以及应用程序类。 要求应用程序类是图形用户界面,输入N的值,并显示其结果 */
import java.awt.*;
import java.awt.event.*;
public class Problem1
{
public static void main(String args[])
{
math a = new math();
}
}
class math implements ActionListener
{
Label la = new Label("");
static String s = "";
public math()
{
int i=0;
Frame fr = new Frame("阶乘计算器");
Panel pa1 = new Panel();
Panel pa2 = new Panel();
Panel pa3 = new Panel();
Panel pa4 = new Panel();
Button[] bu = new Button[10];
Button enter = new Button("Enter");
for (i = 0; i <= 8; i++)
{
bu[i] = new Button("" + (i + 1));
}
bu[9] = new Button("0");
fr.setSize(400, 200);
fr.setVisible(true);
fr.setLayout(new GridLayout(4,1));
fr.add(la);
fr.add(pa1);
fr.add(pa2);
fr.add(pa3