def __init__(self, hours, minutes): self.hours = hours self.minutes = minutes def __add__(self, other): total_hours = self.hours + other.hours total_minutes = self.minutes + other.minutes if total_minutes >= 60: total_hours += 1 total_minutes -= 60 return Duration(total_hours, total_minutes) first_trip = Duration(3, 36) second_trip = Duration(0, 47) first_time = first_trip + second_trip second_time = second_trip + second_trip print(first_time.hours, first_time.minutes) what is the output
Q: Write a Circle class that has the following fields: radius: a double PI:a final double initialized…
A: the below given Java will obey the following rubrics: Importing necessary header files.…
Q: NewspaperSubscriber class- create an abstract class named NewspaperSubscriber with attributes to…
A: In java, whenever there is a requirement for a class that only specifies what all attributes and…
Q: Please Write a class named Student that has the following variables: name - a string that hold…
A: The program is implemented in C++ with object oriented approach. The question asks me to make 3…
Q: (Algebra: quadratic equations) Design a class named QuadraticEquation for a quadratic equation ax² +…
A: UML Diagram of QuadraticEquation:
Q: rite a Die class to model a die (like you play Yahtzee or Monopoly with). Fields faces The number…
A: It is defined as a powerful general-purpose programming language. It is used in web development,…
Q: e ISBN Author Edition
A: EXPLANATION The main method is inside Library class so it should be public. ArrayList can be used…
Q: Preliminaries • Write a Point class with two properties: r, y. Write required constructor, get &…
A: NOTE: As per the policy we can answer only one question at a time, kindly repost the other part to…
Q: JAVA PROGRAMMING: Lesson – Overloading Constructors 1. a .Create a class named Circle with fields…
A: As per our guidelines, we are supposed to answer only one question. Kindly repost the remaining…
Q: A silos is a cylindrical like container used to hold grains in farms. Create class silos where each…
A: The given problem is to be solved in Java programming language where two classes are to be created.…
Q: Classes and Objects Create a class called Car. The Car class has the following fields: ● color ●…
A: Required: Classes and ObjectsCreate a class called Car. TheCar class has the following fields:●…
Q: Assignment Tasks In a Java program • Create a class named "Car" The class must have the following…
A: Code: import java.util.Scanner; class Car{ String carID,Brand; boolean isItElectricCar; double…
Q: ava program Car Maintenance: This assignment will assess your understanding of void and value…
A: Program: import java.util.Scanner; public class Main { //method carMaintenance //takes…
Q: Create a class that represents an employee. This class will have three constructors to initialize…
A: Given Create a class that represents an employee. This class will have three constructors to…
Q: Q2. Write a class Bank that has the following data members –Account Holder name (ah_name[])…
A: Given: Q2. Write a class Bank that has the following data members –Account Holder name (ah_name[])…
Q: Q No#1 (Area Class) Write a program to print the area of a rectangle by creating a class named…
A: Declare two variables in the main() method. Read the values from the user using the Scanner class…
Q: Write class as follows: The class is named Painting, and it inherits from the Art class. It has a…
A: Create Art class with arguments name,artist,year so that Painting class can inherit Art class should…
Q: Directions The total cost of a group of items at a grocery store is based on the sum of the…
A: Given I had implemented the abstract class and abstract method. make sure you place the both files…
Q: You are required to implement a shopping cart module for an online shopping mall. From the available…
A: The code for the above-given question is given below:
Q: In Python Programming Language : Design an Employee class that has fields for the following pieces…
A: ANSWER:-
Q: pplication. se OOP to create a Book Messenger Application that has the following functions: - Add a…
A: Hey there, I am writing the required solution of the questin mentioned above. Please do find the…
Q: It is required to develop an application in Java to maintain information about students registered…
A: Program (A) // Course.java : Java code to create Course class public class Course { // attributes…
Q: Create a class named Rock that acts as a superclass for rock samples collected and catalogued by a…
A: In your code you had `1. -------------- these lines which have to be deleted or commented. 2.…
Q: Sanchez Construction Loan Co. makes loans of up to R100,000 for construction projects. There are two…
A: Answer : PROGRAM/CODE : - Loan.java import java.text.DecimalFormat; public abstract class Loan…
Q: Preliminaries • Write a Point class with two properties: 1, y. Write required constructor, get &…
A: Please give positive ratings for my efforts. Thanks. PROGRAM class Point { int x,y; public…
Q: using jave: Create the a Person class with the following: Class Variables: String firstname…
A: Program Approach:-- Defining the class and the class name is Person. Declaring the variable and the…
Q: You are required to design an Movie class which has following attributes String name;…
A: import java.io.*;class Movie{ // attributes private String name; private String Director;…
Q: Q No#1 (Area Class) Write a program to print the area of a rectangle by creating a class named…
A: A class is a user-defined data type that combines data members and methods for manipulating that…
Q: Given main(), define the Product class that will manage product inventory. Product class has three…
A: Introduction of Java Java is an object-oriented, general-purpose programming language built on…
Q: in java Write a class Travel having two private data members (distanceCovered , Time) The class has…
A: A class is a user-defined data type that combines data members and methods for manipulating that…
Q: tance data: Variable mpg for fuel efficiency (miles per gallon = mpg) Variable gas to save how many…
A: We need to implement the Vehicle class and Main.java as per the given requirements.
Q: Sanchez Construction Loan Co. makes loans of up to R100,000 for construction projects. There are two…
A: package loan; // Defines an interface LoanConstantspublic interface LoanConstants{ // Defines the…
Q: Text Class The Text class inherits from Drawable and it will be used to display the player's score.…
A: It is defined as an interpreted, object-oriented, high-level programming language with dynamic…
Q: Quadratic equations The form of a quadratic equation is ax2 + bx + c = 0. Write a program that…
A: package solveequation;public class Complex{ //two double variable to represent real and imaginary…
Q: Write a class Die representing a single die. Your class should include: An instance variable for…
A: Solution:-- 1)As given in the question it is required to provide the solution for the program…
Q: A small airline has just purchased a computer for its new automated reservations system. You've been…
A: the code is written below in c++ : #include <iostream> using namespace std; int main() {…
Q: 1. Employee Class Write a class named Employee that has the following fields: • name. The name field…
A: import java.util.*;import java.lang.*;import java.io.*; class Employee{ //fields String name; int…
Q: An online retailer sells six products whose prices are as follows: key description price 1…
A: Objective: We need to create a list of sales items with 6 items. Then based on sales we are creating…
Q: Question 4: Elections rite an Election class, used to record votes. The class has the following…
A: Please find the answer below :
Q: 1. Complete the partial declaration of Class Car public class Car { declare three private instamce…
A: NOTE: Since programming, langauge is not mentioned. Therefore the answering question in Java…
Q: 1. a .Create a class named Circle with fields named radius, area and diameter. Include a constructor…
A:
Q: Problem: Employee and ProductionWorker Classes Write a python class named ProductionWorker that is…
A: The program is given below written in python- #class employeeclass Employee : #constructor for the…
Q: Design and implementation of Java (Draw UML) classes 1. Design a class named Bill to represent a…
A:
Q: Invoicing.java Create a class named Invoicing (no instance private data fields) that includes three…
A: Here is the detailed explanation of the program
Q: A. Build a class named car. This class is defined as follows: It has the fields: Car ID, Car model,…
A: Solution: Given,
Q: Write a class Runner having three private data members (distance, minutes, seconds)
A: Since, language is not specified, assuming required solution in java programming language, below is…
Q: IN JAVA PLEASE Child Class: Vegetable Write a child class called Vegetable. A vegetable is described…
A: We need to write a Java class for the given scenario.
Q: Remaining Time: 35 minutes, 18 seconds, ¥ Question Completion Status: A class named Account is…
A: The problem is based on the basics of OOPS in programming languages. NOTE: The answer given below is…
Q: (The MyInteger class) Design a class named My Integer. The class contains: 1 An int data field named…
A: **** Java Program **** MyInteger.java :
class Duration:
def __init__(self, hours, minutes):
self.hours = hours
self.minutes = minutes
def __add__(self, other):
total_hours = self.hours + other.hours
total_minutes = self.minutes + other.minutes
if total_minutes >= 60:
total_hours += 1
total_minutes -= 60
return Duration(total_hours, total_minutes)
first_trip = Duration(3, 36)
second_trip = Duration(0, 47)
first_time = first_trip + second_trip
second_time = second_trip + second_trip
print(first_time.hours, first_time.minutes)
what is the output
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- Circle ClassWrite a Circle class that has the following fields:• radius: a double• PI: a final double initialized with the value 3.14159The class should have the following methods:• Constructor. Accepts the radius of the circle as an argument.• Constructor. A no-arg constructor that sets the radius field to 0.0.• setRadius. A mutator method for the radius field.• getRadius. An accessor method for the radius field.• area. Returns the area of the circle, which is calculated asarea = PI * radius * radius• diameter. Returns the diameter of the circle, which is calculated asdiameter = radius * 2• circumference. Returns the circumference of the circle, which is calculated ascircumference = 2 * PI * radiusWrite a program that demonstrates the Circle class by asking the user for the circle’s radius, creating a Circle object, and then reporting the circle’s area, diameter, and circumference.Java Instance data:Variable mpg for fuel efficiency (miles per gallon = mpg)Variable gas to save how many gallons of gas left in the tank Constructors:Default constructor with no parameter. Use 0 as initial values.Overloaded constructor with two parameters Methods:getMPG() & setMPG()(getGas() & setGas()toString() methoddrive() to simulate that the car is driven for certain miles. For example, v1.drive(100) means vehicle v1 is driven 100 miles. You need to calculate the gas cost and update the gas tank: gas = gas - miles/mpg. You also need to check if there is enough gas left since gas should not be negative. You need to figure out the formal parameters for the above methods. In the testing class, prompt the user for information to create two objects of the Vehicle class. Let each vehicle drive 200 miles. Print out the left gas for each vehicle. Ex: Vehicle 1 Enter the mpg: 40 Enter the gas left: 10.5 Vehicle 2 Enter the mpg: 35 Enter the gas left: 2.1 Vehicle 1…Class Student This class represents a single student __init__(self, id: int, fist_name: str, last_name: str, town:str): """ This creates a student object with the specified ID first and last name and home town. This constructor should also create data structure for holding the students grades for all of there assignments. Additionally it should create a variable that holds the student's energy level which will be a number between 0 and 1. The student start out with 1 (100%) energy. :param id: The student's identifiaction number :param fist_name: The student's first name :param last_name: The student's last name :param town: The student's home town """ get_id(self)->int: """ Returns the ID of the student as specified in the constructor. :return: The student's ID """ get_first_name(self) -> str: """ Returns the first name of the student. :return: The student's first name """ set_first_name(self, name:str):…
- C# (Odd or Even) Write an app that reads an integer, then determines and displays whether it’s odd or even. (Hints: use the remainder operator) (Multiples) Write an app that reads two integers, determines whether the first is a multiple of the second, and displays the result. (Hints: use the remainder operator). Create a class called Date that includes three pieces of information as auto-implemented properties: a month (type int), a day (type int), and a year (type int). Your class should have a constructor that initializes the three fields. Provide a method DisplayDate() that displays the three fields (separated by '/'). Write a test app named DateDemo that demonstrates class Date’s capabilities.Class Student __init__(self, id: int, fist_name: str, last_name: str, town:str): """ This creates a student object with the specified ID first and last name and home town. This constructor should also create data structure for holding the students grades for all of there assignments. Additionally it should create a variable that holds the student's energy level which will be a number between 0 and 1. :param id: The student's identifiaction number :param fist_name: The student's first name :param last_name: The student's last name :param town: The student's home town """ get_id(self)->int: """ Returns the ID of the student as specified in the constructor. :return: The student's ID """ get_first_name(self) -> str: """ Returns the first name of the student. :return: The student's first name """ set_first_name(self, name:str): """ Changes the student first name to the specified value of the name parameter. :param name: The value that the first name of the student will equal. """…7)Circle Class Write a Circle class that has the following fields: radius: a double PI:a final double initialized with the value 3.14159 The class should have the following methods: Constructor. Accepts the radius of the circles as an argument. Constructor. A no-arg constructor that sets the radius field to 0.0. setRadius. A mutator method for the radius field. getRadius.An accessor method for the radius field. area. Returns the area of the circle, which is calculated as area. Returns the area of the circles, which is calculated as area= PI * radius * radius diameter. Returns the diameter of the cirlce, which is calculated as diameter = radius * 2 circumference. Returns the circumference of the circle, which is calculated as circumference = 2 * PI * radius Write a program that demonstrates the Circle class by asking the user for the circles's radius, creating a Circle object, and then reporting the cirlce's area, diameter, and circumference.
- Sanchez Construction Loan Co. makes loans of up to R100,000 for construction projects. There aretwo categories of Loans—those to businesses and those to individual applicants. Write anapplication that tracks all new construction loans. The application also must calculate the totalamount owed at the due date (original loan amount + loan fee). The application should includethe following classes:•• Loan—A public abstract class that implements the LoanConstants interface. A Loan includes aloan number, customer last name, amount of loan, interest rate, and term. The constructor requiresdata for each of the fields except interest rate. Do not allow loan amounts greater than R100,000.Force any loan term that is not one of the three defined in the LoanConstants class to a short-term,1-year loan. Create a toString() method that displays all the loan data.•• LoanConstants—A public interface class. LoanConstants includes constant values for short term(1 year), medium-term (3 years), and long-term…inventory.py templete #========The beginning of the class ========== classShoe: def__init__(self,country,code,product,cost,quantity): pass ''' In this function, you must initialise the following attributes: ● country, ● code, ● product, ● cost, and ● quantity. ''' defget_cost(self): pass ''' Add the code to return the cost of the shoe in this method. '''defget_quantity(self):pass''' Add the code to return the quantity of the shoes. ''' def__str__(self): pass ''' Add a code to returns a string representation of a class. ''' #=============Shoe list==========='''The list will be used to store a list of objects of shoes.''' shoe_list=[] #==========Functions outside the class============== defread_shoes_data(): pass ''' This function will open the file inventory.txt and read the data from this file, then create a shoes object with this data and append this object into the shoes list. One line in this file represents data to create one object of shoes. You must use the try-except in this…Create an automobile class that will be used by a dealership as a vehicle inventory program. The following attributes should be present in your automobile class: private string make private string model private string color private int year private int mileage Your program should have appropriate methods such as: default constructor parameterized constructor add a new vehicle method list vehicle information (return string array) remove a vehicle method update vehicle attributes method. All methods should include try..catch constructs. Except as noted all methods should return a success or failure message (failure message defined in "catch"). Create an additional class to call your automobile class (e.g., Main or AutomobileInventory). Include a try..catch construct and print it to the console. Call automobile class with parameterized constructor (e.g., "make, model, color, year, mileage"). Then call the method to list the values. Loop through the array and print to the screen.…
- Invoicing.java Create a class named Invoicing (no instance private data fields) that includes three overloaded computeInvoice() methods and one displayDetails() method for a book store: see pages 140 and 183 for examples... * Define a constant for the 8% tax rate at the top of the Invoicing class. Set the TAXRATE double constant to 0.08. Do not set to a whole number. When computeInvoice() receives a single parameter, it represents the price of one book ordered. Calculate the tax using the TAXRATE constant. Add the tax to the price and save the total due in a variable. Call the displayDetails() method, defined in the computeInvoice() class, being sure to pass the total due as an argument to the display method. * When computeInvoice() receives two parameters, they represent the price of a book and the quantity ordered. Multiply the price times quantity, calculate the tax using the TAXRATE constant, and calculate the total due. Call the displayDetails() method, defined in the…Write a class called Alien. The Alien class must have one field of type String called name, one of type String called planet and one field of type boolean called humanoid. Write one constructor that takes three parameters to initialise all of these fields. The parameters must be passed in the order name, planet and humanoid status. IntelliJ hint (this won't be in the real test): put your cursor after the last field; right-click, choose Generate, choose Constructor, select the fields that are set via parameters and click Ok. Check that the constructor is correct. Write a getter method for each field. IntelliJ hint (this won't be in the real test): put your cursor after the closing curly bracket of the constructor; right click, choose Generate, choose Getter, select all of the fields; click Ok. Check that the you have three getters. Do not write setters methods. Write a method called getDetails that will return the values of the fields in one of the following two formats. For example,…JAVA PROGRAMMING: Lesson – Overloading Constructors Create a class named House that includes data fields for the number of occupants and the annual income as well as methods named setOccupants(), setIncome(), getOccupants() and getIncome() that set and return those values respectively. Additionally, create a constructor that requires no arguments and automatically sets the occupants field to 1 and income field to 0. Create an additional overloaded constructor . This constructor receives an integer argument and assigns the value to the occupants field. Create a third overloaded constructor this time, the constructor receives 2 arguments, the values of which are assigned to the occupants and income fields respectively. Create another class named I_house that instantiates the House class and see if the constructors work correctly.