Suppose that for the Employee method pay of Exercise 4.6, hours and rate are par
ID: 3622281 • Letter: S
Question
Suppose that for the Employee method pay of Exercise 4.6, hours and rate are parameters rather than instance variables. That is, supposed the method is specified aspublic double pay (int hours, double rate)
Write a complete specification, including reasonable preconditions and postconditions, for this method.
Also, Develop a test plan for the method pay of this class.
Explanation / Answer
Dear, class employee { private int hours; private double rate; public employee(int hr,double rt) { hours=hr; rate= rt; } public double pay(int hr,double rt) { double totpay; if(hr>0) { totpay=hr*rt; } return totpay; } } public class test { public static void main(String[] args) { employee obj=new employee(); //function call to to get pay System.out.println("Total pay:"+obj.pay(64,500)); System.exit(0); } }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.