Overload the following arithmetic operators (+, -) for Distance class. Two sample outputs are given below: Distance d1: 3'-9" Distance d2: 3'-6" d1 + d2 = 7'-3" d1 - d2 = 0'-3" Distance d1: 3'-9" Distance d2: 4'-6" d1 + d2 = 8'-3" d1 - d2 = Error: negative distance by using c++
Q: Q1: Write a complete JAVA program that carries out the following tasks: Declare a class Video with…
A: Program Approach: Create class and create variables and methods in it. Use static keyword to…
Q: Write the box class so that the code gives the expected output. Output: |Вох 1 Creating a Box!…
A:
Q: Given the following classes, write the code for the Player and the Manager class so that the…
A: Solution: Given,
Q: I need help figuring out what is wrong with my code. class employee: def __init__(self, name,…
A: Above is the code given in Python language. We need to update the code and remove the errors from…
Q: Design the Team and Player class so that the following expected output is generated. Your answer…
A: 1) Below is program that design Team and Player class so that the following expected output is…
Q: might not be reasonable to expect users to type long entries such as “oil change” accurately.…
A: import java.util.Scanner; public class CarCareChoice2 { public static void main(String[] args) {…
Q: Design the Library and Book class so that the expected output is generated. #Write your code here…
A: Algorithm: Start Create a class Library with a class variable books which is a list and instance…
Q: using Java Write a grading program for a class with the following grading policies: 1. There are…
A: #include<iostream>using namespace std;struct record{double quiz1;double quiz2;double midyear,…
Q: Implement the design of the EPL_Team class so that the following output is produced: Driver Code…
A: class EPL_Team:def __init__(self,name,*args):self.name=nameif…
Q: Test the following Java classes using JUnit providing 4 test cases that pass and 4 that fail, after…
A: The program is shown below. Sample Response: import java.util.*;//class defintitionpublic class…
Q: Question: 2 Implement the design of the Laptop and Store classes so that the following code…
A: Algorithm: Start Create a class Store with laptops a list as static variable and name as instance…
Q: Assume that you are applying “testing” and “inspection”, the two defect finding methods in the…
A: The answer is as follows.
Q: Write a class called Marks with a required constructor. Then perform the addition using operator…
A: Your python program is given below as you required with an output.
Q: Dry run the below programs and explain the reasons of output. If there is any error then correct…
A: EXPLANATION class access{ public int x; static int y; // all static variables are common for all…
Q: Use Java. Given main() and the Instrument class, define a derived class, StringInstrument, for…
A: StringInstrument.java public class StringInstrument extends Instrument { private int…
Q: 1.1.2: Output variable value. АCTIVITY 283902.1889792.qx3zay7 Jump to level 1 Write a statement that…
A: import java.util.Scanner;public class InputExample{ public static void main(String args[]) {…
Q: Design the required class(es) to get the output shown from the driver code. Your code should work…
A: Code : # Student classclass Student: # constructor with dept, courses and gpa as default values…
Q: Write the CSEStudent class with the required methods to give the following outputs as shown.Hints:…
A: GPA has to printed upto 2 decimal and this can be done by specifying precision which printing
Q: What is the probability that in a classroom of x people, at least 2 will be born on the same day of…
A: Solution: Probability of having at least two people's birthdays on the same day through simulating…
Q: Implement the design of the Travel class in python so that the following output is produced: You…
A: Algorithm: Start Implement class Travel with a static variable count and class variables…
Q: What is the probability that in a classroom of x people, at least 2 will be born on the same day of…
A: Given data, What is the probability that in a classroom of x people, at least 2 will be born on the…
Q: Implement the design of the Account class so that the following output is produced: Driver Code…
A: class Account(): def __init__(self, name='Default Account', bal=0.0): self.name = name…
Q: Question 9 Write the box class so that the code gives the expected output. #Write your class code…
A: GIVEN:
Q: Implement the design of the Pizza class so that the following output is produced: # Write your…
A: The Pizza class has four variables to store the data values for the object of the pizza. The three…
Q: self.baseFare = fare def __str__(self): s = “Name: ”+self.name+", Base fare: "+str(self.baseFare)…
A: Q. write python coiide within 30 minutesDesign Bus class and Train class which inherit Transport…
Q: (Write in the simplest way,please) Write a program that would print the information (name, year of…
A: Using java programming to solve the given problem; Code: class EmpDetails{ private String Ename,…
Q: Write a program that calculates the total cost of airplane tickets according to the following table:…
A: Note: As you have not mentioned the language of the program. The below code is given in CPP…
Q: Write a C++ program with classes to find the roots of a degree 2 polynomial ( a x+bx+c%3D0, ). Use…
A: The Complete code is given below with the output.
Q: (Java) Question 3 Explain the answer step-by-step and include verbal explanation. Thank you!…
A: EXPLANATION: The first object is created of Person class and the constructor is called by passing…
Q: Here is the code given: public class Billing { final static double TAX = 0.08; public static void…
A: Case 1: computeBill() receives a single parameter, it represents the price of one book ordered. Add…
Q: In Java: Write a program that simulates flipping a coin to make decisions. The input is how many…
A: Answer : import java.util.Scanner; import java.util.Random; public class LabProgram {…
Q: A person tries to finish a 10000 piece puzzle and wants to know how much time will it take to finish…
A: The given problem is to be solved in C++ language that will need to create a class Time having…
Q: Write a second constructor as indicated. Sample output: User1: Minutes: 0, Messages: 0 User2:…
A: Program //PhonePlan.java public class PhonePlan { private int freeMinutes; private int…
Q: Design the Team and Player class so that the following expected output is generated. Your answer…
A: The player class will have constructor which doesn't actually takes positional arguments, but…
Q: Write a constructor with parameters self, num_mins and num_messages. num_mins and num_messages…
A: The problem is based on constructors in python. NOTE: In the solution the default value is set to…
Q: Question: 2 Implement the design of the Groceries and Buyer classes so that the following code…
A: I have the same implement program which I done few days and it more useful than this
Q: Python Question Implement the Player class with necessary properties so that the given output is…
A: In Python, Whenever a constructor is called which means a new object is created, we just have to…
Q: Develop a letter-guessing game in this assignment. Requirements: 1). When the game begins, generate…
A: The java code is given below:
Q: Write a program that uses different operators; and Use the methods of the Math class. nstructions:…
A: PROGRAM EXPLANATION Create a class as given in the question. Take 5 grades as input from the user.…
Q: Consider the following code snippet. How many times do you expect "In the constructor!" to be…
A: Please find the answer below:
Q: Enter the name of the item you purchasing. bag Enter the quantity and price separated by a space. 3…
A: Create a header file. Inside the main function declare the function for the input of items name and…
Q: Question 9 Implement the design of the Patient class so that the following output is produced: [You…
A: According to the output given:- We have to implement the design of the Patient Class and follow…
Q: This activity shall test your knowledge in building classes in Java. For this exercise your need to…
A: Objective: A program is designed with a class to construct a Rectangle. The attributes length and…
Q: Observe the given code carefully. Try to understand from the given code and the outputs what to…
A: Given the code and complete the code with the relevant remaining code. The code contains class…
Q: Write java program that has two class the man class and citizenAcoount class. The program will…
A: Required:
Q: Medium resistance: This class includes all resistances of values between 10 Q and 100 k Q. Most of…
A: Below is the complete solution and explanation to the given question in detail.
Q: JAVA Create a class called Quadratic for representing a one-variable quadratic expression of the…
A: A quadratic equation is in the form of the a×x2+b×x+c=0 Where a,b, and c are the coefficients of the…
Q: Design the required class(es) so that the following expected output is generated. Do not change any…
A: Given that, Design the required classes so that the following expected output is generated.…
Q: What is the probability that in a classroom of x people, at least 2 will be born on the same day of…
A: Problem: Probability of having atleast 2 people birthday on the same day through simulating 10000…
Overload the following arithmetic operators (+, -) for Distance class. Two sample outputs
are given below:
Distance d1: 3'-9"
Distance d2: 3'-6"
d1 + d2 = 7'-3"
d1 - d2 = 0'-3"
Distance d1: 3'-9"
Distance d2: 4'-6"
d1 + d2 = 8'-3"
d1 - d2 = Error: negative distance
by using c++
Step by step
Solved in 3 steps
- Create a program in Java that implements Polymorphism and asks the users input to compute the wages of regular and contractual employees. Below is a sample output but it is also accepted to have a different output design Sample Output Payroll System Parent Class ID:Name:Job Position:Job Status: ______________________________________________ Sub Class 1 ID: 101Name: John VasquezJob Position: TeacherJob Status: Regular Enter Rate/Day: 1000Enter Total Days Worked: 24 The Gross Income is: 24,000 --------------------------------------------------------------------------------------- Sub Class 2 ID: 102Name: James MontebonJob Position: Utility ManJob Status: Contractual Enter Rate/hr. 100Enter Total Days Worked: 24 --------> 8 hrs. /day The Gross Income is: 19,200 Note: If you can’t see a word “ ENTER”, which means the values are fixed, no input.Implement the design of the Passenger class so that the following output is produced: The assumption is Bus base-fare is 450 taka. A passenger can carry upto 20 kg for free. 50 taka will be added if bag weight is between 21 and 50 kg. 100 taka will be added if bag weight is greater than 50 kg. [You are not allowed to change the code below] # Write your code here print(“Total Passenger:”, Passenger.count) p1 = Passenger(“Jack”) p1.set_bag_weight(90) p2 = Passenger(“Carol”) p2.set_bag_weight(10) p3 = Passenger(“Mike”) p3.set_bag_weight(25) print("=========================") p1.printDetail() print("=========================") p2.printDetail() print("=========================") p3.printDetail() print("=========================") print(“Total Passenger:”, Passenger.count) Output: Total Passenger: 0 ========================= Name: Jack Bus Fare: 550 taka ========================= Name: Carol Bus Fare: 450 taka ========================= Name: Mike Bus Fare: 500 taka =========================…write python code design Foodcart class and Food class so that the following code provides the expected output.cart1 = Foodcart()food1 = Food('Burger','Chillox',180)food2 = Food.createFood('Cake','Mr. Baker',1000)print("===========================")print(food1)print("===========================")cart1.addFood(food1,food2)print("===========================")cart1.setCartName("Foodpanda")cart1.addFood(food1,food2)cart1.addFood(Food('Steak','Woodhouse Grill',2000))print("Total Price Available:",Foodcart.totalPrice)print("===========================")print("Total Foods created:",Food.totalFoods)print("===========================")cart1.printCartDetails()print("===========================")cart1.removeFood("French Fry")print("===========================")cart1.removeFood("Steak")print("===========================")cart1.printCartDetails()print("===========================")print("Total Price Available:",Foodcart.totalPrice)Output:====================================Food Info : Burger, Food…
- Design the required class(es) so that the following expected output is generated. Do not change any given code.# Write you code herefareChart = {'SR Travels': 40, 'ENA': 50, 'Pathao': 200, 'Uber': 250, 'Hanif Paribahan': 45, 'Others': 90 }v1 = Vehicle("Dhaka-123", "Bus", 'SR Travels', fareChart)p1 = Passenger("Sam", "Dhaka")print("1.===========================")v1.addPassenger(p1)print("2.===========================")p1.calculateFare(v1)print("3.===========================")p2 = Passenger("John", "Dhaka")p3 = Passenger("Bran")print("4.===========================")p3.setDestination("Chittagong")print("5.===========================")v1.addPassenger(p2, p3)print("6.===========================")p2.calculateFare(v1)print("7.===========================")p4 = Passenger("Mark", "Dhaka")p5 = Passenger("Jack", "Khulna")v1.addPassenger(p4, p5)print("8.===========================")p4.calculateFare(v1)print("===========================")v1.status()v2 = Vehicle("Chittagong-798", "Car", "Uber",…Write a program that generates a gradebook similar to the jenzabar grade book output: student name grade letter grade Ahmed ... 90 A- honda 99 A+ Karim 60 D- you must use tuples, list and dictionaries appropriately to get the user input for the grades the grade should include all the categories in the coursework (classwork/homework, quizzes,midterm,final, lab and attendance) the assignments type weight listed in the syllabus must be used to compute the overall class gradeQuestion: 2 Implement the design of the Purchaser and AarongProducts classes so that the following code generates the output below: #Write your code here p1 = Purchaser('Alex Light') print('1.===============================') print(p1) product1 = AarongProducts('Decor', 'Photo-Frame') print('2.===============================') print(product1) print('3.===============================') print(AarongProducts.products) print('4.===============================') AarongProducts.include_products('Souvenirs',['Brass-Flowervase 2170', 'Terracotta-Vase 3500']) print(f'Updated Item List:\n{AarongProducts.products}') print('5.===============================') product2 = AarongProducts('Souvenirs', 'Terracotta-Vase', 2) print(product2) print('6.===============================') p1.create_invoice(product1, product2) print('7.===============================') product3 = AarongProducts('Decor', 'Candles', 5) print(product3) print('8.===============================') product4 =…
- Write a program in Java for the university consisting of the following categories: A mere Person classification contains the following variables:String name The person's name. 1int id id number. 2Write a constructor that receives the variables and a function (ID int , name String(add) whereYou receive the person's name and ID number and assign them. Write the Students class that inherits from the Person class containing the variablesnext:String Specialization The student's specialization. 1double gpa student average. 2Write a constructor that accepts the variables. (Two and a half degrees). Write the Employee class that inherits from the Person class containing the variablesnext:String jop The job name. 1int salary 2Write a constructor that accepts the variables. Create an interface for the program as shown in the following imageWhat is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)? Use a Monte Carlo Simulation and a frequency table to write a program that calculates this probability, where the number of people (x) in the simulated class is given by the user. PLEASE USE the outline of the code GIVEN to answer this question: import mathimport random # create and initialize frequency table:ft = []k = 0while(k < 365) : ft.append(0) k = k+1 # Allow the user to determine class size:print("Please type in how many people are in the class: ")x= int(input()) success = 0 # Simulate:c = 0while(c < 10000) : # Step 1: re-initialize birthday frequency table (it must be re-initialized for each play-through (why?): k = 0 while(k < 365) : ft[k] = 0 k = k+1 # Step 2: randomly get x birthdays and update frequency table: k = 0 while(k < x): # your code goes here ########################## k = k+1 # Step 3:…What is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)? Use a Monte Carlo Simulation and a frequency table to write a program that calculates this probability, where the number of people (x) in the simulated class is given by the user. The probability for a class of size 23, should be right around 50%. NO language of "break" or "true" please! PLEASE USE THE OUTLINE GIVEN BELOW TO WRITE THE CODE: # What is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)?# I have given you the skeleton and some of the code... you complete it using a frequency table!# Note: In a classroom of only 23 people, the probability is about 50.7% !# Try first with 10000 trials and then try with 100000 trials. This code runs somewhat slowly in repl.it import mathimport random # create and initialize frequency table:ft = []k = 0while(k < 365) : ft.append(0) k = k+1…
- Implement the design of the Purchaser and AarongProducts classes so that the following code generates the output below: #Write your code here p1 = Purchaser('Alex Light') print('1.===============================') print(p1) product1 = AarongProducts('Decor', 'Photo-Frame') print('2.===============================') print(product1) print('3.===============================') print(AarongProducts.products) print('4.===============================') AarongProducts.include_products('Souvenirs',['Brass-Flowervase 2170', 'Terracotta-Vase 3500']) print(f'Updated Item List:\n{AarongProducts.products}') print('5.===============================') product2 = AarongProducts('Souvenirs', 'Terracotta-Vase', 2) print(product2) print('6.===============================') p1.create_invoice(product1, product2) print('7.===============================') product3 = AarongProducts('Decor', 'Candles', 5) print(product3) print('8.===============================') product4 = AarongProducts('Souvenirs', 'Brass…What is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)? Use a Monte Carlo Simulation and a frequency table to write a program that calculates this probability, where the number of people (x) in the simulated class is given by the user. The probability for a class of size 23, should be right around 50%. NO language of "break" or "true" please! Please use the outline given below for the code:The Java code provides a Class named Function in Function.java that has a static method named f that takes a double argument and returns the value of . It also has a static method named fprime that takes a double argument for x and returns the value of the slope of f(x). The slope of f(x) can be calculated as . Implement this method. public class Function { public static double f(double x) { return Math.pow(x,3) - 3 * x; } public static double fprime(double x) { // your code goes here } }