早教吧作业答案频道 -->其他-->
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考试题请求各位大神帮个...的网友还看了以下:
一些苹果(100个以内),按每份3个分多一个,每份5个分多3个,每份7个分多2个,问这些苹果有多少 2020-04-27 …
大家帮我解几道填空题1.甲数比乙数多1/3,乙数与甲数的比是():()2.甲乙两数和比乙数多7.6 2020-04-27 …
谁帮我下这几数学题.,要用一次函数.我看不懂A和B己知A比B多2谁帮我下这几数学题.,要用一次函数 2020-05-13 …
数学.解方程组,帮帮忙吧,~{2(x-2)+2=-2和{3分之(x-1)-2分之(-1-x数学.解 2020-05-13 …
数学题,各位高手帮帮忙1.某超市用5万元从外地采购一批T恤衫,由于销路好,该超市又紧急调拨18.6 2020-08-01 …
请各位大虾帮帮小妹,我将感激不尽.(1)少先队员参加植树,准备栽的苹果树苗是梨树苗的2倍.如果每人栽 2020-11-08 …
画2次函数的图象TVT第一个Y=-3(X-2)的平方+9第2个Y=4X的平方-24X+26第3个Y= 2020-11-24 …
帮我~~~数学我不会做找规律的题,请教我怎么做.有一道题不知你们做过没?第1幅图没树枝,第2幅图比第 2020-11-27 …
帮做下急用啊帮帮忙多选题(共4道试题,共24分.)1.从结构上来讲,绝缘子可以分为().A.绝缘子( 2020-12-08 …
帮忙写串词!急用啊!帮帮我啊!是写诗歌朗诵会的串词和开场白!后天上午就要要了!有14首诗歌!帮忙写串 2020-12-29 …