Java Programming (MindTap Course List)
Java Programming (MindTap Course List)
9th Edition
ISBN: 9781337397070
Author: Joyce Farrell
Publisher: Cengage Learning
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 3, Problem 10PE

Explanation of Solution

Program code:

JobPricing.java

//import the packages

import java.util.Scanner;

//define class JobPricing

class JobPricing

{

//define main() method

public static void main(String[] args)

{

//variable to store name of the job

String description;

//variable to store cost of materials

double materials;

//variable to store working hours

double hoursOnJob;

//variable to store traveling hours

double hoursOnTraveling;

//variable to store total cost for the job

double price;

//create an object of Scanner

Scanner input = new Scanner(System.in);

//prompt for job name

System.out.print("Enter job description >> ");

//reading job name

description = input.nextLine();

//prompt for cost of materials

System.out.print("Enter cost of materials >> ");

//reading cost of materials

materials = input.nextDouble();

//prompt for working hours

System.out.print("Enter hours on the job work >> ");

//reading working hours

hoursOnJob = input.nextDouble();

//prompt for traveling hours

System.out.print("Enter hours traveling >> ");

//reading traveling hours

hoursOnTraveling = input.nextDouble();

//calling method computePrice to calculate total cost

price = computePrice(materials, hoursOnJob, hoursOnTraveling);

//printing output

System.out...

Blurred answer
Students have asked these similar questions
3
Cargo Ships This question involves cargo ships that carry a specific number of cargo containers. Each ship has a maximum number of cargo containers that it can hold and a current number of cargo containers that it is holding. You can see more details in the Ship class that is provided for you. Part A For part A, you will be completing the nextToUnload() method. This takes no input and returns a Ship from the ships instance variable that has the highest percentage of its cargo hold filled (as measured by current hold / capacity). If two ships have the same percentage, then it should return the first ship with that percentage. If all of the ships in the ships array are empty (ie. no cargo), the method should return null. Part B For part B, you will complete the two unloadShip methods. The first method takes a Ship object and unloads all of the cargo from that ship. The second method takes a Ship and an int and unloads the specified number of containers from the ship. If the number of…
Create a class named Purchase. Each Purchase contains an invoice number (private int), amount of sale (private double), and amount of sales tax (private double). Include set methods for the invoice number and sale amount. Within the set() method for the sale amount, calculate the sales tax as 5% of the sale amount. Also include a display method that displays a purchase’s details (i.e invoice, sale amount and tax). Save the file as Purchase.java.   2. Create an application (with main ()) that declares a Purchase object (using class defined in previous question) and prompts the user if he/she wants to enter an invoice number (1-yes, 0 – no). If user enters 1 then the program will prompt for an invoice number, do not let the user proceed until a number between 1,000 and 8,000 has been entered. Next, the program prompts for a sale amount, do not proceed until the user has entered a nonnegative value. Using the values entered by the user create a Purchase object, display the object’s…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY