In: Computer Science
Covered chapters: 1 ~ 3 In our first lab of the semester, we will create a Java CLI application that enables a store owner to calculate and out put the cost of a product. As the owner you determine the store name, product, cost, and hours it takes to make the product. Your output should display all pertinent information in a readable format. Lab Parameters Using Exercise 10 on page 165 of the textbook as a starting point, create an application that gets the following from user: Job Name Cost of Materials On the job time (in hours) Travel time to job site (in hours) Make sure to use the parameters and calculation formula noted in the exercise to compute the final costs. For instance, if the cost of material is $10, and the hours needed to repair is 2, and hours needed to reach the site is 2, then the final cost of repair would be the cost of material ($10) plus $35 multiplied by the number of hours of work (2) required for the repair, plus $12 multiplied by the travel time (2). The repair cost would come out to be 10 + 35 * 2 + 12*2 = $104 Once the application has all the input and processed it, output the results with all relevant information. Make sure you add following: Place a company name (you make up the company) formatted at the top with a design as you deem appropriate. Detailed invoice for the product. For example, include pertinent items used to calculate the cos Important Notes/Requirements Use NetBeans IDE for this lab Follow variable and file naming conventions Use appropriate data types Document every file that you create and/or change Create a class that contains a main() method that prompts user for all the inputs Pass the numeric data to a method that calculates the retail price for the job and returns the computed value to the main() method where the product name and price are displayed. Save the program using our usual naming convention: i.e., Lab1jsmith.java
Thanks for the question. Below is the code you will be needing Let me know if you have any doubts or if you need anything to change. Thank You !! =========================================================================== import java.util.Scanner; public class Lab1jsmith { public static void main(String[] args) { final double HOURLY_RATE = 35.00; final double TRAVEL_TIME_COST = 12; Scanner scanner = new Scanner(System.in); System.out.print("Enter job name: "); String jobName = scanner.nextLine(); System.out.print("Cost of material: $"); double costOfMaterial = scanner.nextDouble(); System.out.print("On job time (in hours): "); double hours = scanner.nextDouble(); System.out.print("Travel time to job site (in hours): "); double travelTime = scanner.nextDouble(); double totalCost = costOfMaterial+hours*HOURLY_RATE+travelTime*TRAVEL_TIME_COST; System.out.println("JOB NAME: "+jobName); System.out.println("COST OF MATERIAL: $"+String.format("%.2f",costOfMaterial)); System.out.println("JOB TIME (HOURS): "+String.format("%.2f",hours)); System.out.println("TRAVEL TIME (HOURS): "+String.format("%.2f",travelTime)); System.out.println("TOTAL COST: $"+String.format("%.2f",totalCost)); } }