運算符第二次課
/*
//課前練習:兩道題
//編程計算:一個白領工作加班了89個小時,編程計算共加了多少天零多少小時?
int x=89;
int y=89/24;//存儲加了幾天班
int z=89%24;
System.out.println("加班了"+y+"天"+z+"小時");
//求長方形的周長c和面積s,設長方形的長、寬分別為a,b
float a,b,c,s;
a=3;
b=2;
c=(a+b)*2;
s=a*b;
System.out.println("面積是"+s+"周長是"+c);
int a=3;
int b=2;
//任務一:算術運算符(下篇)
//a+=b;//a=a+b;
//a-=b;
//a*=b;
a/=b;
a%=b;
System.out.println(a);
int m=5;
m+=1;
System.out.println("m="+m);*/
//任務二:比較運算符
System.out.println(3==2);
System.out.println(3!=2);
//任務三:邏輯運算符
System.out.println((3==2)&(3!=2));
System.out.println((3==2)|(3!=2));
System.out.println(!(3>2));
System.out.println((7>=6)&(3==1));//false
System.out.println((3==1)&&(7>=6));
System.out.println(3==1&7>=6);
//任務四:練習寫表達式
// x<=0
//(x>0)&&(x<5)
// (x>=0)&&(x<=10)
// x<=5|x>=10
//任務五:寫思評分的表達式s
//不及格:0<=s && s<60
//及格: s>=60 && s<80
//良好: s>=80 && s<90
//優秀: s>=90 && s<=100
//任務六:三元運算符 有兩條分支
String str= 3<2?"aaa":"bbb";
System.out.println(str);
/*求表達式的值
y = |x| x為整數,y為x的絕對值
如果 x>=0 y = x
x<0 y = - x*/
int x=-3,y;
//x>=0?x:-x;
y=x<0?-x:x;
System.out.println(y);
運算符第二次課