Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

All input, processing (calculations-etc), and output are to be in methods in a u

ID: 3647547 • Letter: A

Question

All input, processing (calculations-etc), and output are to be in methods in a user-defined class. Write an application class file in which an object of the user-defined class is created and the methods of the user-defined class are called. The application should not do anything else. Also do no use class Scanner for input. This program is to use the GUI JOptionPane commands (very end of chapter 3 and the examples under the examples with explanation button on the left). In a loop (see chapters 4 and 5 for loops) have the user enter the the employee's name using JOptionPane commands. Then enter the hours using the JOptionPane commands. You will need to convert the value for hours to an integer or double to use it. Next, call the class method to calculate and return the weekly pay. In that method, determine if the hours worked are > 40. If so, pay is 1.5 times the regular pay. Set regular pay to 10.00 per hour( you can create a constant if you wish). Use the appropriate GUI JOptionPane command to print out the concatenated employees name on one line, the hours worked on the next line and the amount of the weekly pay on a third line. (See sample in Examples w/Explanations button in Blackboard). There should then be another InputDialog() asking the user if they want to enter the information for another employee. A 1 can be entered to continue and a 2 could be entered to quit the program. (Integers are most precise and give better results for this). If the user chooses to continue, the same code already written is executed again, otherwise a 'goodbye' message of some sort is printed in a dialog box and the program ends.

Explanation / Answer

Here is the basic form of a class: class anyName { //attributes list of variables type X; //The list will be composed of lines like this. The "type" could be int or float etc. //behavior anyName( parameter list)//constructor method { some code } someMethodName( parameter list ) { some code } }//end class All classes should have this basic form though a class can have lack attributes or lack behaviors. anyName is the name of the class. The name is follow by a set of braces { }. Inside the braces the attributes are listed and the behavior is defined (i.e. the methods of the class are defined). Every class must have at least one constructor method. Note that the constructor method has the same name as the class and has no return type. (I will explain the constructor method later.) Here is a simple example of a class which follows the above format: class aClass { //attributes int something; //behavior aClass(int a)//constructor method { something=a; } someMethod( ) { System.out.println("This is a simple behavior of the class anyName. The attribute of this class is only the String"+something); } }//end class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote