2009年3月9日 星期一

Lab Keyboard precessing

Project 3 of Chap. 2

------------------------------------------------<程式碼開始>--------------------------------------

import java.awt.*;
import java.applet.*;
import javax.swing.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class S952621502 extends JApplet {
public static void main( String[] args ) throws IOException
{
System.out.println("Enter two number to sum, difference, and product.");
BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));
String n1 = keyboard.readLine();
String n2 = keyboard.readLine();
int N1 = Integer.parseInt(n1);
int N2 = Integer.parseInt(n2);
int N3 = N1 + N2;
int N4 = N1 - N2;
int N5 = N1 * N2;
System.out.println(N1 + "+" + N2 + "=" + N3);
System.out.println(N1 + "-" + N2 + "=" + N4);
System.out.println(N1 + "*" + N2 + "=" + N5);
}
}
------------------------------------------------<程式碼結束>--------------------------------------

沒有留言:

張貼留言