JAVA

名稱:

星期四, 1月 12, 2006

lab_Recursion

package welcome;
import java.io.*;
public class lab_Recursion
{
public static double recursive(double number)
{
if(number==0)
return 0;
else if(number==1)
{
return 1;
}
else return (number*recursive(number-1));
}

public static void main(String[] args) throws IOException
{
double n;
BufferedReader keyboard =new BufferedReader(new InputStreamReader(System.in));
System.out.println("please type positive number");
System.out.println("negative number is end.");
String input = keyboard.readLine();
double temp = Double.parseDouble(input.trim());
n=recursive(temp);
System.out.println(temp+"!="+n);
}
}

Lab 12-26-2005 (2)

public class ttt
{
public static void main(String [] args)
{
int i;
if(args.length == 0)
{
System.out.println("No input number.");
}
else
{
System.out.println("Output:");
for(i=(args.length-1) ; i >= 0 ; i--)
{
System.out.print(args[i]+" ");
}
}
}

星期二, 1月 03, 2006

0102 HW

import javax.swing.JOptionPane;
public class Recursive {
public static void main(String[] arg)
{ String PString=JOptionPane.showInputDialog("幾階層");
int i=Integer.parseInt(PString);
System.out.println(i+" 階層是 "+Recursive.orders(i));
System.exit(0);}
public static int orders(int i){
int n=1;
if (i==0){return 1;}
else if(i>0){ return(orders(i-1)*i);
}
else return 0;}
}

LAB 01-2

package worl;

public class LAB012 {
public static double[] sortt(double[] tmp)
{
int i,j;
double temp;
for (j = 0; j <> tmp[i - 1])
{
temp = tmp[i - 1];
tmp[i - 1] = tmp[i];
tmp[i] = temp;
}
}
}
return tmp;
}
public static void out(double[] temp2)
{

System.out.print("排序後陣列:");
for(int i=0 ; i < temp2.length ;i + +)
{
System.out.print(" " + temp2[i]);
}
}
public static void main(String[] args)
{
double[] num={45,558,78,6,8,0,35};
double[] num2;
num2=sortt(num);
out(num2);
}
}

星期日, 1月 01, 2006

Lab 12/26 (2)

ublic class shine8
{
public static void main(String[] arg)
{
int i;
if(arg.length==0){System.out.println("EORR");System.exit(0);}
for(i=arg.length-1;i>=0;i--)
{
System.out.println(arg[i]);
}

System.out.println("The length of parameter is "+arg.length);
}
}

Homework 12/19

public class equal {
public static boolean equal(int a[],int b[])
{ if (a.length != b.length) {return false;}
else{ int i=0;
while (i < a.length) {
if (a[i] != b[i]) { return false; }
i++; }
}
return true;
}
public static void main(String[] args)
{ int[] a={1,9,6,4,0,2,1,2};
int[] b={1,9,6,4,0,2,1,2};
int k;
System.out.print("a={ ");
for(k=0; k
System.out.print(a[k]+" ");
System.out.println("}");
System.out.print("b={ ");
for(k=0; k
System.out.print(b[k]+" ");
System.out.println("}");
if(equal(a,b))
{System.out.println("a and b are equal.");}
else
{System.out.println("a and b are not equal.");}
}
}

12 / 19 lab

package untitled14;

import java.io.*;

public class add {
private static Object keyboard;
public static void main(String[] args) throws IOException,
NumberFormatException {
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.
in));

double tem;
double[] number = new double[5];
System.out.println("輸入5個數:");

for (int i = 0; i < 5; i++) {
number[i] = Double.parseDouble(keyboard.readLine());
}

for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
if (number[i] < number[j]) {
tem = number[i];
number[i] = number[j];
number[j] = tem;
}
}
}

System.out.println();
System.out.println("結果");

for (int i = 0; i < 5; i++){
System.out.println(number[i]);
}
}
}


for(x=0;x<5;x++)
{
for(y=0;y<5;y++)
{
if (number[x]>number[y])
{
z=number[x];
number[x]=number[y];
number[y]=z;
}
}
}

for(x=0;x<5;x++)
{
System.out.println(""+number[x]);
}
System.exit(0);
}
}

星期日, 12月 25, 2005

Lab 12-19-2005 Class Parameter"

package abc;

