java 实验一

 
 步骤 耗时h 百分比%
需求分析 0.3h

7.5

设计 2.5h 62.5
代码实现 0.5h 12.5
测试 0,2h 5
分析总结 0.5h 12.5

实验一 截图

实验二:

实验三

实现四则运算

代码:

import java.util.Scanner;
public class D1_jisuanqi {
public static void main(String[] args){
double x,y,s;
int i;
System.out.println("1是乘法,2是除法,3是加法,4是减法,5是取模");
Scanner sc = new Scanner(System.in);
i = sc.nextInt();
if (i == 1)
{
System.out.println("你将用乘法");
System.out.println("请输入x,y两个值:(用空格间隔)");
Scanner c = new Scanner(System.in);
x = c.nextDouble();
y = c.nextDouble();
s = x*y;
System.out.println("x*y的值是:"+s);
c.close();
}
else if (i == 2)
{
System.out.println("你将用除法");
System.out.println("请输入x,y的值:(用空格间隔)");
Scanner d = new Scanner(System.in);
x = d.nextDouble();
y = d.nextDouble();
s = x/y;
System.out.println("x/y的值是:"+s);
d.close();
}
else if (i == 3)
{
System.out.println("你将用加法");
System.out.println("请输入x,y的值:(用空格间隔)");
Scanner e = new Scanner(System.in);
x = e.nextDouble();
y = e.nextDouble();
s = x+y;
System.out.println("x+y的值是:"+s);
e.close();
}
else if(i == 4)
{
System.out.println("你将用减法");
System.out.println("请输入x,y的值:(用空格间隔)");
Scanner f = new Scanner(System.in);
x = f.nextDouble();
y = f.nextDouble();
s = x-y;
System.out.println("x-y的值是:"+s);
f.close();
}
else
{
System.out.println("你将用取模");
System.out.println("请输入x,y的值(用空格间隔)");
Scanner g = new Scanner(System.in);
x = g.nextDouble();
y = g.nextDouble();
s = x%y;
System.out.println("x%y的值是:"+s);
g.close();
}
sc.close();
}
}

 

 

 

package ljp;

import java.util.Scanner;

public class Hello {

    public static void main(String[] agrs){

        System.out.println("Input your first name,please:");

        Scanner s =new Scanner(System.in);

        String name = s.next();

        System.out.println("Hello"+name+"!");

    }

posted @ 2015-04-15 22:17  20135311不是富东京  阅读(127)  评论(0编辑  收藏  举报