class Duration: def_init (self, hours, minutes): self.hours hours self.minutes minutes def_add_ (self, other) : if not isinstance (other, Duration): return 'oops' total_hours = self.hours + other.hours total minutes = self.minutes + other.minutes if total_minutes >= 60: total_hours += 1 total minutes return Duration(total_hours, total_minutes) -= 60 one_way_time = Duration (4, 30) round_trip_time = one_way_time + one_way_time print (one_way_time + 53) print (round_trip_time.hours, round_trip_time.minutes)
Q: Use Java Programming Language Loan Account Class: Create class LoanAccount. Use a static variable…
A: The java code is given below.
Q: Exercise 6 - Loaded Coin Simulation Make a new class in the Lab2 project called LoadedCoinSimthat…
A: Note: Answering in python as no language is mentioned. Input : Head probability Number of…
Q: The parts of the code that need fixing are in the comments. Code is in Python.
A: class TicTacToePlayer: # Player for a game of Tic Tac Toe def __init__(self, symbol, name):…
Q: public class Person • public void eat() public class Student extends Person • public void study ()…
A: Solution: Given,
Q: Computer Engineering lab Apex(Salesforce) Write the Apex Test Class for the Below Apex Method and…
A: I have provided apex class in step2
Q: (Algebra: quadratic equations) Design a class named QuadraticEquation for a quadratic equation ax² +…
A: UML Diagram of QuadraticEquation:
Q: c++ Declare an Animal class that has the attributes of Name, Genus, and Weight. Declare four…
A: #include <iostream> #include <sstream> using namespace std; class Animal { string…
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: Exercise 6 - Loaded Coin Simulation Make a new class in the Lab2 project called LoadedCoinSimthat…
A: class LoadedCoinSim { private String sideUp; /** * Default constructor */…
Q: Data Structure Add three methods to the following class
A: The static method add() takes two polynomials p1 and p2 as parameter. It finds the max matching…
Q: Quiz Task: Create a class Student with following instance private variables and member functions:…
A: The answer is given below.
Q: amountofcontainers int amountofholds: int Gload (containes: int) load (type: String ) 1) Create a…
A: public class Ship { public int length; public double grosstonnage; public String flag; public…
Q: Create a class called Jug that represents a jug of liquid. The UML for this class is shown below:
A: The code of the class is below with comments in Java since there is no programming language is…
Q: Python programm In many card games, cards are either face up or face down. Add a new instance…
A: About card class • Each instance of the class Card represents a card in the deck of cards. • Every…
Q: Lecture Question In a package named "lecture11“, implement the following to expand the Flashlight/…
A: BoomBox.scala class BoomBox(override var battery: Battery) extends Electronic(){ this.accum =…
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: Hello, I am having trouble with this homework question Q1: Implement a class called Vehicle. a)…
A: Task : Write a C++ program for given question. C++ program :- #include <iostream>using…
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: Point out errors in the following codes and correct them publicclass CheckingAccount { // Create…
A: Please find the code below:: Highlighted line represent correction. package classes1;public class…
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is…
A: Inheritance is a mechanism in which one class acquires the property of other class. It is a…
Q: Write the DemonSlayer class so that the code gives the expected output. [You are not allowed to…
A: DemonSlayer is the class name and it has instance variables name, style, number_of_technique and…
Q: Design FullTimeEmployee class and PartTimeEmployee class which inherit Employee class so that the…
A: Here I have created two derived classes FullTimeEmployee and PartTimeEmployee. In the classes, I…
Q: class FractionType: def_init_(self, num, den): self.num = num self.den = den def_repr_(self): if…
A: Below is the modified Python program: - According to the question the modification done in the…
Q: # Coding - Simulate a robot Write a program that simulates the movements of a robot. The robot can…
A: Let G - advance L- turn left R- Turn right
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: Write the ComplexNumber class so that the following code generates the output below. class…
A: Algorithm: Start Create a class ComplexNumber with data variables real and comp Implement…
Q: Preliminaries • Write a Point class with two properties: 1, y. Write required constructor, get &…
A: EXPLANATION: - The Point class comprises two instance variables of type double. The parameterized…
Q: Write the Apex Test Class for the Below Apex Method and also show the code Coverage Output Here is…
A: Required: Apex(Salesforce) Write the Apex Test Class for the Below Apex Methodand also show the…
Q: Nutritional information (classes/constructors) PYTHON ONLY Complete the FoodItem class by adding a…
A: Given: Complete the FoodItem class by adding a constructor to initialize a food item. The…
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: Pet Whisperer Define a public class Whisperer that provides a single class method named…
A: Java Code for Above : //class in which method is defined class Whisperer{ //method…
Q: In Java OOP language Create the following class: Employee: Employee have following variables:…
A: Note: This code should be rewritten instead of copying to the compiler otherwise it will throw a…
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: Using OOP in java Create a class called Employee that includes three pieces of information as…
A: Algorithm: Create a category known as worker that has 3 items of knowledge as instance variables* -…
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: Question 4: Elections rite an Election class, used to record votes. The class has the following…
A: Please find the answer below :
Q: Please code in python Create a program with two classes – the person class and the student The…
A:
Q: //Todo write test cases for SimpleCalculator Class // No need to implement the actual Calculator…
A: Program :- import java.util.Scanner;class Main{ public static void main(String[] args) { char…
Q: 1. a .Create a class named Circle with fields named radius, area and diameter. Include a constructor…
A:
Q: 17. Coin Toss Simulator Write a class named Coin. The Coin class should have the following field: •…
A: Note: Below is the required program in java language. Programming Approach: Importing necessary…
Q: A shuttle van picks up passengers and drives them to a destination, where they leave the van. Keep a…
A: PROGRAM EXPLANATION: - The Van class comprise of three instance variables namely maxPassengers,…
Q: Write the ComplexNumber class so that the following code generates the output below. |class…
A: We need to write ComplexNumber class for the given scenario in Python.
Q: Sanchez Construction Loan Co. makes loans of up to R100,000 for construction projects. There are two…
A: the code for the above requirement is
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: Write a derived class of the NumberGuesser class named RandomNumberGuesser. The derived class…
A: Solution is given below :
Q: * This class describes a tweet. A tweet has a message in it, a unique ID, * a count of the number of…
A: EXPLANATION: - The Tweet class comprises instance variables of the following instance variables: -…
The first image is an example which shows the right answer. I want to know the output for the second one. Using python
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
- [java program] public class ScenarioAnalysis { // Instance variables privateVehicle[] vehicles; // all vehicless being analyzed privatedoublegasPrice; // price of one gallon of gas in dollars privatedoubleelectricityPrice; // price of 1 kWh in cents of a dollar, c$/kWh publicScenarioAnalysis ( doublegasPrice, doubleelectricityPrice ) { this.gasPrice = gasPrice; this.electricityPrice = electricityPrice; } /* * Updates the price of gas * Call computeCO2EmissionsAndCost() whenever there is an update on gas prices */ publicvoidsetGasPrice ( doublegasPrice ) { this.gasPrice = gasPrice; computeCO2EmissionsAndCost(); } /* * Returns the gas price */ publicdoublegetGasPrice () { returngasPrice; } /* * Updates the price of electricity * Call computeCO2EmissionsAndCost() whenever there is an update on electricity prices */ publicvoidsetElectricityPrice ( doubleelectricityPrice ) { this.electricityPrice = electricityPrice; } /* * Returns electricity price */ publicdoublegetElectricityPrice…**JAVA LANGUAGE** beginner level Suppose that a Scanner object contains a bunch of tokens all on a single line separated by spaces. For example: 100.5 30.4 pizza 56.8 1000.3 8.2 Also suppose that you have a particular item that you know the price of. Let’s use the following example: Kindle: 99.99 Write a static method: public static double priceIsRight(Scanner s, double price) that takes a Scanner and an item price as parameters and returns the bid that is closest to the item price but not greater than the item price. If all bids are greater than the price, return 0.0. If there are no bids (Scanner is empty) return 0.0. You can assume the Scanner is not null. In the above example. 56.8 should be returned, since it is the number that is closest to 99.99 but not over 99.99. Notice that there may be some invalid tokens in the Scanner's input. The above example has pizza as one of its tokens, which is clearly not a valid bid. Your method should throw these tokens away and not…Java Programming. Needs to be done with loops. Define a public static method called printPyramid(). This method should have publicstatic as its visibility modifiers. It should not return a value. It has a single integer parameter.When printPyramid() is called with an integer value, it should print a pyramid with a heightof that value.For example, if we call printPyramid() with an integer value of 5, then the following shouldbe displayed in the output console.** ** * ** * * ** * * * *You will have to use multiple for loops (consider nested for loops) to write this method.❏ In your main method, you should ask the user for the desired height of the pyramid. The usershould provide a value greater than 1. If the user does not provide a valid value, you should forcethe user to continue entering values until they enter a correct one.Then, call the printPyramid() method with the height given by the user.
- A rational number is the quotient of two integers - the numerator and denominator. The denominator cannot be zero. Two rational numbers can be added, subtracted, multiplied and divided. Write a java classRational for a rational number with the following specs: • A constructor that gets two integers (make sure the denominator is not 0).• The numerator and denominator should be private.• Getters: public int getNumerator() and public int getDenominator()• Setters: public void setNumerator(int n) and public void setDenominator(int d)• Public methods public Rational add(Rational r1), public Rational subtract(Rationalr1), public Rational multiply(Rational r1) and public Rational divide(Rational r1).• Printer function: public void print(). The number should be printed in the format n/d (numerator, forward-slash, denominator).Write a public int method named initialNumberOfSticks which takes two int parameters named max_sticks and min_sticks and returns a random integer value between max_sticks and min_sticks (inclusive). You will create a new instance of the Random class and call it r. Use the nextInt method of r to a get random value within a desired range and use it to compute the value that will be returned. Your method must be a syntactically correct Java method.GIVEN //BookMain.java//This is the client code of Book class public class BookMain{ public static void main(String[] arguments){// Small test of the Book classBook example = new Book("Angels and Demons");System.out.println("Title (should be Angels and Demons): " + example.getTitle());System.out.println("Rented? (should be false): " + example.isBorrowed());example.rented(); //marks the book as rentedSystem.out.println("Rented? (should be true): " + example.isBorrowed());example.returned();//marks the book as returnedSystem.out.println("Rented? (should be false): " + example.isBorrowed());} GIVEN //Book.java//complete the missing implementation to this class public class Book{private String title;private boolean borrowed; // Creates a new Book (constructor)public Book(String bookTitle){// Implement this method} // Marks the book as rentedpublic void rented() {// Implement this method} // Marks the book as not rentedpublic void returned() {// Implement this method} // Returns true if the…
- In Java Write a Fraction class that implements these methods:• add ─ This method receives a Fraction parameter and adds the parameter fraction to thecalling object fraction.• multiply ─ This method receives a Fraction parameter and multiplies the parameterfraction by the calling object fraction.• print ─ This method prints the fraction using fraction notation (1/4, 21/14, etc.)• printAsDouble ─ This method prints the fraction as a double (0.25, 1.5, etc.)• Separate accessor methods for each instance variable (numerator , denominator ) in theFraction classProvide a driver class (FractionDemo) that demonstrates this Fraction class. The driver class shouldcontain this main method : public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); Fraction c, d, x; // Fraction objects System.out.println("Enter numerator; then denominator."); c = new Fraction(stdIn.nextInt(), stdIn.nextInt()); c.print(); System.out.println("Enter numerator; then denominator."); d = new…In Java Write a Fraction class that implements these methods:• add ─ This method receives a Fraction parameter and adds the parameter fraction to thecalling object fraction.• multiply ─ This method receives a Fraction parameter and multiplies the parameterfraction by the calling object fraction.• print ─ This method prints the fraction using fraction notation (1/4, 21/14, etc.)• printAsDouble ─ This method prints the fraction as a double (0.25, 1.5, etc.)• Separate accessor methods for each instance variable (numerator , denominator ) in theFraction classProvide a driver class (FractionDemo) that demonstrates this Fraction class. The driver class shouldcontain this main method : public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); Fraction c, d, x; // Fraction objects System.out.println("Enter numerator; then denominator."); c = new Fraction(stdIn.nextInt(), stdIn.nextInt()); c.print(); System.out.println("Enter numerator; then denominator."); d = new…**JAVA LANGUAGE** beginner level import java. util.Arrays;import java.util.Scanner; Suppose that a Scanner object contains a bunch of tokens all on a single line separated by spaces. For example: 100.5 30.4 pizza 56.8 1000.3 8.2 Also suppose that you have a particular item that you know the price of. Let’s use the following example: Kindle: 99.99 Write a static method: public static double priceIsRight(Scanner s, double price) that takes a Scanner and an item price as parameters and returns the bid that is closest to the item price but not greater than the item price. If all bids are greater than the price, return 0.0. If there are no bids (Scanner is empty) return 0.0. You can assume the Scanner is not null. In the above example. 56.8 should be returned, since it is the number that is closest to 99.99 but not over 99.99. Notice that there may be some invalid tokens in the Scanner's input. The above example has pizza as one of its tokens, which is clearly not a valid bid. Your…
- When the given integer variable numberOfTools is: less than 14, output "Small tool box". between 14 inclusive and 39 inclusive, output "Mid-sized tool box". greater than 39, output "Need wall storage". End with a newline. Ex: If the input is 13, then the output is: (in java) Given Code: import java.util.Scanner; public class ToolDetails {public static void main(String[] args) {Scanner scnr = new Scanner(System.in);int numberOfTools; numberOfTools = scnr.nextInt();in Java LanguageWrite the method dateFashion().** You and your date are trying to get a table at* a restaurant. The parameter "you" is the stylishness* of your clothes, in the range 0..10, and "date" is* the stylishness of your date's clothes. The result* getting the table is encoded as an int value with 0 = no,* 1 = maybe, and 2 = yes.** If either of you is very stylish, (8 or more), then* the result is 2 (yes). With the exception that if* either of you has style of 2 or less, then the result* is 0 (no). Otherwise the result is 1 (maybe).** Some examples:* dateFashion(5, 10) returns 2* dateFashion(5, 2) returns 0* dateFashion(5, 5) returns 1* * @param you the style quotient for your clothes.* @param date the style quotient for your date's clothes.* @return chances of getting a table (0-no, 1-maybe, 2-yes).In Java I need to create a 2 new Student objects in a main method. The first will have name, major, 16 hours completed, and a 3.8 gpa. The 2nd will have name and major. they just started scool and have no hours completed or gpa. I need to change the 2nd students major. I need to update the students information based on hours they took and return a class level. public class Student{ private String name; private String major; private double gpa; private int hoursCompleted; /**Constructor * @param name * The student's name * @param major * The student's major */ public Student(String name, String major) { this.name = name; this.major = major; this.gpa = 0.0; hoursCompleted = 0; } /**Constructor * @param name * The student's name * @param major * The student's major * @param gpa * The student's cumulative gpa * @param hoursCompleted * Number of credit…