public class complex {
double real;
double imag;

public complex()
{
real=0;
imag=0;
}
public complex(double re,double im)
{
this.real = re;
this.imag = im;
}
public double real()
{
return real;
}
public double imag() {
return imag;
}

public void add(complex cccc)
{
this.real=this.real+cccc.real;
this.imag=this.imag+cccc.imag;
}

public static void main(String[] args) {
complex cc1=new complex(5,4);
complex cc2=new complex(2,2);
cc1.add(cc2);
System.out.println(""+cc1.real+"+("+cc1.imag+")i");

}
}

HW 12-12-2005 Counter II

package counter;
public class counter1 {
public static void main(String[] args) {
counter count1 = new counter(),
count2 = new counter();
count1.increment();
count1.decrement();
count2.increment();
count2.decrement();
if (count1.equals(count2))
System.out.println("The are equal");
else
System.out.println("The are not equal");
count2.increment();
if (count1.equals(count2)) {
System.out.println("The are equal");
} else {
System.out.println("The are not equal");

}
}
}
-----------------------------------------------------
package counter;
public class counter {
private int count = 0;
public void resetToZero() {
count = 0;
}

public void increment() {
count++;
}

public void decrement() {
if (count <= 0)
count = 0;
else
count--;
}
public int getValue()
{
return count;
}
public void output() {
System.out.println(" The counter is " + count);
}
public boolean equals(counter otherCounter)
{
return this.count == otherCounter.count;
}
public String toString() {
return Integer.toString(count);
}
}

星期一, 12月 19, 2005

Homework 12-5-2005

