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
Java Programming (MindTap Course List)
- At most, a class can contain ____________ method(S). 0 1 2 any number ofarrow_forwardAn 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_forwardTrue or False If a method belongs to a class, then you must write a method’s definition inside the class.arrow_forward
- Design 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_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_forward41. A Type of Method that does not return any value. Void Method Non-Void Method None of the Choices Parameterized Method Give an explanation for the answer. Thank youarrow_forward
- create an automobile class for a dealership. include fields fo an ID number, model, make, color, year and miles per gallon. include get and set methods for each field. do not allow the ID to be negative or more than 9999; if it is, set the ID to 0. do not allow the year to be earlier than 2005 or later than 2019, if it is, set year to 0. do not allow the miles per gallon to be less than 10 or more than 60; if it is, set the miles per gallon to 0. include a constructor that accepts arguments for each field value and uses the set methods to assign the values.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_forwardObjective: At the end of the activity, the students should be able to: Apply method overloading in a program. Procedure: 1. Develop a simple program for an individual savings account. Create two (2) classes named AmountDue (no class modifier) and RunAmountDue (public). 2. For the AmountDue class, create three (3) overloaded methods named computeAmountDue based on the following conditions: With a single parameter: It represents the price of one (1) item ordered. Add 12% tax and return the total due. With two (2) parameters: These represent the price of an item and the quantity ordered. Multiply the two (2) values, add 12% tax, and return the total due. With three (3) parameters: These represent the price of an item, the quantity ordered, and the discount amount. Multiply the quantity and price, deduct the discount amount, add 12% tax, and return the total due. 3. For the RunAmountDue class, import the Scanner class to be able to use the nextDouble() method. 4. Instantiate an AmountDue…arrow_forward
- 1. The Rockford Daily Clarion wants you to design a class named Issue. Fields include the issue number, the total number of advertisements sold in each issue, and total advertising revenue. Include get and set statements for each field. Include a static method that displays the newspaper's motto (Everything you need to know) Include three overloaded contractors as follows. o A default constructor that sets the issue number to 1 and the other fields to 0. o A constructor that allows you to pass values for all three fields. o A constructor that allows you to pass an issue number and a number of advertisements sold but sets the advertising revenue at 50$ per ad. 2. Create a class diagram and write the pseudocode that defines the class. 3. Design an application that declares three Issue objects using a different constructor version with each object. Display each Issue's values and then display the motto.arrow_forward2. Write a class named MonthDays. The class's constructor should accept two arguments: • An integer for the month (1 = January, 2= February, etc.). • An integer for the year The class should have a method named getNumberOfDays that returns the number of days in the specified month. The method should use the following criteria to identify leap years: 1. Determine whether the year is divisible by 100. If it is, then it is a leap year if and if only it is divisible by 400. For example, 2000 is a leap year but 2100 is not. 2. If the year is not divisible by 100, then it is a leap year if and if only it is divisible by 4. For example, 2008 is a leap year but 2009 is not. Demonstrate the class in a program that asks the user to enter the month (letting the user enter an integer in the range of 1 through 12) and the year. The program should then display the number of days in that month. Here is a sample run of the program: Enter a month (1-12): 2 [Enter] Enter a year: 2008 [Enter] 29 daysarrow_forwardGiven the code below, write a method call for the method (assume that each parameter is a String). Then determine that method’s output given the arguments that you pass. METHOD trickOrTreat (parameters: candy) BEGIN CREATE treat ← 26 SWITCH candy CASE “Tootsie Roll”: treat ++ CASE “Candy Corn”: treat += 2 BREAK CASE “Twizzlers”: treat -= 2 CASE “Dots”: treat -- CASE “Kit Kat”: treat *= 2 END SWITCH RETURN treat END METHOD Method Call Exact Outputarrow_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,