早教吧作业答案频道 -->其他-->
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考试题请求各位大神帮个...的网友还看了以下:
大工11春《大学英语3》在线作业2试卷总分:100测试时间:--单选题判断题一、单选题大工11春《 2020-04-26 …
物理题-大气压强将一大试管开口朝上,灌满水,再将一个稍小的试管地朝下插入大试管水中某一深度,然后将 2020-05-14 …
这一道题怎么做?(请写出详细过程)1.一种试管有两种规格,大试管容量25.5毫升,是小试管容量的3 2020-05-20 …
难度较大的初中数学试题新华书店有各种各样的初中试题或试卷.如轻巧夺冠,启东中学作业本,状元笔记,五 2020-06-13 …
一次考试共5道题,考试结果统计如下:做对第一题的占考试总人数的90%,做对第二道题的占考试总人数的 2020-06-16 …
一次考试共5题,考试结果统计如下:做对第一题的占考试总人数的百分之90,做对第二题的占考试总人数的 2020-06-16 …
求焊接高手做份试卷高技焊工的题·考试用·很重要·希望好好答·别错了·百度应该都能收索到的题·真心希 2020-06-29 …
如图所示,取大小试管各一支,大试管的内径略大于小试管的外径.先在大试管里装满水,再把小试管的一部分 2020-07-31 …
问个初二物理题在一支大试管中装满水,将小试管(不装水)一半插入大试管中,将他们倒置过来,将会怎么样? 2020-10-31 …
求大家为我解答俩道大学统计学题目,非常急的,本人数理盲,等一下快补考考试了,因为这俩道题考试可能回去 2020-11-06 …