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

You Do It Declaring and Using Objects In the last \"You Do It\" section, you cre

ID: 3890254 • Letter: Y

Question

You Do It Declaring and Using Objects In the last "You Do It" section, you created a class named SpaService. Now you create an application that instantiates and uses SpaService objects. 1. Open a new file in your text editor, and type the import statement needed for an interactive program that accepts user keyboard input: import java.util.Scanner; Create the shell for a class named CreateSpaServices: public class CreateSpaServices 2. 3. Between the curly braces of the CreateSpaServices class, create the shell for a mainO method for the application: public static void main(String[] args) (continues)

Explanation / Answer

import java.util.Scanner;

public class CreateSpaServices

{

    public static void main(String[] args)

    {

        String service;

        double price;

       

        SpaService firstService = new SpaService();

        SpaService secondService = new SpaService();

       

        Scanner keyboard = new Scanner(System.in);

       

        System.out.print("Enter service >> ");

        service = keyboard.nextLine();

        System.out.print("Enter price >> ");

        price = keyboard.nextDouble();

        

        firstService.setServiceDescription(service);

        firstService.setPrice(price);

       

        keyboard.nextLine();

        System.out.print("Enter service >> ");

        service = keyboard.nextLine();

        System.out.print("Enter price >> ");

        price = keyboard.nextDouble();

        secondService.setServiceDescription(service);

        secondService.setPrice(price);

       

        System.out.println("First service details:");

        System.out.println(firstService.getServiceDescription() + " $" + firstService.getPrice());

       

        System.out.println("Second service details:");

        System.out.println(secondService.getServiceDescription() + " $" + secondService.getPrice());

    }

}