首页 > 代码库 > java练手
java练手
public class jichu{
public static void main(String[] args){
// 输出控制台
System.out.print("hello world");
}
}
public class jichu{
public static void main(String[] args){
int number=23;
String i="我爱你";
char b=‘女’;
double c=1.45;
//输出控制台
System.out.println(number);
System.out.println(i);
Ststem.out.print(b);
System.out.print(c);
}
}
public class jichu{
public static void main(String[] args){
String brand="爱国者F928";
String type="内置锂电池";
double weight=12.4;
int price=499;
//输出控制台
System.out.println("品牌:"+brand);
System.out.println("重量:"+weight);
System.out.println("电池类型:"+price);
System.out.println("价格:"+type);
}
}
public class jichu{
public static void main(String[] args){
int A=80;
//int B=80;
//同类型的可以赋值
int B=A;
System.out.println(B);
}
}
public class jichu{
public static void main(String[] args){
int Java=90;
int STB=89;
int SQL=60;
int AA=Java-SQl;
int sum=Java+SQL+STB;
int avg=sum/3;
System.out.println(AA);
// 非数值 数值
System.out.println("平均分"+avg);
}
}
public class jichu{
public static void main(String[] ards){
int days=46;
int week=7;
int weekend=days/week;
int date=days%week;
System.out.println("剩余"+date+"天");
System.out.println("有"+weekend+"周");
}
}
public class jichu{
public static void main(String[] args){
int A=5;
double AA=1.3;
double sum=A+AA;
System.out.println(sum);
}
}
public class jichu{
public static void mian(String[] args){
String A="与";
char B=‘男‘;
char V=‘女‘;
String sum=A+B+V;
System.out.println();
}
}
public class jichu{
public static void main(String[] args){
int year=20;
double f=9.8;
int B=(year+(int)9.8)
System.out.println(B);
}
}
import java.util.Scanner;
public class jichu{
public static void main(String[] args){
Scanner in=new Scanner(System.in);//输入设备
System.out.println("请输入你的姓名:");
String name=in.next();
System.out.println("请输入你的年龄:");
int age=in.nextInt();
System.out.println("姓名:"+name);
system.out.println("年龄:"+age);
}
}
public class jichu{
public static void main(String[] args){
int radius=10;
double high=1.9;
int value=http://www.mamicode.com/(int)(3.14*radius*radius*high);
System.out.println();
}
}
public class jichu{
public static void main(String[] args){
int num1=19;
int num2=89;
int temp;
temp=num1; num1=num2; num2=temp;
System.out.println("temp的值:"+temp);
System.out.println("num1的值:"+num1);
SyStem.out.println("num2的值:"+num2);
}
}
public class jichu{
public static voiod main(String[] args){
int A=2;
int B=2;
boolean flag;
A==B;
flag=A==B;
System.out.println(flag);
}
}/*
>大于
<小于
!= 不等于
== 等于
<= 小于等于
>= 大于等于
*/
import java.util.Scanner;
import java.util.*;
public class jichu{
public static void main(Strimng[] args){
Scanner in=new Scanner(System.in);
System.out.println("请输入你的成绩:");
int score=in.nextInt();
//if(score>90){
if (score>90==false) {
System.out.println("奖励一本书");
}
System.out.println("正在测试");
}
}
import java.util.Scanner;
public class jichu{
public static void main(String[] args){
Scanner in=new Scaner(Sysytem.in);
System.out.println("请输入你的JAVA成绩:");
int Java=in.nextInt();
System.out.println("请输入你的SQL成绩:");
int SQL=in.nextInt();
// if(Java>90&&SQL>90){
if(!(Java>90)&&SQL>90){
System.out.println("送你一本书");
}
}
System.out.println("测试");
}
}
public class jichu{ //3+4*5=23
public static void main(String[] args){
if(!(4>5)&&5>4||4>3){
System.out.println("成立");
}
}
public class jichu{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("请输入你的成绩:");
int scone= in.nextInt();
// if (scone>=90) {
// System.out.println("优秀");
// }
// if (scone>=80&&scone<90) {
// System.out.println("良好");
// }
// if(scone>=60&&scone<80){
// System.out.println("及格");
// }
// if (scone<60) {
// System.out.println("不及格");
// }
// System.out.println("测试");
if (scone>=90) {
System.out.println("优秀");
}else if (scone>=80) {
System.out.println("良好");
}else if (scone>=60) {
System.out.println("及格");
}else{
System.out.println("不及格");
}
System.out.println("测试");
}
}
import java.util.Scanner;
public class jichu{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("请问你的性别是?(boy/girl)");
String sex=in.next();
if(sex.equals("boy")){
//if(sex=="boy"){
System.out.println("你的年龄多少岁?");
int age=in.nextInt();
if(age>=18){
System.out.println("成年");
}
}else{
System.out.println("未成年");
}
}else{
System.out.println("原来是一位girl");
}
}
}
import java.util.*;
public class jichu{
public static void main(String[] args){
Scanner in=new Scanner(SyStem.in);
System.out.println("请输入你的名次:");
int mingci=in.nextInt();
//char mingci=‘女‘;
// if(mingci==1){
// System.out.println("出任盟主");
// }
// if(mingci==2){
// System.out.println("出任掌门");
// }
// if(mingci==3){
// System.out.println("出任师傅");
// }
// if(mingci>3){
// System.out.println("出任守山大弟子");
// }
switch(mingci){ // 开关
case 1:// 案例
//case ‘女‘:
System.out.println("出任盟主");
break;// 跳出
case 2:
System.out.println("出任掌门");
break;
case 3:
System.out.println("出任师傅");
break;
default:// 默认
System.out.println("出任守山大弟子");
}
}
}
public class jichu{
public static void main(String[] args){
}
}
//奇数偶数
import java.util.*;
public class jichu{
public static void main(String[] args){
Scnaner in=new Scanner(System.in);
Sysytem.out.println("输入一个数:");
int number=in.nextInt();
if(number==0){
System.out.println("请不要输入0,我们只计算正整数的偶数!");
}
else{
if(number%2==0){
System.out.println(number+"是一个偶数!");
}
else{
System.out.println(number+"是一个奇数!");
}
}
}
}
import java.util.*;
public class jichu{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("输入年份:");
int i=in.nextint();
if (i%4==0&&i/100!=0||i%400==0) {
System.out.println(i+"是一个瑞年");
}else{
System.out.println(i+"是一个平年");
}
}
}
import java.util.Random;
public class jichu{
public static void main(String[] args){
Random c=new.Random();
int number=c.nextInt(10);//0~9的随机数;
System.out.println("随机数"+number);
}
}
public class jichu{
public static void main(StringP[] args){
// System.out.println(Math.random()*10);
//随机数0~9;
// 但是double类型的数
int number=(int)(Math.random()*10);
System.out.println("随机数是:"+number);
//支持多线程的
}
}
import java.util.Scanner;
import java.util.Random;
public class jichu{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("------猜拳游戏--------");
System.out.println("请出( 1.剪刀 2.石头 3.布)");
int person=in.nextInt();
int computer(int)(Math.random()*3)+1;
String P="拳头";//做一个标记
String C="拳头"
// System.out.println(computer);
switch(person){
case 1:
P="剪刀";
break;
case 2:
P="石头";
break;
case 3:
P="布";
break;
}
switch(computer){
case 1:
C="剪刀";
break;
case 2:
C="石头";
break;
case 3:
C="布";
break;
}
if (person==1&&computer==1) {
System.out.println("平局"+P+"电脑出的是"+C);
}else if(person==1&&computer==2||person==2&&computer==3||person==3&&computer==1){
System.out.println("你出的是:"+P+"电脑出的是"+C+"你输了");
}else{
System.out.println("你出的是:"+P+"电脑出的是"+C+"你赢了");
}
}
}
java练手