public class Temperature;
{
private float degree;
private char scale;
public void unknown()
{
degree=0;
scale='c';
}
public void setToZeroC()
{
degree=0;
scale='C';
}
public void returnC()
{
if(scale=='C')
{
this.degree=degree;
this.scale=scale;
}
else
{
this.degree=5*(degree-32)/9;
this.scale='C';
}
}
public void returnF()
{
if(scale=='F')
{
this.degree=degree;
this.scale-scale;
}
else
{
this.degree=(9*(degree)/5)+32;
this.scale='F';
}
}
public void setTheTemp(char scale)
{
this.scale=scale;
}
public void setTheTemp(float degree)
{
this.degree=degree;
}
public void setTheTemp(float degree,char scale)
{
this.degree=degree;
this.scale=scale;
}
public boolean comparisionEquals(Temperature temp)
{
if(this.scale==temp.scale)
{
if(this.degree==temp.degree)
return true;
else
return false;
}
else
{
if(this.scale=='F')
this.degree=(9*(this.degree)/5)+32;
else
temp.degree=(9*(temp.degree)/5)+32;
if(this.degree==degree)
return true;
else
return false;
}
}
public boolean comparisionGreater(Temperature temp)
{
if(this.scale==temp.scale)
{
if(temp.degree>this.degree)
return true;
else
return false;
}
else
{
if(this.scale=='F')
temp.degree=(9*(temp.degree)/5)+32;
else
this.degree=(9*(this.degree)/5)+32;
if(temp.degree>this.degree)
return true;
else
return false;
}
}
public boolean comparisionLess(Temperature temp)
{
if(this.scale==temp.scale)
{
if(temp.degree
return true;
else
return false;
}
else
{
if(this.scale=='F')
temp.degree=(9*(temp.degree)/5)+32;
else
this.degree=(9*(this.degree)/5)+32;
if(temp.degree
return true;
else
return false;
}
}
public void outPut()
{
System.out.println("The temperature = "+degree+" degrees "+scale);
}
}
-------------------------------------------
public class TemperatureDemo
{
public static void main(String[] arg)
{
float degree;
char scale;
Temperature temp1=new Temperature();
Temperature temp2=new Temperature();
temp1.unknown();
temp1.outPut();
temp2.setToZeroC();
temp2.outPut();
temp1.setTheTemp('F');
temp1.outPut();
temp1.setTheTemp(212);
temp1.outPut();
temp2.setTheTemp(100,'C');
temp2.outPut();
temp2.returnF();
temp2.outPut();
System.out.println("temp1 = temp2 ? "+temp1.comparisionEquals(temp2));
System.out.println("temp1 > temp2 ? "+temp.comparisionGreater(temp2));
System.out.println("temp1 < temp2 ? "+temp1.comparisionLess(temp2));
temp1.setTheTemp(0,'C');
temp1.returnF();
temp1.outPut();
temp1.setTheTemp(-40,'F');
temp1.returnC();
temp1.outPut();
}
}

Lab 12-12-2005 (2) Static Class

public class Lab12122
{
public static double i=1,j=1,k=0;
public static double next()
{
k=i+j;
i=j;
j=k;
return k;
}
public static void main(String[] args)
{
int m;
for(m=0;m<=100;m++)
{
Lab12122.next();
System.out.println("F"+m+":"+k);
}
}
}

Lab 12-12-2005 (1) Constructor

import java.io.*;
public class Lab1212
{
private String month;
private int day;
private int year;
public Lab1212()
{
month="January";
day=1;
year=1000;
}
public Lab1212(int monthInt,int day,int year)
{
setDate(monthInt,day,year);
}
public Lab1212(String monthString,int day,int year)
{
setDate(monthString,day,year);
}
public Lab1212(int year)
{
setDate(1,1,year);
}
public Lab1212(Lab1212 aDate)
{
if(aDate==null)
{
System.out.println("Fatal Error.");
System.exit(0);
}
month=aDate.month;
day=aDate.day;
year=aDate.year;
}
public void setDate(int monthInt,int day,int year)
{
if(dateOK(monthInt,day,year))
{
this.month=month(monthInt);
this.day=day;
this.year=year;
}
else
{
System.out.println("Fatal Error");
System.exit(0);
}
}
public void setDate(String monthString,int day,int year)
{
if(dateOK(monthString,day,year))
{
this.month=monthString;
this.day=day;
this.year=year;
}
else
{
System.out.println("Fatal Error");
System.exit(0);
}
}
public void setDate(int year)
{
setDate(1,1,year);
}
private boolean dateOK(int monthInt,int dayInt,int yearInt)
{
return((monthInt>=1)&&(monthInt<=12)&&(dayInt>=1)&&(dayInt<=31)
&&(yearInt>=1000)&&(yearInt<=9999));
}
private boolean dateOK(String monthString,int dayInt,int yearInt)
{
return(monthOK(monthString)&&(dayInt>=1)&&(dayInt<=31)
&&(yearInt>=1000)&&(yearInt<=9999));
}
private boolean monthOK(String month)
{
return(month.equals("January")||month.equals("February")
||month.equals("March")||month.equals("April")
||month.equals("May")||month.equals("June")
||month.equals("July")||month.equals("August")
||month.equals("September")||month.equals("October")
||month.equals("November")||month.equals("December"));
}
public void readInput()throws IOException
{
boolean tryAgain=true;
BufferedReader keyboard=new BufferedReader(new InputStreamReader(System.in));
while(tryAgain)
{
System.out.println("Enter month, day, and year.");
System.out.println("Do not use a comma.");
String monthInput=keyboard.readLine();
int dayInput=keyboard.read();
int yearInput=keyboard.read();
if(dateOK(monthInput,dayInput,yearInput))
{
setDate(monthInput,dayInput,yearInput);
tryAgain=false;
}
else
System.out.println("Illegal date. Reenter input.");
}
}
public void writeOutput()
{
System.out.println(month+" "+day+", "+year);
}
public void setMonth(int month)
{
if((month<=0)||(month>12))
{
System.out.println("Fatal Error");
System.exit(0);
}
else
this.month=month(month);
}
public void setMonth(String month)
{
this.month=month;
}
public void setDay(int day)
{
if((day<=0)||(day>31))
{
System.out.println("Fatal Error");
System.exit(0);
}
else
this.day=day;
}
public void setYear(int year)
{
if((year<=9999))
{
System.out.println("Fatal Error");
System.exit(0);
}
else
this.year=year;
}
public boolean equals(Lab1212 otherDate)
{
return((month.equalsIgnoreCase(otherDate.month))
&&(day==otherDate.day)&&(year==otherDate.year));
}
public boolean precedes(Lab1212 otherDate)
{
return((year
|| (year==otherDate.year&&getMonth()
|| (year==otherDate.year&&month.equals(otherDate.month)
&&day
}
public String toString()
{
return(month+" "+day+", "+year);
}
public int getDay()
{
return day;
}
public int getYear()
{
return year;
}
public int getMonth()
{
if(month.equalsIgnoreCase("January"))
return 1;
else if(month.equalsIgnoreCase("February"))
return 2;
else if(month.equalsIgnoreCase("March"))
return 3;
else if(month.equalsIgnoreCase("April"))
return 4;
else if(month.equalsIgnoreCase("May"))
return 5;
else if(month.equals("June"))
return 6;
else if(month.equalsIgnoreCase("July"))
return 7;
else if(month.equalsIgnoreCase("August"))
return 8;
else if(month.equalsIgnoreCase("September"))
return 9;
else if(month.equalsIgnoreCase("October"))
return 10;
else if(month.equalsIgnoreCase("November"))
return 11;
else if(month.equalsIgnoreCase("December"))
return 12;
else
{
System.out.println("Fatal Error");
System.exit(0);
return 0;
}
}
private String month(int monthNumber)
{
switch(monthNumber)
{
case 1:
return "January";
case 2:
return "February";
case 3:
return "March";
case 4:
return "April";
case 5:
return "May";
case 6:
return "June";
case 7:
return "July";
case 8:
return "August";
case 9:
return "September";
case 10:
return "October";
case 11:
return "November";
case 12:
return "December";
default:
System.out.println("Fatal Error");
System.exit(0);
return "Error";
}
}
}
-------------------------------------------
public class Lab1212Demo
{
public static void main(String[] args)
{
Lab1212 date1=new Lab1212("December",6,1770),
date2=new Lab1212(1,27,1756),
date3=new Lab1212(1882),
date4=new Lab1212();
System.out.println("Whose birthday is "+date1+"?");
System.out.println("Whose birthday is "+date2+"?");
System.out.println("Whose birthday is "+date3+"?");
System.out.println("The default date is "+date4+".");
}
}

Lab 12-5-2005 (2) Overloading

import java.io.*;
public class lab120502 {
private String month;
private int day;
private int year;
public void setDate(int monthInt, int day, int year)
{if (dateOK(monthInt,day,year))
{ this.month = monthString(monthInt);
this.day = day;
this.year = year;}
else
{System.out.println("Error");
System.exit(0);}
}
public void setDate(String monthString,int day,int year)
{if (dateOK(monthString,day,year))
{ this.month = monthString;
this.day = day;
this.year = year;}
else
{System.out.println("Error");
System.exit(0);}
}
public void setDate(int year)
{ setDate(1,1,year);}
private boolean dateOK(int monthInt,int dayInt,int yearInt)
{ return ((monthInt >= 1)&&(monthInt <= 12)&&(dayInt >= 1)&&(dayInt <= 31)
&&(yearInt >= 1)&&(yearInt <= 9999));}
private boolean dateOK(String monthString,int dayInt,int yearInt)
{ return (monthOK(monthString)&&(dayInt >= 1)&&(dayInt <= 31)
&&(yearInt >= 1)&&(yearInt <= 9999));}
private boolean monthOK(String month)
{ return (month.equals("Jan")||month.equals("Feb")||
month.equals("Mar")||month.equals("Apr")||month.equals("May")||
month.equals("Jun")||month.equals("Jul")||month.equals("Aug")||
month.equals("Sep")||month.equals("Oct")||month.equals("Nov")||
month.equals("Dec"));}
public void readInput()throws IOException
{ boolean tryAgain = true;
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
while (tryAgain)
{System.out.println("Enter month, day, and year:");
String monthInputString=keyboard.readLine();
int dayInput = keyboard.read();
int yearInput = keyboard.read();
if(dateOK(monthInputString,dayInput,yearInput))
{ setDate(monthInputString,dayInput,yearInput);
tryAgain = false;}
else
System.out.println("Illegal date. Reenter input.");
}
}
public String monthString(int monthNumber)
{switch(monthNumber)
{case 1:return "Jan";
case 2:return "Feb";
case 3:return "Mar";
case 4:return "Apr";
case 5:return "May";
case 6:return "Jun";
case 7:return "Jul";
case 8:return "Aug";
case 9:return "Sep";
case 10:return "Oct";
case 11:return "Nov";
case 12:return "Dec";
default :System.out.println("Error");
System.exit(0);
return "Error";
}
}
}
------------------------------------------------------------------------------------
public class lab120502demo {
public static void main(String[] args) {
lab120502 date1 = new lab120502(),
date2 = new lab120502(),
date3 = new lab120502();
date1.setDate(1,2,2008);
date2.setDate("Feb",2,2008);
date3.setDate(2008);
System.out.println(date1);
System.out.println(date2);
System.out.println(date3);
}
}

lab12/05

Mar 2 , 2007
Apr 2 , 2007
Jan 1 , 2007

lab 12/05


month = monthString(newmonth);
day = newday;
year = newyear;
改成
this.month = monthString(month);
this.day = day;
this.year = year;

HW11/28

HW11/28
public class Counter {
private int count;
public Counter() {
}
public void setZero()
{
count=0;
}
public void countIncrease()
{
count=count+1;
}
public void countDecrease()
{
if((count-1)>=0)
count=count-1;
else if((count-1)<0)
System.out.println("Decrease counnt is negative");
}
public int accessor()
{
return count;
}
public void out()
{
System.out.println(""+count);
}
public static void main(String[] args) {
}
}


public static void main(String[] args) {
Counter count1 = new Counter(),count2=new Counter();
System.out.println("count set to zero.");
count1.setZero();
System.out.print("coun1=");
count1.out();
System.out.print("coun2=");
count2.setZero();
count2.out();
System.out.println("count is increase or dercase");
System.out.print("coun1=");
count1.countIncrease();
count1.countIncrease();
count1.out();
System.out.print("coun2=");
count2.countIncrease();
count2.countDecrease();
count2.out();
if(count1 ==count2)
System.out.println("count1 is equal count2");
else
System.out.println("count1 does not equal count2");
count2.countIncrease();
count2.accessor();
}

lab11/28

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Display {
public Display() {
}

private String month;
private int day;
private int year;
public String toString() {
return (month + " " + day + ", " + year);
}

public void writeOutput() {
System.out.println(month + " " + day + ", " + year);
}

public boolean equals(Display otherDate) {
return (month.equals(otherDate.month) && day == (otherDate.day) &&
year == (otherDate.year));
}

public boolean precedes(Display otherDate) {
return (year < otherDate.year) ||
(year == otherDate.year && getMonth() < otherDate.getMonth()) ||
(year == otherDate.year && month.equals(otherDate.month)
&& day < otherDate.day);
}

public int getMonth() {
if (month.equals("Jan")) {
return 1;
} else if (month.equals("Feb")) {
return 2;
} else if (month.equals("Mar")) {
return 3;
} else if (month.equals("Apr")) {
return 4;
} else if (month.equals("May")) {
return 5;
} else if (month.equals("Jun")) {
return 6;
} else if (month.equals("Jul")) {
return 7;
} else if (month.equals("Aug")) {
return 8;
} else if (month.equals("Sep")) {
return 9;
} else if (month.equals("Oct")) {
return 10;
} else if (month.equals("Nov")) {
return 11;
} else if (month.equals("Dec")) {
return 12;
} else {
System.out.println("Fateal Error");
System.exit(0);
return 0;
}
}

public String monthString(int monthNmmber) {
switch (monthNmmber) {
case 1:
return "Jan";
case 2:
return "Feb";
case 3:
return "Mar";
case 4:
return "Apr";
case 5:
return "May";
case 6:
return "Jun";
case 7:
return "Jul";
case 8:
return "Aug";
case 9:
return "Sep";
case 10:
return "Oct";
case 11:
return "Nov";
case 12:
return "Dec";
default:
System.out.println("Fateal Error");
System.exit(0);
return "Error";
}

}

public void setDate(int newMonth, int newDay, int newYear) {
month = monthString(newMonth);
day = newDay;
year = newYear;
}
}


class EqualAndToStringDemo {
public static void main(String[] args) {
Display date1 = new Display();
Display date2 = new Display();
date1.setDate(6, 17, 1882);
date2.setDate(6, 17, 1882);
if (date1.equals(date2)) {
System.out.println(date1 + " equals " + date2);
} else {
System.out.println(date1 + " does not equal " + date2);
}
date1.setDate(7, 28, 1750);
if (date1.precedes(date2)) {
System.out.println(date1 + " comes before " + date2);
} else {
System.out.println(date2 + " comes before or is equal to " + date1);
}
}
}

HW 11/21

package untitled1;
import javax.swing.JOptionPane;
public class DateFirstTry {
private String month;
private int day;
private int year;

public void writeOutput()
{ System.out.println (month+" "+day+" "+year);}


public void readInput(){
month=JOptionPane.showInputDialog("Enter month");
String PString1=JOptionPane.showInputDialog("Enter day");
day=Integer.parseInt(PString1);
String PString2=JOptionPane.showInputDialog("Enter year");
year=Integer.parseInt(PString2);
}

public void setDate(int newMonth ,int newDay,int newYear){day=newDay;
year=newYear; month=monthString(newMonth);

}

public String monthString(int monthNumber){
switch(monthNumber){
case 1: return "January";
case 2: return "February";
case 3: return "March";
case 4: return "April";
case 5: return "May";
case 6: return "June";
case 7: return "July";
case 8: return "August";
case 9: return "September";
case 10: return "October";
case 11: return "November";
case 12: return "December";
default: System.exit(0); return "Eorror";}
}

public int getDay(){return day;}
public int getYear(){return year;}
public int getmonth(){if(month.equalsIgnoreCase("January")) return 1;
else if(month.equalsIgnoreCase("February")) return 2;
else if(month.equalsIgnoreCase("March")) return 3;
else if(month.equalsIgnoreCase("April")) return 4;
else if(month.equalsIgnoreCase("May")) return 5;
else if(month.equalsIgnoreCase("June")) return 6;
else if(month.equalsIgnoreCase("July")) return 7;
else if(month.equalsIgnoreCase("August")) return 8;
else if(month.equalsIgnoreCase("September")) return 9;
else if(month.equalsIgnoreCase("October")) return 10;
else if(month.equalsIgnoreCase("November")) return 11;
else if(month.equalsIgnoreCase("December")) return 12;
else{ System.out.println("FATAL ERROR"); System.exit(0); return 0;}

}}





package untitled1;



public class DateFirstTryDemo {

public static void main(String[] args)
{
DateFirstTry date =new DateFirstTry();
int year=1882;
date.setDate(6,17,year);// date.setDate(6, 17, year);
date.readInput();
date.writeOutput();


}
}

4.出現錯誤: 因為month的宣告是private所以其他的class無法使用,只能在month所在的class的method上使用。

星期一, 12月 05, 2005

Display 4.7

星期一, 10月 31, 2005

N pruduct

package aaaaa;

import javax.swing.JOptionPane;

public class aaa{
public static void main(String[] args) {
int i;
int ans=1;
int c;

while(1>=0)
{String number=JOptionPane.showInputDialog(" Enter a number");
c= Integer.parseInt(number);

ans=c*ans;
if (ans>=0)
{System.out.println("pruduct is "+ans);
}

else System.out.println("Finished");



}




}
}

費式級數的例子

所謂的費式級數,就是 0,1,1,2,3,5,8,13,21...and go on

他是數列前兩項之和,為他下一項的和.

大自然中最有明的例子就是生育的例子.

假設兔子一次只會生下一隻兔子,並且生下的兔子不會死亡.且生下的兔子還會在生下兔子
pair 數
則 1 1
1 1
1 1 2
1 1 1 3
1 1 1 1 1 1 5


另外蜜蜂的家族表

如果是公蜜蜂的話,他的長輩就是媽媽一隻照顧, 如果是母蜜蜂的話,他的長輩則是父母照顧

因此

父母 爺奶 祖父母 祖父母的父母 祖父母的爺爺奶奶
每一隻公蜜蜂 1 2 3 5 8
每一隻母蜜蜂 2 3 5 8 13

以上也是一個費事數列的例子


另外遠古的鸚鵡羅 他的排法就是

以正方形 邊長 不斷的擴張出去

邊長 1 1 2 3 5 並且繞者他角落不斷的旋轉出去

這個高中的時候有話過相關的圖形,應該也算是吧!

66667
52237
51137
54447
88888 概念圖 = =

EXP

public class EXP {

public static void main(String[] args)throws IOException
{


double i,n1=1,n2=0,count1=1,count2=1,sum1=0,sum2=1;
String sum=JOptionPane.showInputDialog("n=");
double n = Integer.parseInt(sum);
for (i=0;i<100;i++){
count1=count1*n;
count2=count2*n1;
sum1=count1/count2;
n2=n2+count1;
sum2=sum2+sum1;n1++;
}
System.out.println("N= " +n);
System.out.println("exp(N) is = " +sum2 );
}
}