class Trace: def hMB(self,h): if (h==0): print("Stop: ",h) return 0 elif(h==1): print("Stop: ",h) return h else: print("Continue: ",h) return h + self.hMB(h-1) #Tester t = Trace() print("Finally ",t.hMB(5))
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: Complete the class LeetMaker using String methods. Print the word in lowercase Print…
A: Note: In the 2 point print changed word is mentioned. But there is no changed word. So we are using…
Q: Modify the Java CountByFives application so that the user enters the value to count by. Start each…
A: public class CountByAnything{ public static void main (String args[]) { final int START…
Q: class Garden{ private int area; public Garden(int a) { area = a; } public boolean equals (Garden g)…
A: In the following code A garden class is there with area private variable and garden constructor,…
Q: class Line: '''write your codes below (don't forget to change the doc strings)''' def…
A: class Line(object): k=0 b=0 def __init__(self, k, b): self.k=k…
Q: Carrots Peanuts where 4 is the number of items to be inserted; Kale, Lettuce, Carrots, Peanuts are…
A: Java programming: Java is an extremely capable general-purpose programming language. It is used to…
Q: class Duration: def_init (self, hours, minutes): self.hours hours self.minutes minutes def_add_…
A: We have to find output of the given Code
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: Complete method area in the following class. All it needs is a return statement. class Rectangle:…
A: Code: class Rectangle: def __init__(self, w: float, h: float) -> None: self.width = w…
Q: public class MovieRatings extends ConsoleProgram { public void run() { double movierRating =…
A: public class MovieRatings extends ConsoleProgram { public void run() { double…
Q: Namespaces allow for naming variables, methods, classes without worrying about conflict. T/ F a. b.…
A: As per guidelines, we are supposed to answer only three subparts of question. Kindly send other…
Q: class Garden{ private int area; public Garden (int a) { area = a; } public boolean equals (Garden g)…
A: Ans: Code: class Garden{ private int area; public Garden(int a){ area = a; }…
Q: implementation
A: Actually, python is a easiest programming language. It is a dynamically typed programming…
Q: Print the arrival time of the flight using a combination of methods from Flight and LocalTime • Read…
A: A flight object is created using parameterized constructor and then the changes are made and…
Q: Class Die java.lang.Object extended by Die public class Die extends java.lang.Object Die - an…
A: public class Main{ public static void main(String[] args) { Die d1=new Die(); //creates Die…
Q: Write a method (compare Strings) that reads two strings from the keyboard and prints the largest…
A: Write a program to find out largest given two string. If two strings are equal then print 'The two…
Q: /** * Processing Data with Loops */ public class skipChar { /** Write the method named skipChar()…
A: public class SkipChar {public static void main(String[] args) {SkipChar sk=new…
Q: Java programming language I need the two classes ( the testing class and the class with the…
A: We can merge both the classes in one (testing and method class) . We can use main method the…
Q: How should the code be fixed? public class MidtermProblems { // Main driver method public…
A: There are multiple error, here is the explanation.
Q: Write a Java method splitName() that takes a string (that contains 1 word or more (space-…
A: Sample Response: //Java codeimport java.util.Scanner; public class splitName{ //splitName method…
Q: // Implement method getTotalCost to return the totalCost. // Your code here... // Implement method…
A: Define the class named ShoppingCart. Declare the data fields as customerName, numItems and…
Q: public class output{ public static int check (int a, int b, int c) { if(a==0) return (b); else if…
A: Given:
Q: def fun_cities(adict, city): """ Question 7 - Given a dict that maps a fun activity to…
A: Answer:
Q: ** * Test Food class */ public class FoodTester { public static void main(String[] args) { Food…
A: Actually, java is a object oriented programming language. Ii is a platform independent.
Q: one
A: public class RegularTriangle { private int side; public…
Q: public class Question1 { public static void main(String[] args) { double val; int counter = 0; int…
A: public class Question1 { public static void main (String[]args) { double val; int…
Q: Need to complete this evaluate while class that is simialr to the evaluate if statement tree…
A: Your logic is correct similar to if part logic for tree traversal . As I can see you are facing…
Q: 3. Import Class a) Import pi only from math module. b) Implement a class Circle with an attribute,…
A: code is in next step:
Q: In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the…
A: The problem is based on the basics of classes in C++ programming language.
Q: class Surprise: def mystery (self,n) : print ("h(" ,n,")") if (n==0): print ("value: 0") return 0…
A: class Surprise(): def mystery(self,n): print("hello")…
Q: Implement the class Character The role should be “primary” or “secondary” all other values are…
A: Begin Enter name Enter role Enter gender Enter age Enter salary Print using toString() End
Q: class Circle: A circle with a radius. def init_(self, r: int) -> None: """Create a circle with a…
A: class Circle: radius = 0 #A Circle with a radius def __init__(self, radius):…
Q: PYTHON PROGRAMMING CODE: class Dog: def __init__(self, name, breed, age): self.name = name…
A: The 1st line of the code creates a class named Dog. A class is a group of objects which have common…
Q: public class EscapeSequences { public static void main( String args[] ) { // Add a tab between…
A: Code public class EscapeSequences { public static void main(String args[]){ System.out.println("He…
Q: Draw a UML class diagram for the following three classes to show their structures and relationships.
A: The class diagram is composed of three parts: Upper section: Name of the class - This section…
Q: cashier in a supermarket returns change to customers. Suppose we want to write a program to help the…
A: C++ Code for above : #include <bits/stdc++.h> using namespace std; vector<int>…
Q: Complete the convert() method that casts the parameter from a double to an integer and returns the…
A: Algorithm: Start Implement convert() method which takes a double number as argument and returns an…
Q: Modify the CountByFives application so that the user enters the value to count by. Start each new…
A: Given: A code snippet in Java containing a method that prints numbers counted by 'five'. Objective:…
Q: ss Point: """ A point in a two-dimensional coordinate plane """ def…
A: The move method in WindTurbine calls the move method from Rectangle, which causes the turbine's…
Q: et’s Play with Numbers!!! Write the ComplexNumber class so that the following code generates the…
A: Noww we have to write the ComplexNumber class which has two attributes to store real part and…
Q: class overload { int x; double y; void add(int a { x = a + b; } void add(double c { y = c + d; }…
A: Given, Code: class overload { int x; double y; void add(int a , int b) {…
Q: Die Write a Die class to model a die (like you play Yahtzee or Monopoly with). Fields faces The…
A: Die.java import java.util.Random; public class Die { /** * @param args */ //attributes…
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E"…
A: Answer:
Q: Import Class a) Import pi only from math module. b) Implement a class Circle with an attribute,…
A: In this question we have to write a python code class program with circle and rectangle classes with…
Q: Givén thé fóllówing UML diagram of the Recipe class, write the implementation of the method…
A: class Recipe{ String name; String[] ingredients; int numOfRecipes; Recipe(){…
Q: Tape for a Turing Machine (Doubly-linked List)”.(I USE ECLIPSE & RUN CHECK ONLINE CONSOLE) A class…
A: public class Tape { // Instance variablesprivate Cell currentCell; /*** Default constructor*/public…
Q: Complete the method buildPhrase that prompts the user to enter a phrase, þne word at a time. When…
A: Using equals function check the string is -1. If -1 stop iterating otherwise read word Append word…
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: Die Write a Die class to model a die (like you play Yahtzee or Monopoly with). Fields faces The…
A: Answer Die.java import java.util.Random; public class Die { /** * @param args */…
- [Easy]
class Trace:
def hMB(self,h):
if (h==0):
print("Stop: ",h)
return 0
elif(h==1):
print("Stop: ",h)
return h
else:
print("Continue: ",h)
return h + self.hMB(h-1)
#Tester
t = Trace()
print("Finally ",t.hMB(5))
Step by step
Solved in 2 steps with 1 images
- class Line:'''write your codes below (don't forget to change the doc strings)'''def __init__(self, k, b):'''write your codes below (don't forget to change the doc strings)'''def __repr__(self):'''printable representation of the line by equation y = k*x+b'''return 'line y = %r*x + %r' % (self.k, self.b) def __add__(self,other):'''write your codes below (don't forget to change the doc strings)'''def intersect(self,other):'''write your codes below (don't forget to change the doc strings)'''Complete the class LeetMaker class using String methods. Remember that all the String methods are accessors. They do not change the original String. If you want to apply multiple methods to a String, you will need to save the return value in a variable. Complete the class by doing the following: Print the word in lowercase Replace "e" with "3" (Use the unmodified variable word) Print the changed word In the changed word, replace: "t" with "7" Print the changed word In this newest changed word, replace: "L" with "1" (uppercase L with the number 1). Then, print the final changed word (with all the replacements) Print the length of the word The code to print the original word is already included for you. Do not change that statement. You will need to use the replace() method multiple times. Then print the final String. Remember that replace is an accessor method; It returns the changed version of the String. If you want to do something with the returned String - like use replace() on…Implement the class Character The role should be “primary” or “secondary” all other values are not acceptable. Considercapital and small letters variance. The gender should be “m” or “M” for male or “f” or “F” for female. The age should be a positive value. The giveRaise method increase the salary of a character by a given percentage with amaximum salary of 10000. The toString method returns a string that describes the character. For example: [Elisabeth Kane, female, 35, primary,4500$] 2) Implement the class Play A Play can have at most 20 characters. The real number of characters is registered in nbOfCharacters and is updated automaticallywhen a new character is added. AddCharacter method adds a new character to the characters array and updates thenbOfCharacters value. The attribute nbPlay keeps track of the number of Plays created. The toString method returns a string description of the play including name, genre and thenames of all the characters.Example: [The Opera…
- Load your bag with some initial values, but do not fill it. Your client code should give the user the option to: display the contents of the bag using the class method “toVector” add values to the bag remove values from the bag sort the bag search for a value using their choice of either the iterative search or the recursive search - both need to be tested Allow the user to keep doing these things until they are done. Do not automatically sort the bag if the user chooses to search. Your program should give the user a message telling them they must first sort the bag before they can search.You decide what the user interface will be. Make it clear and easy to use. It can be very basic; nothing fancy. A menu driven program works well. Each value in your array should be unique - no value will appear in the array multiple times. Your array elements can be any data type – use a template class put in place in the code provided. You can write your client code to process a bag holding any…mport java.util.Scanner; public class ParkingCharges { // function to calculate the basic charge using the asked hours static double getBasicCharge(int hours) { if (hours >= 7 && hours <= 8) return 5.50; else if (hours >= 5 && hours <= 6) return 4.50; else if (hours >= 2 && hours <= 4) return 4.00; return 3.00; } // function to return the amount to subtract based on local living and OAP static double getDiscount(String isLocal, String isOAP) { if (isOAP.equals("Yes") && isLocal.equals("Yes")) return 2.0 + 1.0; else if (isOAP.equals("Yes")) return 2.0; else if (isLocal.equals("Yes")) return 1.0; return 0; } public static void main(String[] args) { // create a new Scanner object Scanner sc = new Scanner(System.in); // prompt the user to ask if they are disabled…Let’s Play with Numbers!!! Write the ComplexNumber class so that the following code generates the output below. class RealNumber: def __init__(self, r=0): self.__realValue = r def getRealValue(self): return self.__realValue def setRealValue(self, r): self.__realValue = r def __str__(self): return 'RealPart: '+str(self.getRealValue()) cn1 = ComplexNumber() print(cn1) print('---------') cn2 = ComplexNumber(5,7) print(cn2) OUTPUT: RealPart: 1.0 ImaginaryPart: 1.0 -------------------- RealPart: 5.0 ImaginaryPart: 7.0
- **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…class Circle: """ A circle with a radius. """ def __init__(self, r: int) -> None: """Create a circle with a radius r. >>> c = Circle(10) >>> c.radius 10 """public class Question1 {public static void main(String[] args) {double val;int counter = 0;int numIterations = 0;/*** Part a: Implement a branching condition that increases counter by 1 if val is larger than 0.5*/val = Math.random();/*** Part b: Add a loop around the code created in Part a that continues until counter equals 3.*//*** Part c: Use the variable numIterations to count how many times your loop in Part b iterates*/System.out.println("Number of Iterations until 3 random values greater than 0.5 were generated: "+ numIterations);}}
- 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(1, 45)second_trip = Duration(0, 42) first_time = first_trip + second_tripsecond_time = second_trip + second_trip print(first_time.hours, first_time.minutes)print(second_time.hours, second_time.minutes) WHAT IS THE OUTPUTplzz help no need to show work...just the answerclass 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_tripsecond_time = second_trip + second_trip print(first_time.hours, first_time.minutes) what is the output