早教吧作业答案频道 -->其他-->
java考试题请求各位大神帮个忙能答多少答多少人多力量大谢谢大家了。!!1)Writeamethodthatreceivestwointparametersandreturnsthesmallerofthetwovalues.CallyourmethodgetSmaller.2)Writeamethodt
题目详情
java 考试题 请求各位大神帮个忙 能答多少 答多少 人多力量大 谢谢大家了。!!
1) Write a method that receives two int parameters and returns the smaller
of the two values. Call your method getSmaller.
2) Write a method that receives two String objects and returns true if the
two Strings start with the same character (ignoring case) and false
otherwise.
3) Using the Die class, write a method that will use two Die, roll them
100 times and return the number of times that the sum of the two is
7 or 11.
For questions 4 and 5, write the requested portions of a class called Employee.
4) An Employee will have a name, social security number, position, and
hourly wages. Define the instance data for this class.
5) Write a method that is passed the int value of the number of hours worked
for the week as a parameter, and returns the pay for the Employee,
including overtime, which is 1.5 * hourly wages for each hour over 40.
1) Write a method that receives two int parameters and returns the smaller
of the two values. Call your method getSmaller.
2) Write a method that receives two String objects and returns true if the
two Strings start with the same character (ignoring case) and false
otherwise.
3) Using the Die class, write a method that will use two Die, roll them
100 times and return the number of times that the sum of the two is
7 or 11.
For questions 4 and 5, write the requested portions of a class called Employee.
4) An Employee will have a name, social security number, position, and
hourly wages. Define the instance data for this class.
5) Write a method that is passed the int value of the number of hours worked
for the week as a parameter, and returns the pay for the Employee,
including overtime, which is 1.5 * hourly wages for each hour over 40.
▼优质解答
答案和解析
前两题,后面的继续给你写
public int getSmaller(int a,int b){
if(a<=b){
return a;
}else{
return b;
}
}
public boolean checkFirstLetter(String a,String b){
if(a.toLowerCase().charAt(0)==b.toLowerCase().charAt(0)){//不区分大小写,区分的话把.toLowerCase()去掉
return true;
}else{
return false;
}
}
第四题
public class Employee {
private String name="小明";
private String socialSecurityNumber="abcdefg";
private String position="图书管理员";
private Float hourlyWages=5.0f;
public String getName() {
return name;
}
public String getSocialSecurityNumber() {
return socialSecurityNumber;
}
public String getPosition() {
return position;
}
public Float getHourlyWages() {
return hourlyWages;
}
}
第五题
public Float getPayForEmployee(int hour){
Float wages=0f;
Employee e=new Employee();
if(hour >40){
wages=(hour-40)*e.getHourlyWages()+40*e.getHourlyWages();
}else{
wages=40*e.getHourlyWages();
}
return wages;
}
第三题我再看看是什么意思
public int getSmaller(int a,int b){
if(a<=b){
return a;
}else{
return b;
}
}
public boolean checkFirstLetter(String a,String b){
if(a.toLowerCase().charAt(0)==b.toLowerCase().charAt(0)){//不区分大小写,区分的话把.toLowerCase()去掉
return true;
}else{
return false;
}
}
第四题
public class Employee {
private String name="小明";
private String socialSecurityNumber="abcdefg";
private String position="图书管理员";
private Float hourlyWages=5.0f;
public String getName() {
return name;
}
public String getSocialSecurityNumber() {
return socialSecurityNumber;
}
public String getPosition() {
return position;
}
public Float getHourlyWages() {
return hourlyWages;
}
}
第五题
public Float getPayForEmployee(int hour){
Float wages=0f;
Employee e=new Employee();
if(hour >40){
wages=(hour-40)*e.getHourlyWages()+40*e.getHourlyWages();
}else{
wages=40*e.getHourlyWages();
}
return wages;
}
第三题我再看看是什么意思
看了java考试题请求各位大神帮个...的网友还看了以下:
人的主观能动性.1、人的主观能动性是随机吗?2、人的主观能动性能在多大程度上得以体现?(从单个人改 2020-05-16 …
关于做功和能量的说法A 具有能量的物体一定对外做了功B 物体具有的能量越大,它做的功一定越多C 物 2020-05-17 …
关于动能的概念,下列说法正确的是()A.速度越大的物体动能就越大B.动能越大的物体速度就越大C.物 2020-06-16 …
最好简单点,也不要太简单是应用题哟!能不能多点大概50题左右吧 2020-06-29 …
三峡大坝水位提高大大提高了我国水资源的利用率下列正确的是A水轮机是利用水流的动能转动的B水的动能越 2020-07-10 …
40吨锅炉爆炸能量是多少大40吨锅炉爆炸能量是多少大一个爆炸在它边上的也会炸吗如果会炸那一起爆炸的能 2020-11-10 …
“干不干,照吃饭--好坏不分;多劳不能多得--大小不分;社员占用公家东西--公私不分.”之所以出现2 2020-11-14 …
六、品读诗歌,积累感悟。让母亲不再忧伤如果天空多下一场雨,我就能痛痛快快地洗个澡。天空能多下一场雨吗 2020-12-04 …
“干不干,照吃饭--好坏不分;多劳不能多得--大小不分;社员占用公家东西--公私不分.”之所以出现2 2020-12-10 …
一个物体能够,就说这个物体具有能量.能量是表示物体本领大小的物理量,能量的大小可用能够做功的多少来度 2020-12-20 …