Given class Triangle (in files Triangle.h and Triangle.cpp), complete main() to read and set the base and height of triangle1 and of triangle2, determine which triangle's area is larger, and output that triangle's info, making use of Triangle's relevant member functions
Q: Given the following sample code: public class Example{ public float Twin(float a, float b) {.. }…
A: By Replacing overloading from overriding Explanation:- This is the correct option because in…
Q: Write a Python Simpsons class that implements a solution to the following slightly modified problem…
A: Python code is given below-
Q: It`s a python Class Implementation a) Implement a class PlayCard with three attributes, rank, suit,…
A: 1) Below is program to implement class PlayCard with three attributes, rank, suit, and players, amd…
Q: Given the class Pet below, write a client program to read data for five pets and display the…
A: The required Java code is: /**Class for basic pet data: name, age, and weight. */import…
Q: Write a class called Calculation to finish the following tasks of computation. 1. Given an integer…
A: In first program accept input from user so we use scanner class and create one user defined function…
Q: Derive a class BuyNItemsGetOneFree from DiscountPolicy, as described in Exercise 10. The class…
A: public class BuyNItemsGetOneFree extends DiscountPolicy{ private int numberOfItems;…
Q: onsider the following classes. What is output when then OwlApp program is executed? public class…
A: I run your code in my visual studio code editor for your output and remove public keyword from first…
Q: suppose there is a class Roster. Roster has one variable, roster, which is a list of tuples…
A: #Python Code:- class Roster:#Constructordef __init__(self):self.list1=[] # Method to add tuple in…
Q: use python Design the required class(es) so that the following expected output is generated. Do not…
A: Code : class TicketCounter(): def __init__(self): print('This is a general bus and train…
Q: Given two points in the plane (?,?) and (?,?), the slope of the line through them is the number ?…
A: Three points are said to be collinear if they lie on same line Here, we can find the slope of line…
Q: Write a method that accepts two integer parameters rows and cols. The output is a comma-separated…
A: public static void printGrid(int iRows, int iCols) { StringBuilder sb = new…
Q: class A {protected int x1,1,2; public: A(a, b,c):x1(a+2),y1(b-1),z(c+2) { for(i=0; i<5;i++)…
A: Explanation: Consider the given code. The values of k, m, and n are 4, 2, and 5 respectively. The…
Q: Implement the FindText() function, which has two strings as parameters. The first parameter is the…
A: #include <iostream>using namespace std;int FindText(const string &text,string…
Q: Write a python program to define a class (Clock) with the following members: > Attributes: hours:…
A: class clock: def __init__(self): self.hours = 0 self.minutes = 0…
Q: Given main(), complete the Car class (in file Car.java) with methods to set and ge t the purchase…
A: Required java code provide below:
Q: public abstract class DebugBoat { String boatType = new String(); int passengers; String…
A: public abstract class DebugBoat{ String boatType = new String(); int passengers; String power…
Q: Write in Java: Given main(), complete the Car class (in file Car.java) with methods to set and get…
A: public class Car { private int modelYear; // TODO: Declare purchasePrice field (int) private int…
Q: s = #of wicket * 1000 Century Bonus = #of century * 1000 addPlayerWithWickets and…
A: We need to define the England and Australia classes as per the given description.
Q: Given a class BClass with a constructor which accepts one argument (of epresenting certain identity…
A: We have to declare an array of type BClass BClass[] bArr;
Q: do I take a long number input, validate the input as a long number and then subsequently use it in a…
A: It is defined as a classification of data which tells the compiler or interpreter how the programmer…
Q: Write a Class called ALG_GRD_002a to do the following: 1. Given a range from a given whole number a…
A: code given below: Code: import java.util.Scanner; public class ALG_GRD_002a { public…
Q: Create a Python class that represents a standard playing card. Playing cards (in America, at least)…
A: Answer Code:- import random#random is uses to generate random cardsclass PlayingCard(): #Dict to…
Q: How can I write the repeating code just once in Python class subclass inheritance? For example…
A: We have to rewrite the given code using python class inheritance. Explanation: class Item() is a…
Q: Write a Python Program Implement the design of the Traveller class so that the following output…
A: 1) Below is program that implements the design of the Traveller class so that the following output…
Q: I want to add values for: AECar a1 = new AECar(); AECar a2 = new AECar(); Then, these values…
A: In this question we have to change JAV code to set the values of the class instances created. Let's…
Q: As a starting point, use the files fraction.h, fraction.cpp, testfraction.cpp below: //…
A: Coded using C++.
Q: please solve in python languange and use proper comments for better understanding . Thank you.
A: Given python code
Q: Write a client program for a MyTime class in Java which loops around getting strings from the user…
A: import java.util.Scanner; public class Main { int hours; int minutes; public Main () { }…
Q: Write the Director class with the required methods to give the following outputs as shown.
A: class Director: def __init__(self,*args): self.__director = '' self.__movie = {}…
Q: Write one word answers for the following: a.On compiling a file with the name “Demo.java” having a…
A: a) In Java, the java file name ought to be continuously a similar as a public category name. whereas…
Q: Implement the design of the Traveller class so that the following output is
A: Use instance variables to store all the places and total cost Use a static variable to keep track of…
Q: 5. Given the definitions of class x (Figure 3) and class Y (Figure 4) below, class x { 3 private int…
A: 4 3 6
Q: class A {protected int x1,y1,z; public: A(a, b,c):x1(a+2),yl(b-1),z(c+2) { for(i=0; i<5;j++) x1++;…
A: Answer: x1 -> 11, y1 -> 2 and z -> 8 See below step for explanation.
Q: sing PYTHON: The instances of this class have the following attributes: word_count, status, grade,…
A: I have answered below:
Q: ????????: Implement the design of the Pizza class so that the following output is produced: [Your…
A: As per our guidelines we are supposed to answer only one question. Kindly repost the remaining…
Q: 2. In the code below, classes A and B are in the same package. If the question marks are replaced by…
A: There are four access modifiers in Java Private: The access level of this modifier is only within…
Q: Q13: In the following code, the classes A and B are in different packages. If the question marks in…
A:
Q: to create a class named as ‘Employee’ with attributes i.e. ID, Name, Designation, Qualification,…
A: Write a python code to create a class named as ‘Employee’ with attributes i.e. ID, Name,…
Q: In Python without using super(): Given the base class Book, define a derived class called…
A: class Book: def __init__(self, title, author, publisher, publication_date): self.title =…
Q: Please answer the following question in Python code: (Composition) Write a Pizza class so that this…
A: Python Class: """ Class Pizza Definition """class Pizza: #Constructor that initializes size and…
Q: Given main(), complete the Car class (in file Car.java) with methods to set and get the purchase…
A: According to given problem,private variables need to be declared which only can be accessed within…
Q: What is the output of the following code? ( Assume each class is defined in a separate java file).…
A: According to the Question below the solution:
Q: 2. Using the BasketballTeam class above, write a complete demo driver class on the next page, which…
A: 1.create a main function to execute the class2.Creating two teams for the match3.Runs the loop 40…
Q: Write a program to print the sum of two complex numbers by creating a class named as…
A: Program code: import java.util.*;import java.util.Scanner; public class ComplexNumbers { int…
Q: omputer Science Use only NumPy to create the Normalize Class: Image Normalization is a technique…
A: SUMMARY: - hence we discussed all the points.
Q: Given main(), complete the car class (in file Car.java) with methods to set and get the purchase…
A: 1.Start 2.In Car.java file declare variables modelYear,purchasePrice,currentValue. 3.Define methods…
Q: A new deadly virus has infected large population of a planet. A brilliant scientist has discovered a…
A: So as per the question logic for code should be, vaccine count of midichlorains will be higher than…
Given class Triangle (in files Triangle.h and Triangle.cpp), complete main() to read and set the base and height of triangle1 and of triangle2, determine which triangle's area is larger, and output that triangle's info, making use of Triangle's relevant member functions.
Ex: If the input is:
3.0 4.0
4.0 5.0
where 3.0 is triangle1's base, 4.0 is triangle1's height, 4.0 is triangle2's base, and 5.0 is triangle2's height, the output is:
Triangle with larger area:
Base: 4.00
Height: 5.00
Area: 10.00
#include <iostream>
#include "Triangle.h"
using namespace std;
int main() {
Triangle triangle1;
Triangle triangle2;
// TODO: Read and set base and height for triangle1 (use SetBase() and SetHeight())
// TODO: Read and set base and height for triangle2 (use SetBase() and SetHeight())
// TODO: Determine larger triangle (use GetArea())
cout << "Triangle with larger area:" << endl;
// TODO: Output larger triangle's info (use PrintInfo())
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 3 images
- a) Implement a class Point with three attributes, x, y, and z.b) Implement an init method with an optional parameter type: 1) Set the default value of x, y, and z to 0.c) Implement a display method to print the values of x, y, and z as the example output below.d) Instantiate two objects of type Point, one with arguments,1, 2, and 3, and the other one without any arguments.e) Call display() to print x, y, and z. Example Output(x, y, z): (1, 2, 3)(x, y, z) : (0, 0, 0)Write a python program that takes input values as integer, checks the number is not less than 10 (otherwise take input again) and prints the previous 10 numbers i.e. 10, 9, 8, … Concatenate the integer and string values and print as a string Write a python code to create a class named as ‘Employee’ with attributes i.e. ID, Name, Designation, Qualification, Salary, Taken-Leaves, Allowed-Leaves and the functions applyLeave(). This function will take number of leaves as an input and check Allowed-Leaves to see whether the employee can take leaves or not. If he can take, deduct these leaves from Allowed-Leaves and add in Taken-Leaves. Otherwise show message ‘you cannot take leave’. Create another class ‘Intern’ and inherit ‘Employee’ as super class.Consider a class that could be used to play a game of hangman. The classhas the following attributes:- the secret word- the disguised word, in which each unknown letter is replaced with a question mark (?). For example, if the secret word isabracadabra and the letters a, b, and e have been guessed, the disguisedword would be ab?a?a?ab?a.- the number of guesses made- the number of incorrect guessesIt will have the following methods:- makeGuess(c) guesses that character c is in the word.- getDisguisedWord returns a string containing correctly guessed letters in their correct positions and unknown letters replaced with ?.- getSecretWord returns the secret word.- getGuessCount returns the number of guesses made.- isFound returns true if the hidden word has been discovered.a. write method heading for eeach methodb. write preconditions and postconditions for each methodc. write some java statements that test the classd. Implement the class.2. Write an application that plays the game of…
- Please implement in Java implement a keyed bag in which the items to be stored are strings (perhaps people’s names) and the keys are numbers (perhaps Social Security or other identification numbers). So, the in- sertion method has this specification: public void insert(String entry, int key);// Precondition: size( ) < CAPACITY, and the // bag does not yet contain any item// with the given key.// Postcondition: A new copy of entry has// been added to the bag, with the given key. When the programmer wants to remove or retrieve an item from a keyed bag, the key of the item must be specified rather than the item itself. The keyed bag should also have a boolean method that can be used to determine whether the bag has an item with a specified key. In a keyed bag, the pro- grammer using the class specifies a particular key when an item is inserted. Here’s an implementation idea: A keyed bag can have two private arrays, one that holds the string data and one that holds the corresponding…Implement a class Season that represents a season during a specified year. For purposes of thisproblem, assume that the seasons in each year are, in order, 'Winter', 'Spring', 'Summer', 'Autumn' .__init__, __repr__A Season object is created by calling the constructor and supplying two optional arguments:1. season, defaults to 'Winter'2. calendar year, an int , defaults to 2023For the __repr__ , see the usage below: The next and prev methods modify a Season object by changing it to the next season or previousseason in sequence, respectively. Note that the seasons can "roll over" or "roll back" and that this maychange the year by +/-1. 1. During each year, the seasons occur in this sequence: 'Winter', 'Spring', 'Summer', 'Autumn' 2. next - change to next season, if the current season is Autumn then year will increase by 1 3. prev - change to previous season, if Winter then year will decrease by 1 Implement the == operator ( __eq__ method) to compare two Season…In Python without using super(): Given the base class Book, define a derived class called Encyclopedia. Within the derived Encyclopedia class, define a print_info() method that overrides the Book class' print_info() method by printing not only the title, author, publisher, and publication date, but also the edition and number of volumes. Ex: If the input is: The Hobbit J. R. R. Tolkien George Allen & Unwin 21 September 1937 The Illustrated Encyclopedia of the Universe James W. Guthrie Watson-Guptill 2001 2nd 1 the output is: Book Information: Book Title: The Hobbit Author: J. R. R. Tolkien Publisher: George Allen & Unwin Publication Date: 21 September 1937 Book Information: Book Title: The Illustrated Encyclopedia of the Universe Author: James W. Guthrie Publisher: Watson-Guptill Publication Date: 2001 Edition: 2nd Number of Volumes: 1 Default code: class Book: def __init__(self, title, author, publisher, publication_date): self.title = title self.author =…
- For Python, write a program that reads and processes sets of data until a sentinel value of a negative number. The first number in a set is a room number, the second is the room's capacity, and the third is the size of the class scheduled to meet in that room. For each triplet set, print an output line showing the classroom number, capacity, number of seats filled, number of seats available, and a message ("FULL" or "OPEN") indicating whether the classroom is filled or not. After all classrooms have been processed, a summary is to be printed.suppose there is a class Roster. Roster has one variable, roster, which is a list of tuples containing the names of students and their numerical grades- for example, [('Richard',90), ('Belle',67), ('Christine',85), ('Francine',97)]. Roster has a function findValedictorian that returns the name of the student with the highest grade. Find the valedictorian of the Roster object englishClass and store it in the variable valedictorian. using pythonwrite a python code and finish it within 20 minutes please ????????:Design Australia class and England class which inherit from Cricket class so that the following code provides the expected output.Note:Wicket Bonus = #of wicket * 1000Century Bonus = #of century * 1000addPlayerWithWickets and addPlayerWithCenturies methods should work any number of parameters assuming that the parameter number will be an even number and greater than 1.class Cricket: total_player = 0 def __init__(self, name, number): self.name = name self.number = number def __str__(self): s = "Name: "+self.name+", World Cup: "+self.number return s# Write your codes here.# Do not change the following lines of code.s1 = Australia("Australia", "5")print("==============================")s1.addPlayerWithWickets("Starc", 4, "Hazlewood", 3)print("==============================")print(s1)print("==============================")s2 = England("England",…
- You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad. given is an API bool isBadVersion(version) which returns whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API. please write code in pythonPython: implement a class called point, the class contains two values of a type of integer (x and y). Define both as private. Add the following to the class: 1. Default initializer, used to create objects of type Point, by default x and y are set to 1. 2. Initializer with two parameters for x and y. 3. Set and get methods for x 4. Set and get methods for y 5. Method __str__, which returns a string that represent the Point(e.g., p = [4,5])Computer Science Use only NumPy to create the Normalize Class: Image Normalization is a technique used to touch up images that are too dark or too light for the human viewing experience. Implement a version that outputs images with full dynamic range (0–255 pixel intensity). In other words, for each color channel (r, g, b), rescale the range of pixel values for that channel to include both 0 and 255. After normalizing, there should be at least one pixel with a red value of 0, at least one pixel with a red value of 255, at least one pixel with a green value of 0, etc. To normalize a list of numbers nums to the range 0–n, set nums[i] = (nums[i]−min(nums))/(max(nums)−min(nums))∗n for all i. Be careful! When max(nums) == min(nums), you should not touch that list (why?).