Question # 04: Write base class that ask the user to enter a complex number and derived class adds the complex number of its own with the base. Finally make third class that is friend of derived and calculate the difference of base complex number and its own complex number.
Q: Complete the program class Person { public: string profession; int age; Person ():…
A: The code is completed in the below steps.
Q: 3. (a)How many parameters does the following constructor have? public Student (String name, int…
A: 3(a) Ans: Constructor student having two parameters name and stupid. 3(b) Ans: Student std = new…
Q: Write a program that use two classes. Calculate the factorial of a given number by using one class…
A: Constructors are the functions which have same name as class name and whenever an instance is…
Q: The following code may, or may not, work. However the bigger issue is that it doesn't give good…
A: Required: The following code may, or may not, work. However the bigger issue is that it doesn't…
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: class Doctor: """Represents a Doctor""" #initializer with specialization default to "general" def…
A: Hello student, hope you are doing well. The script and the introduction is attached below.
Q: True or FalseThe same rules for naming variables apply to naming classes.
A: Rules for naming variables and naming classes: Pascal Case is the standard naming convention used…
Q: Complete the program class Person { public: string profession; int age; Person ():…
A: ANSWER:
Q: Declare Math class which has a function overloading. There are two versions of add function. The…
A: Find Your Code Below
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E"…
A: The correct answer is (E) Seed Explanation: The composite class known as a concrete component class…
Q: I. Using the dialog boxes in the JOptionPane class, write a program that calculates and prints the…
A: PROGRAM: //Importing header import javax.swing.JOptionPane; //Defining class class…
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: Reuse your Car class . In a main, build an object of that class, and print out the object using…
A: public class Car { //instance variables private int odometer; private String make;…
Q: Write a program that implements the algorithm delimiterMatching() seen in class.
A: public class delimiterMatching { public static void main(String a[]){ delimiterMatching…
Q: Suppose that you are in charge of customer service for a certain business. As phone calls come in,…
A: Answer: The Main program have all the methods to test the methods in the ServiceRequests class…
Q: public class Team { private String name; private int wins, int losses; public…
A: Program Approach: In the given code a class "Team" is declared that defines one string "name"…
Q: Complete the program class Person { public: string profession; int age; Person ():…
A: CODE:
Q: A decimal number is composed of an integral part and a fractional part. The number appearing before…
A: SOLUTION: CODE: #ifndef ROUNDOFF_H #define ROUNDOFF_H #include<iostream>…
Q: QUESTION 9 Public Class Employee { public static int y; Private int age; Public Employee0{ age=0;}…
A: I have given the output for the above code.
Q: Q1: write program by using class to find the area of circle with using constructor function and…
A: PROGRAM INTRODUCTION: Include the required header files. Start definition of class test. Declare…
Q: I. Using the dialog boxes in the JOptionPane class, write a program that calculates and prints the…
A: PROGRAM: //Importing header import javax.swing.JOptionPane; //Defining class class…
Q: Lab04-06. Change the definition of the following constructor to use initialization instead of…
A: A function or method can be initiated by using the initializer list. The syntax is shown below.…
Q: Complete method __init__ in the following class. (It's only missing an assignment to a radius…
A: Here in the init method, we have an integer type argument whose value will be passed at the time of…
Q: i have written the first question, please follow the way of my first question /* Employee class…
A: import java.util.Scanner; /* Employee class*/public class Employee { public int EmployeeID;…
Q: Write a Rectangle class that has the following fields: Length (L): a double Width (W): a double The…
A: Since the language was not mentioned , the answer is provided in C++ language. Code: #include…
Q: Question 01: Write a Program to design a class complex to represent complex numbers. Create an input…
A: As per expert guidelines , when there are unrelated multiple questions, I am supposed to answer the…
Q: JAVA Write a class that corrects a sentence. Your class must capitalize the letter in each…
A: Write a class that corrects a sentence. Your class must capitalize the letter in each sentence.
Q: Identify the constructor for the following class class Teacher { int id; String name; O a. Teacher)…
A: Option (a) is the correct option.
Q: Write a Rectangle class that has the following fields: Length (L): a double Width (W): a double The…
A: * Writting program in c++ as no programming language in mentioned in the question. #include…
Q: Write a convertToMetric class that has the following field: standard - holds a double, standard…
A: Actually, the code has given below:
Q: ?Which the following is not correct for the class defined class student{ int student(){}} class…
A: Note: Answering the first question as per the guidelines. In the given question, the class student…
Q: public class Rational private int numerator; private int denominator; public Rational (int…
A: GIVEN: Fix the typo in the given java program. The output should be a single line. TYPO ERROR: In…
Q: Lab04-07. Given the following class definition: class Sample private: int x; public: int getx ()…
A: A constructor is a special member function of a class that automatically called when the object of…
Q: class Sugar{ public: Sugar (int q) {this->quantity = q;} int get() {return quantity;} void set (int…
A: This program comprises of 3 three classes namely Milk, Sugar, and Tea class. Milk and Sugar class…
Q: python language Write a function that overwrite the greater than method for a class. The class…
A: Given, The function should overwrite greater than method i.e should implement less than or equal to.…
Q: Q3. Modify the class by adding another method that prompts user for a positive integer. The program…
A: In this question, we are asked to write a java program to reverse the number, explained code below
Q: Write base class that ask the user to enter Time (hour minute and second) and derived class adds the…
A: Code for Base class: // Base class class timeBase { private: int hours, min, sec; public:…
Q: . A complex number is a number which can be put in the form a + bi. Create a class for complex…
A: // iostream in C++ is the standard library which implement stream based input/output capabilities…
Q: Given the following class: public class Student { private long ID; private String name;…
A: Programming instructions: Create a Student class. Create variables. Create constructor without…
Q: In Programming Exercise 2, the class dateType was designed and implemented to keep track of a date,…
A: #include <iostream>class dataType{ int month,day,year; public: void setmonth(int m){…
Q: 8.9 LAB: Car value (classes) Complete the Car class by creating an attribute purchase_price (type…
A: """Program to define a car class and calculate car value""" #define a car classclass Car: #init…
Q: Find the error(s) in the following class definition: public class Circle { private double radius;…
A: Ans: The error in the following class definition is that in the get and the set function the get…
Q: public int getMileage (int miles, int gallon) public double getMileage (int kilometers, int liters)
A: Given :
Q: 1. A constructor is a special type of method. 2. The following code will result in a compiler error:…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Write base class that ask the user to enter a complex number and derived class adds the complex…
A: Since the programming language is not mentioned, so we'll do it in c++. The programming…
Q: Please add the following to my class in the code and don't make a sepearte one Question: Implement…
A: import edu.princeton.cs.algs4.*;import edu.princeton.cs.algs4.LinearProbingHashST;import…
Q: Complete the Car class by creating an attribute purchase_price (type int) and the method…
A: class Car: def __init__(self): self.model_year = 0 # TODO: Declare…
Q: Create a class Fraction with two integer final fields: numeratorand denominator. Its constructor…
A: Introduction of the Program: The Java program makes a Fraction class and this class has two member…
Write in C++.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Question: Implement the following functions in your class: getTotalWords (returns the amount of total words), getUniqueWords (returns the amount of unique words), getMostUsedWord, (returns the word that is most used) getMaxOccurrence (returns how many times the most used word occured). Name them as indicated here. The code to add the functions to: import edu.princeton.cs.algs4.*;import edu.princeton.cs.algs4.LinearProbingHashST;import edu.princeton.cs.algs4.SeparateChainingHashST;import edu.princeton.cs.algs4.ST;import edu.princeton.cs.algs4.SequentialSearchST;import edu.princeton.cs.algs4.In;import edu.princeton.cs.algs4.StdOut; public class TestPerf { public static long LinearProbingHashST(String x[]) { LinearProbingHashST<String, Integer> st = new LinearProbingHashST<String, Integer>(); long start = System.currentTimeMillis(); for(int i = 0; i < x.length; i++){ String key = x[i]; if…Create a RationalNumber (fractions) class like the one Provide the capabilities:Create a constructor that prevents a 0 denominator in a fraction, reduces or simplifies fractions that are not in reduced form and avoids negative denominators.Question: 2Implement the design of the Chillox and Customer classes so that the following code generates the output below:print(f"It's been a good day!. \nToday, we have already served {Chillox.order_id} customers.")print("**************************************************")outlet1 = Chillox()print("1.==========================================")print("Burger Menu:")print(Chillox.menu)print("2.==========================================")outlet1.addBurger("Chicken Burger",180,"Chicken with Cheese",200)print("3.==========================================")print("Burger Menu:")print(Chillox.menu)print("4.==========================================")c1 = Customer("Samin")c1.order = "2xChicken Burger"outlet1.placeOrderof(c1)print("5.==========================================")outlet1.addBurger('Chicken Smoky BBQ Cheese',225)c2 = Customer("Rafi")c2.setOrder("2xChicken with Cheese,3xChicken Smoky BBQ…
- A complex number has two parts: real value and imaginary value. In mathematics, we learnt how to add and multiply two complex numbers. Write a class Complex which will have two fields for real and imaginary values. The constructor will set the values in these fields (there could be multiple overloaded constructors). The class should also have method like this: Complex add (Complex c) This add() method takes a complex object and return a new complex object after adding the complex number c with itself(Use general complex number addition rule).Create a new data type Fraction using classes. The each fraction should have two parts numerator and denominator. Afterwards, overload the following operator for the class. operator Used as purpose ++ ++f1; Will increase the fraction by 1. Example1: f1= 1/3 ++f1; d1=4/3 Example1: d1= 2/6 ++d1; d1=8/6Question: 2Implement the design of the Groceries and Buyer classes so that the following code generates the output below:#Write your code herebuyer1 = Buyer('Ross', 'CL23')print('1.===============================')print(buyer1)item1 = Groceries('Mango', 'Fruits')print('2.===============================')print(item1)print('3.===============================')print(Groceries.items)print('4.===============================')Groceries.add_items('Packaged',['Flour 90', 'Noodles 30', 'Soybean-Oil 150'])print(f'Updated Item List:\n{Groceries.items}')print('5.===============================')item2 = Groceries('Flour', 'Packaged', 3)print(item2)print('6.===============================')buyer1.create_bill(item1, item2)print('7.===============================')item3 = Groceries('Orange', 'Fruits', 3)print(item3)print('8.===============================')item4 = Groceries('Rice', 'Packaged', 2)print(item4)print('9.===============================')buyer2 =…
- Question: 2 Implement the design of the Laptop and Store classes so that the following code generates the output below: print("Total Laptop Created:",Laptop.total_laptop) print("1.=========================================") s1 = Store() p1 = Laptop("Lenovo B4180", 55000) print("2.=========================================") p2 = Laptop("HP Pavilion") print("3.=========================================") s1.add_laptop(p1, p2) print("4.=========================================") p2.setPrice(77000) s1.add_laptop(p2) print("5.=========================================") s1.sell_laptop("HP Probook") print("6.=========================================") print(s1) print("7.=========================================") s2 = Store("Star Tech") p3 = Laptop("HP Probook", 58000) print("8.=========================================") p4 = Laptop("Lenovo Thinkpad", 60000) print("9.=========================================") p5 = Laptop("HP Elite", 80000)…Question 8: Questions 8 - 12 are based on the following code. Now, this code results in a compile error (where it's marked "here"). Why? class Fraction {private: int numerator; int denominator;public: Fraction(int n, int d) { numerator = n; denominator = d; } void display() { cout << numerator << "/" << denominator << endl; }};int main() { Fraction f; // <-- here return 0;} Group of answer choices There is no constructor defined Copy constructor is undefined Default constructor is undefined Constructor is defined as public Question 9: Find an incorrect definition of getter/setter for Fraction. Group of answer choices void setNumerator(int n) { numerator = n; } void getNumerator() { return numerator; } void setDenominator(int d) { denominator = d; } int getDenominator() { return denominator; } Question 10: What would be the printout of the following code segment? Fraction f(2, 3); f.display(); Group of answer choices…Question 1: Create two classes in c++ one is rectangle and other is square. Both classes are friend of each other .Take value of sides of square and use it to convert it to Calculate area of rectangleArea of rectangle=width*hight
- do part 4 import java.util.*; // Car classclass Car{ private String name; // Variable to hold car name private String model; // Variable to hold car model // Default constructor Car(){ this.name = null; this.model = null; } // Parametrised constructor Car(String name, String model){ this.name = name; this.model = model; } // Function to get car name public String getName(){ return this.name; }} // Dealer classclass Dealer{ private Car[] arr; // Array holding car objects for a dealer private int count; // Variable to hold number of cars under a dealer // Default constructor Dealer(){ arr = new Car[50]; count=0; } // Function to add a car under a dealer public void addCar(Car obj){ this.arr[this.count] = obj; this.count++; } // Function to check if a car exists under a dealer or not public boolean contains(String name){…Reuse your Car class . In a main, build an object of that class, and print out the object using System.out.println(). Notice that this simply reports the memory address of the object in question, and we’d like to do something more useful. To replace (or override) the toString (or equals) function. Now, build a toString function that prints out the make, model, and odometer reading for a vehicle object. public class Car { //instance variables private int odometer; private String make; private String model; //overloading //constructors public Car(int odometer,String make, String model) { this.odometer = odometer; this.make = make; this.model = model; } public Car(String make, String model) { this.make = make; this.model = model; } public Car(String make) { this.make = make; } /* *getter & setter methods */ public int getOdometer() { return odometer; } public void…Question: 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 =…