早教吧作业答案频道 -->其他-->
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考试题请求各位大神帮个...的网友还看了以下:
动能公式只与初速度和末速度有关吗?将物体以初速度v0斜向上抛出,v0与水平方向的夹角为θ,落地时物体 2020-03-30 …
物理题目,流水以初速度V1进入V型管,流出时速度为V2.V1=V2=V,设每秒进入的水的质量为Q求在 2020-03-31 …
一辆汽车在平直的公路上加速行驶,受到恒定的阻力作用,当速度为v时,汽车发动机功率为p,此时汽车的牵 2020-05-16 …
质量m、速度大小为v的指点,在受某个力的作用后,其速度的大小未变,质量m、速度大小为v的指点,在受 2020-05-17 …
如图所示,V形细杆AOB能绕其对称轴OO′转动,OO′沿竖直方向,V形杆的两臂与转轴间的夹角均为α 2020-07-31 …
如图所示,V形细杆AOB能绕其对称轴OO′转到,OO′沿竖直方向,V形杆的两臂与转轴间的夹角均为α 2020-07-31 …
质量为m的汽车,启动后沿平直路面行驶,如果发动机的功率为P,且行驶过程中受到的摩擦阻力大小一定,汽 2020-08-02 …
一辆车的功率一定,根据p=Fv得,力越大,v越小,但是我认为F越大,合力越大,a越大,v越大才对,请 2020-11-16 …
(2013•黄浦区一模)静止在光滑水平面上的物体,受到一个大小不为零的水平拉力作用,若拉力开始作用瞬 2021-01-22 …
有关P=Fv这一公式的理解F是合力吗?比如,摩擦力,重力的分力,安培力同时作用于某物体(力都在同一直 2021-01-23 …