Create a Class with Data Fields and Methods in Java. Provide a Java coding solution for...

50.1K

Verified Solution

Question

Programming

Create a Class with Data Fields and Methods in Java. Provide aJava coding solution for the following:

1. Name the class SalonServices

2. Add private data fields: a. salonServiceDescription – Thisfield is a String type b. price - This field is a double type

3. Create two methods that will set the field values.

a. The first method setSalonServiceDescription() accepts aString parameter defined as service and assigns itto the salonServiceDescription. The method is not static

b. The second method setPrice() accepts a double parameterdefined as salonPrice and assigns it to the pricefield. The method is not static

4. Create two methods that retrieve or get the field value.

a. The first method is getSalonServiceDescription()

b. The other method is getPrice()

Create an application to run objects of the classSalonService

This will be an interactive program. Hint: java.util import

1. Name the class CreateSalonServices

2. The main() method will contain two variables from the userinput

a. String service

b. double price

3. Create an object for SalonServices and name it service1

4. Create an object for SalonServices and name it service2

5. Create an object that uses the built-in Java Scannerclass

6. Prompt the user to enter a service. You will store theresponse in the variable service

a. User will enter “massage” as the service during the executionof the program

7. Prompt the user to enter a price. You will store the responsein the variable price

a. User will enter 65.00 as the price during the execution ofthe program.

8. Write the statement that will send the user input for serviceto the setSalonServiceDescription() method for service1 object.

9. Write the statement that will send the user input for priceto the setPrice() method for service1 object.

10. Type ______.nextLine() The ____ will be replaced with thename of your scanner object sc , input, etc.

11. User prompted for second service information. Prompt theuser to enter a service. You will store the response in thevariable service

a. User will enter “facial” as the service during the executionof the program

12. Prompt the user to enter a price. You will store theresponse in the variable price.

a. User will enter 45.00 as the price during the execution ofthe program.

13. Write the statement that will send the user input forservice to the setSalonServiceDescription() method for service2object.

14. Write the statement that will send the user input for priceto the setPrice() method for service2 object

15. Display the details for service1 object on two lines:

a. Line 1 will contain the string literal: “Details for serviceone: “

b. Line 2 will contain the description and price information

16. Display the details for service2 object on two lines

a. Line 1 will contain the string literal: “Details for servicetwo: “

b. Line 2 will contain the description and price information

Compile and Execute the program.

Answer & Explanation Solved by verified expert
4.3 Ratings (764 Votes)
Code for your program is provided below Code is explainedthoroughly in code comments You can also refer to screenshot ofproperly indented code in IDE which i have attached in the lastOutput screenshot is also providedIf you need any further clarification please feel free to ask incomments I would really appreciate if you would let me know if theexplanation provided is upto your satisfactionCODEimport javautilScanner importing to use scanner for    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students