This activity will enable you to apply what you will learn during this course. Y
ID: 3606650 • Letter: T
Question
This activity will enable you to apply what you will learn during this course. You need to write a program for the instructions given below:
Caitlyn's Crafty Creations computes a retail price for each product as the cost of materials plus $14 multiplied by the number of hours of work required to create the product, plus $6 shipping and handling. Caitlyn’s Crafty Creations is having a semi-annual sale now, and everything is 25% off before shipping and handling:
Retail price = 0.75 * (cost of materials + (14 * hours of work)) + 6
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 before discount 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 retail price are displayed. Save the program as CraftPricing.java.
Explanation / Answer
Code:
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String name;
float retailPrice, shipping = 6, material_cost, hrs;
System.out.print("Enter the name of the product: ");
name = in.nextLine();
System.out.print("Enter the material cost : ");
material_cost = in.nextInt();
System.out.print("Enter the # of hours : ");
hrs = in.nextInt();
retailPrice = 0.75f*(material_cost+(14*hrs)) + shipping;
System.out.println("Price of '"+name+"' is "+retailPrice+" .");
}
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.