初涉江湖

从昨天起开始学习java  从此坚定信念一条道走到黑

昨天讲了一些java的历史和基础知识 没啥好说的   要点:1.JDK的安装 环境变量的设置 2.快捷键alt+/  (main    sysout)  

今天上机练习  

这两天写的代码 

/**import java.util.Scanner;


public class lianxi {


public static void main(String[] args) {


System.out.println("请输入第一个数字:");
Scanner yi = new Scanner(System.in);
int a = yi.nextInt();
System.out.println("请输入运算符:");
Scanner yun = new Scanner(System.in);
String b = yun.next();
System.out.println("请输入第二个数字");
Scanner er = new Scanner(System.in);
int c = er.nextInt();
if (b.equals("+")) {
a += c;
System.out.println(a);
} else if (b.equals("-")) {
a -= c;
System.out.println(a);


} else if (b.equals("*")) {
a *= c;
System.out.println(a);
} else if (b.equals("/")) {
a /= c;
System.out.println(a);


}
}


}
 */


/**import java.util.Scanner;


 public class lianxi {
 public static void main(String args[])


 {
 System.out.println("请输入数字:");
 Scanner yi = new Scanner(System.in);
 int a = yi.nextInt();
 System.out.println("请输入运算符:");
 Scanner fu = new Scanner(System.in);
 String b = fu.next();
 System.out.println("请输入数字:");
 Scanner er = new Scanner(System.in);
 int c = er.nextInt();
 if (b.equals("+"))
 a += c;
 else if (b.equals("-"))
 a -= c;
 else if (b.equals("*"))
 a *= c;
 else if (b.equals("/"))
 a /= c;


 System.out.println(a);


 }


 }*/


/**import java.util.Scanner;


 public class lianxi {
 public static void main(String args[]) {


 System.out.println("输入:");
 Scanner yi = new Scanner(System.in);
 int a = yi.nextInt();
 System.out.println("符号:");
 String b = yi.next();
 System.out.println("输入:");
 int c = yi.nextInt();
 if (b.equals("+"))
 a += c;
 else if (b.equals("-"))
 a -= c;
 else if (b.equals("*"))
 a *= c;
 else if (b.equals("/"))
 a /= c;
 System.out.println(a);


 }
 }*/


import java.util.Scanner;


public class lianxi {
public static void main(String args[]){
System.out.println("输入");
Scanner shuru=new Scanner(System.in);
int a=shuru.nextInt();
String b=shuru.next();
int c=shuru.nextInt();
if (b.equals("+"))
a+=c;
else if (b.equals("-"))
a-=c;
else if (b.equals("*"))
a*=c;
else if (b.equals("/"))
a/=c;
System.out.println(a);
}
}




import java.util.Scanner;


public class xunhuan {
public static void main(String[] args) {
/**
* boolean x=true; boolean y=false; System.out.println(x&y);
* System.out.println(x|y); System.out.println(x^y);
* System.out.println(x&&y); System.out.println(x||y); //逻辑运算符运算 int
* b=~3; System.out.println(b);

* int salary; String type; type="工人";
* salary=type.equals("经理")?3000:2000;
* System.out.println("我们的薪水是"+salary); //三元运算符 Scanner scan=new
* Scanner(System.in); System.out.println("请输入一个数字"); int
* in=scan.nextInt(); if(in%2==0) System.out.println(in+"是个偶数"); else
* System.out.println(in+"是个奇数"); //流程控制 for

* switch (in) { case 200: System.out.println("良好"); break; case 100:
* System.out.println("优秀"); break; default: System.out.println("较差"); }
* //流程控制 switch int i=1; do { in++; i++; } while (i<=100);
* System.out.println(in); //do循环

* while (i<=100) { in++; i++; } System.out.println(in); //while循环 int
* k; for( k=1;k<=10;k++) { System.out.println(in); in=in*k; }
* System.out.println(in); System.out.println(k); //for循环
*/
System.out.println("请输入第一个数字:");
Scanner shu = new Scanner(System.in);
int down = shu.nextInt();
System.out.println("请输入运算符:");
Scanner ru = new Scanner(System.in);
String a = ru.next();
System.out.println("请输入第二个数字:");
Scanner er = new Scanner(System.in);
int go = er.nextInt();

if (a.equals("+"))
{

down += go;
System.out.println(down);
}
else if (a.equals("-")) {
down= down-go;
System.out.println(down);
}
else if (a.equals("*")) {
down =down*go;
System.out.println(down);
}
else if (a.equals("/")) {
down /= go;
System.out.println(down);
}

}


}




呵呵 挺幼稚的程序  今天的收获是掌握了如何接收从外部输入的数据并存储   import java. until.Scanner;       Scanner   ver=new  Scanner(System.in);

int a=ver.nextInt();


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值