java常见的代码 java代码长什么样( 二 )


}
return sb.toString();
}
}
主要的除了转16进制,就是用RandomAccessFile的seek来快速定位倒数的三个字节的位置 。还有问题的话,baiduhi我 , 随时在线
求几个简单的JAVA代码,关于变量的import java.util.Scanner;
public class Variate {
/**
* 数字排序
*/
public static void variate1(){
Scanner in = new Scanner(System.in);
System.out.println("请输入第一个数字java常见的代码:");
float first = in.nextFloat();
System.out.println("请输入第二个数字java常见的代码:");
float second = in.nextFloat();
System.out.println("请输入第三个数字:");
float third = in.nextFloat();
if(first - second = 0){
if(second - third = 0){
System.out.println("三个数字从大到小顺序为:" + first + "=" + second + "=" + third);
}else if(first - third = 0){
System.out.println("三个数字从大到小顺序为:" + first + "=" + third + "=" + second);
}else{
System.out.println("三个数字从大到小顺序为:" + third + "=" + first + "=" + second);
}
}else if(first - third = 0){
System.out.println("三个数字从大到小顺序为:" + second + "=" + first + "=" + third);
}else if(second - third = 0){
System.out.println("三个数字从大到小顺序为:" + second + "=" + third + "=" + first);
}else{
System.out.println("三个数字从大到小顺序为:" + third + "=" + second + "=" + first);
}
}
/**
* 利率计算
*/
public static double bonus(){
float profit = 0;
double bonus = 0;
Scanner in = new Scanner(System.in);
System.out.println("请输入利润(万元):");
profit = in.nextFloat();
if(profit = 10){
bonus = profit * 0.1;
}else if(profit10profit = 20){
bonus = (profit - 10) * 0.075 + 10 * 0.1;
}else if(profit20profit = 40){
bonus = (profit - 20) * 0.05 + 20 * 0.1;
}else if(profit40profit = 60){
bonus = (profit - 40) * 0.03 + 40 * 0.1;
}else if(profit60profit = 100){
bonus = (profit - 60) * 0.015 + 60 * 0.1;
}else if(profit100){
bonus = (profit - 100) * 0.01 + 100 * 0.1;
}
return bonus;
}
/**
* 判断元辅音字母
*/
public static void variate2(){
Scanner in = new Scanner(System.in);
System.out.println("请输入一个字母:");
char liter = in.next().charAt(0);
boolean vowel = false;
boolean capital = false;
switch (liter){
case 'A' : vowel = capital = true; break;
case 'O' : vowel = capital = true; break;
case 'E' : vowel = capital = true; break;
case 'I' : vowel = capital = true; break;
case 'U' : vowel = capital = true; break;
case 'a' : vowel = true; break;
case 'o' : vowel = true; break;
case 'e' : vowel = true; break;
case 'i' : vowel = true; break;
case 'u' : vowel = true; break;
default : vowel = capital = false;
}
if(vowel || capital){
if(vowelcapital){
System.out.println("输入java常见的代码的是大写元音字母:" + liter);
}else{
System.out.println("输入java常见的代码的是小写元音字母:" + liter);
}
}else{
System.out.println("输入的是辅音字母:" + liter);
}
}
/**
* 简单计算
*/
public static void calculator(){
Scanner in = new Scanner(System.in);
double first = 0;
double second = 0;
double result = 0;
char operator;
System.out.println("请输入第一个数字:");
first = in.nextDouble();
System.out.println("请输入第二个数字:");
second = in.nextDouble();
System.out.println("请输入运算符:");
operator = in.next().charAt(0);
switch(operator){

推荐阅读