et’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
Q: Task - 2 Write the ComplexNumber class so that the following code generates the output below. class…
A: Here is the approach : Create the class complex number . Create the init method in the class .…
Q: in python how do you (1) Build the ItemToPurchase class with the following specifications:…
A: class ItemToPurchase: def __init__(self, item_name = "none", item_price = 0, item_quantity = 0):…
Q: nBasic: def init(self, name = 'Default', hp = 0,weakness = 'None', type = 'Unknown'): self.name =…
A: Write the PokemonExtra class so that the following code generates the output below: class…
Q: Use Java Code to this Please keep it simple 1. Create House Class with the following properties…
A: The solution has two classes, where TownHouse and House class, displaying the inheritance feature.…
Q: Write a new class called DistanceFitnessTracker that extends FitnessTracker. DistanceFitnessTracker…
A: Distance.javaDistanceFitnessTracker.javaFitnessExperiment.javaFitnessTracker.javaHeartRate.javaHeart…
Q: Given the following class, write the code for the Sphere and the Cylinder class so that the…
A: The following are steps need to be taken for the given program: Create Sphere class inheriting…
Q: uestion) class Player: total_player = 0 def __init__(self,name,country):…
A: Design TennisPlayer class which inherit from Player class so that the following code provides the…
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: I just want you to do the second part only using java class, but i have attached the answer for…
A: Solution:: Assignment 1: public class LoanAccount { // properties…
Q: Task: 1. Park class with the following class variables: 1) String ParkName; 2) int ParkID; 3)…
A: Actually, given information: Park class with the following class variables: 1) String ParkName; 2)…
Q: In this exercise, you have to calculate the student's total marks using the concept of Classes…
A: Algorithm: Start Create a class named Student with name, mark1 and mark2 as its private attributes…
Q: D Create a class Sum with the following fields, constructors and methods: Fields: create two…
A: As per the requirement program is developed. Note: In the question programming language is not…
Q: Given the following classes, write the code for the BBA_Student class so that the following output…
A: Solution: Given,
Q: Write the PokemonExtra class so that the following code generates the output below: class…
A: class PokemonBasic: def __init__(self, name="Default", hp=0, weakness="None", type="Unknown"):…
Q: Could you tell me how to fix the error in testing the following code: class Employee: """ The…
A: In the second last line of the program use object to call member function of class Employee. result…
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: Build the ItemToPurchase class with the following specifications: Attributes item_name (string) item…
A: The code is given in the below step
Q: Write the Game class with the required properties to give the following outputs as shown. # Write…
A: Algorithm: Start Create a class with name Game and class members dueList, sentinelList as empty…
Q: What is the output of the following code? public class MyClass { static int num = 20; private String…
A: static variables are the common shared instances among all the classes public static void main…
Q: Build the ItemToPurchase class with the following specifications: Attributes item_name (string)…
A: The code is given in the below step
Q: Q1: Write a Java class called Machine which has: 2 instance variables brandName and power (to check…
A: Sol. 1. Create a Machine class with two instances variables brandName and power. which declare as…
Q: Your task is to create a Circle constructor that creates a circle with a radius provided by an…
A: Algorithm - Design a method with one argument as a string. Now use the below logic to solve the…
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: Write the CheckingAccount class so that the following code generates the output below: class…
A: numberOfAccount is a class level variable which can be accessed by using class name and this gets…
Q: Build the ItemToPurchase class with the following specifications: Attributes item_name (string)…
A: the answer is given below:-
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: Given the following classes, write the code for the Cricket Tournament and the Tennis_Tournment…
A: Solution :
Q: a. Write a Java statement that increments the value of count by 1. b. Write a Java statement that…
A: Please find the answer below :
Q: This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier…
A: the answer is given below:-
Q: Write the CheckingAccount class so that the following code generates the output below: class…
A: ANSWER : Here I have given a python code with the given function name, please find the code, code…
Q: can you please answer number 4 for me 1. Create a class called Student, with the following…
A: Class declaration is given below: public class Student{private String studentName;private int…
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: ** * This is the utility class to accompany RandomNumberGuesser * It contains static methods to…
A: Below is the answer:
Q: Fill in the missing code for the Range class below. Upload your Range.java. public class Range…
A: The setters and getters methods are used for encapsulation in object oriented paradigm. The…
Q: Create a class called RoomCarpet that has three private instance variables – room length and width…
A: Create a Java class that has the private double data of length, width, and price. Create the gets…
Q: Build the ItemToPurchase class with the following specifications: Attributes item_name (string)…
A: Coded using Python 3.
Q: Write a convertToMetric class that has the following field: standard - holds a double, standard…
A: Actually, the code has given below:
Q: Check this code and execute the rectangle class with some modifications: - change to other shapes…
A: Task : Modify rectangle class to show the output of another shape. Add attribute color to the…
Q: ight triangle class with instance variables(double) for sideA, sideB and the hypo. write three…
A: We need to define the class RightTriangle per the given description.
Q: Write a class CountObject which has a method name numberfoObjects() which returns the number of…
A: Static is a keyword that is used for either variables or methods. Once it is declared as static…
Q: 1A. Create a Die class with one integer instance variable called sideUp. Give it a constructor and a…
A: Note: Programming language is missing in the question. So we will answer this program in Java…
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: In this lab you will write three classes: Die, PairOfDice, and Player. The Die dass mimics the…
A: Q: Code the given problem in java
Q: Your task is to implement the following DigitalWallet class. The description of the class is as…
A: In this question we have to write a JAVA program, Where DigitalWallet class has to be executed with…
Q: Task - 3 Write the CheckingAccount class so that the following code generates the output below:…
A: 1) Below is program that includes CheckingAccount class to generate the output It defines Account…
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: Build the ItemToPurchase class with the following specifications Attributes item_name (string) item…
A: Attributes item_name (string)item_price (float)item_quantity (int) Default constructor Initializes…
Q: Task - 1 Let's Play with Numbers!!! Write the ComplexNumber class so that the following code…
A: 1) Below is python program to include ComplexNumber class to generate the output It defines Real…
Q: This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier…
A: NOTE - As per our guidelines we are supposed to do only one question, please repost other parts as a…
Q: Build the ItemToPurchase class with the following specifications: Attributes item_name (string)…
A: The code is given in the below step
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
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- Write the CheckingAccount class so that the following code generates the output below: class Account: def __init__(self, balance): self._balance = balance def getBalance(self): return self._balance print('Number of Checking Accounts: ', CheckingAccount.numberOfAccount) print(CheckingAccount()) print(CheckingAccount(100.00)) print(CheckingAccount(200.00)) print('Number of Checking Accounts: ', CheckingAccount.numberOfAccount) OUTPUT: Number of Checking Accounts: 0 Account Balance: 0.0 Account Balance: 100.00 Account Balance: 200.00 Number of Checking Accounts: 3Build the ItemToPurchase class with the following specifications: Attributes item_name (string)item_price (int)item_quantity (int)Default constructor Initializes item's name = "none", item's price = 0, item's quantity = 0Methodprint_item_cost() Ex. of print_item_cost() output: Bottled Water 10 @ $1 = $10In the main section of your code, prompt the user for two items and create two objects of the ItemToPurchase class. Ex: Item 1Enter the item name:Chocolate ChipsEnter the item price:3Enter the item quantity:1 Item 2Enter the item name:Bottled WaterEnter the item price:1Enter the item quantity:10 Add the costs of the two items together and output the total cost. Ex: TOTAL COSTChocolate Chips 1 @ $3 = $3Bottled Water 10 @ $1 = $10 Total: $13Implement 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…
- D Create a class Sum with the following fields, constructors and methods:Fields: create two integer fields Constructors:- a no-argument constructor- a constructor with two parameters Methods:- write a getter to return the sum of fields- Create 4 overloaded calculate methods 1. method receives two integer parameters and returns the sum 2. method receives four integer parameters and returns the sum 3. method receives two double parameters and returns the sum 4. method receives two String parameters and returns the sum Create a demo class to test the two constructors, all the methods and display the returned values. You can hard code the parameters values. Make sure the four methods created are toverloaded i.e. same method name for all four.Write a new class called DistanceFitnessTracker that extends FitnessTracker. DistanceFitnessTracker will represent a fitness tracker able torecord only distance. Here, you will not be asked to convert between distance units(i.e. the default behaviour of the Distance class will be used, namely, kilometres). Distance.java public class Distance {// Enum of distance unitspublic enum DistanceUnit {KILOMETRES,MILES}// Constantsprivate static final double KMS_PER_MILE = 1.609;private static final double MILES_PER_KM = 0.621;// Instance variablesprivate double value;private DistanceUnit distanceUnit;// Constructorspublic Distance(double value) {this.value = value;// Default unit is kmthis.distanceUnit = DistanceUnit.KILOMETRES;} public Distance(double value, DistanceUnit distanceUnit) {this.value = value;this.distanceUnit = distanceUnit;}// Methods: You should remove the comments and complete the method bodies for all the methods below// Think that all these methods are in the class for a…This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class to contain a new attribute. item_description (string) - Set to "none" in default constructorImplement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Ex. of print_item_description() output: Bottled Water: Deer Park, 12 oz. (2) Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs (empty methods) initially, to be completed in later steps. Parameterized constructor which takes the customer name and date as parameters Attributescustomer_name (string) - Initialized in default constructor to "none"current_date (string) - Initialized in default constructor to "January 1, 2016"cart_items (list)Methodsadd_item()Adds an item to cart_items list. Has a parameter of…
- please code in java..refer the 2 codes BankAccount and AccountTest.. BankAccount source code is given below and AccountTest source code is added in image Question is to add code to be able to lock the account. for example if someone withdraws a certain amount of money the accounts locks, etc /** The BankAccount class simulates a bank account.*/ public class BankAccount{ private double balance; // Account balance /** This constructor sets the starting balance at 0.0. */ public BankAccount() { balance = 0.0; } /** This constructor sets the starting balance to the value passed as an argument. @param startBalance The starting balance. */ public BankAccount(double startBalance) { balance = startBalance; } /** This constructor sets the starting balance to the value in the String argument. @param str The starting balance, as a String. */ public BankAccount(String str) { balance =…public class BackAccount{public double Balance { set; get; }public void Deposit(double amount){Balance = Balance + amount;} }Transaction FeesTransaction TypeDeposit Withdrawal Check BalanceAmount0.25 % of the deposit amount 0.5 % of the withdrawal amount FreeUsing the code snippet above, complete the bank account functionality by adding Withdraw and CheckBalance methods. In your definition for the Withdraw method, check if the account has sufficient funds before making a withdrawal. Apply transaction fees as per the table above:can you please answer number 4 for me 1. Create a class called Student, with the following attributes/variables:a. studentName (String)b. studentNumber (int)sc. regYear(long)d. faculty(String)e. department(String)2. Add the following methods in Student:a. accessors and mutators for all variablesb. toString methodi. Formulate your toString so that it only shows studentName,studentNumber and faculty3. Create a class called MyFriends, with the following attributes variables:a. studentArray(Student[])4. Add the following methods in MyFriends:a. fillArrayi. Using scanner ask how many students does the user want to inputii. Capture user input for all of his friends(Of course we are assuming all your friends would be similarUWC students, go ask around and meet new friends, alsopreferably not in the same Computer Science department … ifpossible … only if possible)b. maini. Call the fillArray methodii. Count how many Computer Science studentsiii. If half or more students are Computer Science…
- In this exercise, you have to calculate the student's total marks using the concept of Classes Problem Statement# Write a Java class called Student with ● private fields: ○ name(String type) ○ mark1 and mark2 (double type) And methods: ● getMarks(int markNumber), a method which should return mark1 if markNumber equals 1 and mark2 otherwise. ● calcTotal() method should take the two marks entered and return their sum. Also define two constructors: ● A default constructor that takes no parameters and initializes the values to zeros and null. ● A constructor that takes the three variables and sets them as the values of the appropriate fields. Input# Name of the student and the marks obtained in the first and second tests Output# Sum of both marks Sample Input# Student student = new Student("Jack", 60, 70); Sample Output# getMarks(1) => 60 getMarks(2) => 70 calcTotal() => 130.0 Part of solution class Student { // Define private fields here public Student() { // Write…Use the following code to answer the question public class SpeedTrap {private int speedLimit;/*** Creates a new SpeedTrap with the given* speed limit* * @precondition speedLimit >= 1* @postcondition getSpeedLimit()==speedLimit*/public SpeedTrap(int speedLimit) {if (speedLimit < 1) {throw new IllegalArgumentException("invalid speed limit");}this.speedLimit = speedLimit;}/*** Gets the speed limit* @return the speed limit*/public int getSpeedLimit() {return this.speedLimit;}/*** Checks to see if the given miles-per-hour* is considered speeding.** @precondition mph >= 0* @postcondition none** @returns true if speeding; false otherwise*/public boolean isSpeeding(int mph) {if (mph < 0) {throw new IllegalArgumentException("invalid mph");}return (mph > this.speedLimit);}}Write a JUnit test named testWhenSpeeding that uses a value for mph that is valid and is considered speeding.Use the following code to answer the question public class SpeedTrap {private int speedLimit;/*** Creates a new SpeedTrap with the given* speed limit* * @precondition speedLimit >= 1* @postcondition getSpeedLimit()==speedLimit*/public SpeedTrap(int speedLimit) {if (speedLimit < 1) {throw new IllegalArgumentException("invalid speed limit");}this.speedLimit = speedLimit;}/*** Gets the speed limit* @return the speed limit*/public int getSpeedLimit() {return this.speedLimit;}/*** Checks to see if the given miles-per-hour* is considered speeding.** @precondition mph >= 0* @postcondition none** @returns true if speeding; false otherwise*/public boolean isSpeeding(int mph) {if (mph < 0) {throw new IllegalArgumentException("invalid mph");}return (mph > this.speedLimit);}}Write a JUnit test for the SpeedTrap constructor named testWhenOneUnderSpeedLimitBoundary