早教吧 育儿知识 作业答案 考试题库 百科 知识分享

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.
▼优质解答
答案和解析
前两题,后面的继续给你写
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考试题请求各位大神帮个...的网友还看了以下:

中英两种早期教育方式,华人家长各有考量  2020-03-29 …

下列各项权力属于公安机关侦查权的有?A.收集各种证据的权力B.讯问犯罪嫌疑人的权力C.询问证人的权  2020-04-07 …

英语翻译现在人面临各种压力,有的来自工作,有的来自家庭,还有年轻人关于房子的压力等等,他们通过运动  2020-04-08 …

二战后社会主义国家力量壮大的客观原因是()A.二战使帝国主义国家力量削弱B.苏军追击法西斯军队进入  2020-05-12 …

詹天佑说:“各出所学,各尽所知,使国家富强不受外侮,足以自立于地球之上。”这一名言()①是以爱国主  2020-07-11 …

不用方程.1小玲全家有三口人,爸爸、妈妈、她.今年全家年龄和是68岁,5年前年龄和是54岁.已知爸爸  2020-11-13 …

人民代表大会制度作为中国共产党和中国人民的伟大创造,在当今世界政治体系中具有保证人民当家作主、协调国  2020-11-27 …

人民代表是国家权力机关的组成人员,其权力来源于人民,表现在①各级人大代表都由人民民主选举产生②人大代  2020-12-13 …

江泽民曾发表重要讲话强调,党和国家的各级领导干部要牢固树立明确的权力观,诚心诚意为实现人民群众利益而  2020-12-17 …

今大道既隐,天下为家,各亲其亲,各子其子,货力为己,大人世及以为礼。——〈礼记·礼运篇》请回答:(1  2020-12-22 …