扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
import java.util.Scanner;
万秀网站制作公司哪家好,找成都创新互联!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。成都创新互联公司2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联。
public class Variate {
/**
* 数字排序
*/
public static void variate1(){
Scanner in = new Scanner(System.in);
System.out.println("请输入第一个数字:");
float first = in.nextFloat();
System.out.println("请输入第二个数字:");
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(profit 10 profit = 20){
bonus = (profit - 10) * 0.075 + 10 * 0.1;
}else if(profit 20 profit = 40){
bonus = (profit - 20) * 0.05 + 20 * 0.1;
}else if(profit 40 profit = 60){
bonus = (profit - 40) * 0.03 + 40 * 0.1;
}else if(profit 60 profit = 100){
bonus = (profit - 60) * 0.015 + 60 * 0.1;
}else if(profit 100){
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(vowel capital){
System.out.println("输入的是大写元音字母:" + liter);
}else{
System.out.println("输入的是小写元音字母:" + 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){
case '+' : result = first + second; break;
case '-' : result = first - second; break;
case '*' : result = first * second; break;
case '/' : result = first / second; break;
default : result = 0;
}
System.out.println("计算结果为:" + result);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
variate1();
System.out.println("可提成" + bonus() + "万元");
variate2();
calculator();
}
}
package com.text;
public class Animal {//动物方类
private String Name;//成员变量 名字 私有的
private int Age;//成员变量 年龄 私有的
private String Color;//成员变量 颜色 私有的
-----------------------------
public void Cry(){//成员方法(成员函数) 下面是方法体
System.out.println("我是一只"+this.Name+",颜色是"+this.Color+",我今年"+this.Age+"岁了。");
}
--------------------------------------------
通常情况下一个类还要有构造函数 作用是给成员变量附初始值
-----------------------------------------------------------
public Animal(String Name,int Age,String Color){//动物类的构造函数
this.Name=Name;
this.Age=Age;
this.Color=Color;
}
java代码如下: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class IoDemo { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(System.in)); System.out.println("请输入:"); String str = bufferedReader.readLine(); System.out.println("输入的内容是:" + str); } }
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流