Concept explainers
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...
Trending nowThis is a popular solution!
Chapter 3 Solutions
EBK JAVA PROGRAMMING
- At most, a class can contain ____________ method(S). 0 1 2 any number ofarrow_forwardInstructions This assignment must follow directions exactly. Create a class Lab02 with a main method, and put all of the following code into the main method: Print the prompt shown below and ask the user for the number of exemptions. The number of exemptions is an integer. Print the prompt shown below and ask the user for their gross salary. The gross salary represents dollars, which can be entered with or without decimal points. Print the prompt shown below and ask the user for their interest income. The interest income represents dollars, which can be entered with or without decimal points. Print the prompt shown below and ask the user for their capital gains income. The capital gains represents dollars, which can be entered with or without decimal points. Print the prompt shown below and ask the user for the amount of charitable contributions. The charitable contributions represents dollars, which can be entered with or without decimal points. Perform the calculation of…arrow_forwardThe class provided represents a item. Information about a item includes the name of the item and the count of items in inventory (inventory count). When ordering items they are ordered in descending order by the inventory count. If items have the same inventory count then they are ordered in ascending alphabetical order by their name (a-z). Here is an example set of items: 7 Camera 5 Bicycle 5 Lego 5 Robot 3 Tricycle The Item class is missing a required method. Write the missing method in the space provided below. public class Item implements Comparable { private String name; private int count; public Item (String nameIn, int count In) { name name In; count countIn; }arrow_forward
- An artist's discography includes several albums. Each album includes several songs. We want to model the Discography, Album and Song classes as follows • a discography has a single artist attribute and a total_time method that returns the total minutes corresponding to the artist's entire discography • an album has a single name attribute and a total_time method that returns the total minutes for the songs on the album a song has two attributes: title and duration and a duration method that returns the duration in minutes of the song • we want to take advantage of the composite pattern so that the duration method delivers the total number of minutes of a song, album or the entire discography of the artist depending on the object in question a) Draw a UML class diagram showing the solution b) Write the Ruby code that implements itarrow_forwardDesign a class named Rectangle that holds length, width and color. Create the class diagram and write the pseudocode that defines the class. The details are below: Each field (length, width & color) should only be accessible within the class (hint: use correct access modifier). Include methods to set and get the values for each field. Include an additional method to calculate and return the area (hint: this is calculated by multiplying width and height). Include two constructors One default constructor that sets the length and width to default values of 10 and the color to blue Second constructor that takes two arguments to set the length and width fields and default the color to red Design an application that declares two Rectangle objects and sets and displays their values. Design an application that declares a Rectangle object using the second constructor and then displays the object's values Design an application that declares an array of 5 Rectangle objects. Prompt the user…arrow_forwardTrue or False If a method belongs to a class, then you must write a method’s definition inside the class.arrow_forward
- Please help using Javaarrow_forwardkindly answer asap!!arrow_forward0o.Absolutely answer please Write a program that calculates the average of courses, overall grade, and letter grade. Suppose that your students take four courses - English, Mathematics, Science, and History. You should design a class that accepts all four course's numeric scores, calculates average and overall grade, and decides letter grade based on the overall grade. Your class should have a constructor, get and set methods of each course, a method that calculates the average of four courses, a method that calculates overall grade, and a method that decides letter grade. The overall grades are calculated as the following rate: Average of All four courses: 50% Quiz: 40% Attendance: 10% The letter grade is based on the following: 90.0 to 100.0 - A 80.0 to 89.9 - B 70.0 to 79.9 - C 65.0 to 69.9 - D less than 65 - F Your program demonstrates the class by asking the user to input four-course numeric scores, creating an object, and then reporting each course's score, average, overall…arrow_forward
- • must require .extra instance variable • calculated volume again inside method getSnowVolume () • calculated snow volume again inside method getSnowCost()arrow_forwardQuestion 5: In this question, you will complete the FootballPlayer class, which is used to compute some features of a Football Player. The class should be constructed with the name and age, as well as shooting, passing, tackling and saving skill points of a player. The constructor method as well as the defenderScore method is provided below. You should implement the remaining methods. The definitons of the methods are presented below as comments. An example execution and the corresponding outputs are provided below: >>> burkay FootballPlayer ("Burkay", 42, 15, 30, 10, 15) %3D >>> cemil = FootballPlayer("Cemil", 30, 70, 30, 45, 20) >>> ronaldo = FootballPlayer ("Ronaldo", 36, 85, 95, 35, 5) >>> print(burkay) (Burkay, 42,13640000) >>> print(cemil) (Cemil, 30,144270000) >>> print(ronaldo) (Ronaldo, 36,322445000) >>> print(burkay > cemil) False >>> print(ronaldo > burkay) Truearrow_forwardA(n)_ is a special kind of class that never uses any non-virtual methods. Please provide your comment in the spaces provided.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,