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

Caitlyn’s Crafty Creations computes a retail price for each product as the cost

ID: 3892192 • Letter: C

Question

Caitlyn’s Crafty Creations computes a retail price for each product as the cost of materials plus $12 multiplied by the number of hours of work required to create the product, plus $7 shipping and handling. Create a class that contains a main() method that prompts the user for the name of a product (for example, “woven purse”), the cost of materials, and the number of hours of work required. Pass the numeric data to a method that computes the retail price of the product and returns the computed value to the main() method where the product name and price are displayed. Save the program as CraftPricing.java. (Show the solution in Netbeans)

Explanation / Answer

import java.util.Scanner;

public class CraftPricing {

public static double computeRetailPrice(double costOfMaterial,double numberOfHours)

{

return costOfMaterial+numberOfHours*50;// assume 50 rupees per hour as it is not mentioned in the problem

}

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

System.out.println("Enter product Name");

String name=sc.next();

System.out.println("Enter the cost of material");

double costOfMaterial=sc.nextDouble();

System.out.println("Enter the number of hours required");

double numberOfHours=sc.nextDouble();

double result=computeRetailPrice(costOfMaterial, numberOfHours);

System.out.println("Retail price of the "+name+" is "+result);

}

}

output:

Enter product Name
cake
Enter the cost of material
323
Enter the number of hours required
5
Retail price of the srikanth is 573.0