Answer:
The Java code is given below with appropriate comments and output
Step-by-step explanation:
CaitlynsCraftyCreations.java
package org.students;
import java.util.Scanner;
public class CaitlynsCraftyCreations {
public static void main(String[] args) {
//Scanner object is used to read the values entered by the user.
Scanner sc = new Scanner(System.in);
//Getting Product Name From the User
System.out.print("The name of a product :");
String nameOfProduct=sc.nextLine();
//Getting the cost of the material entered by the user.
System.out.print("The cost of materials : $");
double costOfMaterials=sc.nextDouble();
//Getting the Hours of work entered by the user..
System.out.print("Enter the hours of work :");
double hoursOfWork =sc.nextDouble();
/*
* Calling the method
* by passing the costOfMeterials and hoursOfWork as parameters.
* Get the Returned value and stored into a varible of type double.
*/
double retailPrice= findRetailPrice(costOfMaterials,hoursOfWork);
//Displaying the Product name and Its retail price after discount.
System.out.println("The Name of the Product is :"+nameOfProduct);
System.out.println("The Retail Price after Discount is : $"+retailPrice);
}
/*
* This method will find the retail price of the Product after discount.
* @Param costOfMaterials,hoursOfWork
* Return discounted retail price of double type.
*/
private static double findRetailPrice(double costOfMaterials,double hoursOfWork)
{
return 0.75 * (costOfMaterials + (14 * hoursOfWork)) + 6 ;
}
}
___________________________________________________________________________
Output:
The name of a product :Woven Purse
The cost of materials : $500
Enter the hours of work :25
The Name of the Product is :Woven Purse
The Retail Price after Discount is : $643.5
__________________________________________________________________________