explain why "this->dollars = dollars_part; this->dollars += cents_part / 100; this->cents = cents_part % 100;" is used
Q: Use C++ Write a program with total change amount as an integer input that outputs the change using t...
A: A required program is as follows, #include <iostream> #include <vector> using namespace ...
Q: To fully define a variable one needs to mention not only its ‘type’ but also its ‘other properties’....
A: To fully define the variable we needs to mention the data type of the variable is must but further...
Q: The problem below involves the UDP protocol.DescriptionClientSend an integer in the range 0 to 100 r...
A: Note: Follow Proper indentation as specified in code. Basic steps followed in client-server communic...
Q: The decision variant of the minimum vertex cover problem is stated as follows. Given an undirected g...
A: Actually, the answer has given below:
Q: Describe why web caching can reduce the delay in receiving a requested object. Will Web caching redu...
A: Caching of the Internet A Web cache is a network object used to meet a client request without the in...
Q: Find the least number of cables required to connect eightcomputers to four printers to guarantee tha...
A: Total Computers = 8 Total Printers = 4 Here, when any four computers are selected , these four compu...
Q: 3. TCP's Flow Control guarantees that. Optional Answers: 1. The sender won't overwhelm the receiver ...
A: TCP is a connection-oriented communications protocol used for reliable communication channel over an...
Q: Write LMC assembly code that prints the minimum of two numbers. HINT: use and extend the table below...
A: Write LMC assembly code that prints the minimum of two numbers.
Q: Convert -123.6875 to IEEE format.
A: Givne number = -123.6875 IEEE 754 format in single precision is 32 bit. Sign bit = 1 Exponent = 8 bi...
Q: . Answer the following questions for the machine language instructions 6AF82C and D623D (a) What is ...
A: Actually, the answer has given below:
Q: Search engines spend their lives touring the web gathering up information on websites which the SEs ...
A: -> Spiders, for example Googlebot, visit the web pages in search of new data to add to the index....
Q: Write the difference between the characters' two data types in SQL Server: VARCHAR NVARCHAR
A: Data types: While creating a table in the database, each and every column of the table will be havi...
Q: For this week's conversation, since we are talking about functions, most other programming languages...
A: This is related both to linker and operating system behaviors and language design. C code is called ...
Q: Numerical Analysis
A: PROGRAM STRUCTURE: Include the required header files. Define the value of epsilon as 0.001 Write th...
Q: C++ Fix this code so that it displays in the format like the image shown where the principal and rat...
A: CHANGED STATEMENTS: First statements that is changed to get the desired result is: cout << "...
Q: Select all expressions that evaluates to an empty dictionary. O dict([]) O dict()) O dict() O dict(s...
A: 1.) All expressions are empty dictionary See the input and output down below:
Q: If f(n) = theta (g(n) log n) then g(n)=0(f(n)) O True O False Use master theorem to solve the follow...
A:
Q: InstructionsLet n be a nonnegative integer. The factorial of n, written n!, is defined by 0! = 1, n!...
A: Approach To calculate factorial of any non-negative number, we can use either loop (for or while) or...
Q: 2. Given the context-free grammar G below: S → aSb|bSa[SS|A (a) Draw a derivation tree for the strin...
A: a) DERIVATION TREE: For the string aabbbabbaa
Q: In the context of a wireless sensor network (WSN) given below, please list at least three different ...
A: WSN: WSN stands for Wireless Sensor Network. This network is basically de dicated for the purpose o...
Q: Write static methods: public static double cubeVolume(double h) : h^3 public static double cube...
A: Two questions are asked so we will give the answer to the first question only. Please upload another...
Q: Create class SavingsAccount. Usea static variable annualInterestRate to store the annual interest ra...
A: class SavingsAccount { //instance variables privatestaticfloatannualInterestRate; privatefloatsaving...
Q: The following code spawns n-1 concurrent processes by the forall construct. Each process ww www i re...
A: Semaphore : Semaphore is essentially a variable that is non-negative and shared between strings. A s...
Q: Operating systems have suitably and rapidly evolved over the years from serial processing operating ...
A: 1. Resource management is one of the main OS functions. Hardwire or software may be the resource. Fo...
Q: Use C++. This lab should provide you with practice in stream formatting. classes are pretty much use...
A: A required program is as follows, #include <iostream> #include <iomanip> #include <st...
Q: Write a query to display the brand ID, brand name, brand type, and average price of products for the...
A: A query to display the brand ID, brand name, brand type, and average price of products for the brand...
Q: java programming
A: Java code: public class Main { //class public static void main(String[] args) { //main me...
Q: When you use File Explorer or Windows Explorer to delete a file from the hard drive, where does Wind...
A: Recycle Bin: The Recycle Bin is a place where deleted files or directories have been temporarily pla...
Q: (Using C programming) A positive integer is entered through the keyboard, write a function to displa...
A: C Code Fibonacci without recursion #include <stdio.h>int main() { int i, n, t1 = 0, t2 = 1,...
Q: Please solve very soon
A: A regular expression that can generate L over the alphabet Σ = {0,1} is mentioned in next step:
Q: Create a Deterministic finite automaton that takes in binary strings and accepts them which has both...
A: The solution is divided in three parts: 1. Split the given language into two small languages. L1 acc...
Q: (a) Why is a datagram buffer needed on the output port of a router? (b) Explain why distance vector ...
A: Note: only one question can be answered at a time in the BNED Guidance. If you want a reply to anoth...
Q: Turtle Graphics is a Python feature like a drawing board, which lets us command a turtle to draw all...
A: The internal angle is 135 Therefor 180-135=45 So, we have used angle 45 to turn right every time and...
Q: Exercise 4: Write a Python program that asks the user to enter two numbers n and m, then your progra...
A: Approach Import the math module to use the pow() function. Input n. Input m. Check if n <= 0 or ...
Q: Description of the architecture of your networks, Plots of the loss on the training set through epoc...
A: X
Q: (Algebra: multiply two matrices) Write a method to multiply two matrices. The header of the method i...
A: Programming approach: Two-dimensional arrays are used to input 2 matrices and store the product of i...
Q: W XYZ Corporation pays its salespeople a commission based on the amount of their sales, as shown in ...
A: x = 1 commission = 0 total_sales = 0 while(x<101): salesamount= int(input(f'\nEnter sales amount ...
Q: Why is storage needed in a computer?
A: Computer:A computer is an electronic instrument that can receive several mathematical and logical in...
Q: Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The ...
A: Actually, the code has given below:
Q: Why is the output of this code 11? Can someone give me a step-by-step explanation?
A: C++ code with output Note: When break is not written within a case then switch causes the flow to c...
Q: how Linux could play a role in any aspects of rocket technology.
A: LINUX COULD PLAY A ROLE IN ANY ASPECT OF ROCKET TECHNOLOGY - The new waves are required, like the NA...
I am trying to understand a part of a code
code
// To do: Implement class Money constructor
// (Hint: Use either : initializer form or assignment,
// EXTRA CREDIT to incorporate cents over 99)
Money::Money(int dollars_part, int cents_part)
{
this->dollars = dollars_part;
this->dollars += cents_part / 100;
this->cents = cents_part % 100;
}
// Return true if the invoking object has less value than m
bool Money::isLessThan (const Money &m)
{
if (this->dollars == m.dollars) {
return this->cents < m.cents;
}
return this->dollars < m.dollars;
}
// Output the Money object
void Money::output()
{
cout << "$" << dollars << ".";
if (cents < 10) {
cout << "0";
}
cout << cents;
}
Can someone explain why "this->dollars = dollars_part;
this->dollars += cents_part / 100;
this->cents = cents_part % 100;" is used when its says "To do: Implement class Measurement constructor
// (Hint: Use either : initializer form or assignment,"?
Step by step
Solved in 2 steps
- 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…In Java, Write a line of code that performs each of the following tasks : (a) Call superclass Employee's toString method from subclass Pieceworker's toString method. (b)Specify that class Pieceworker inherits from class Employee. (c) Call superclass Employee's constructor from subclass Pieceworker's constructor - assume that the superclass constructor receives three strings representing the first name, last name and social security number.Computer Science In Java, create a class Die representing a die to roll randomly. -Give Die a public final static int FACES, representing how many faces all dice will have for this run of the program. -In a static block, choose a value for FACES that is randomly chosen from the options 4, 6, 8, 10, 12, and 20. -Give Die an instance variable current, representing the last value it rolled. (cannot be less than 1 or more than FACES) -Give Die int instance variables maxCount and minCount. (cannot be negative) -Give Die a method roll that randomly sets current to a value between 1 and FACES. If the die rolls a 1, increase minCount, if the die rolls FACES, increase maxCount. -Give Die a static method sumDice, which takes a variable length parameter list of Dies and returns the sum of all their current values. -Give Die a static method sameDice, which takes a variable length parameter list of Dies, and returns true only if all of them have the same current value. Do not compare…
- ???????? 2: Design the required class(es) so that the following expected output is generated. Do not change any given code. Your code should work for any number of arguments in init and setToppings method of pizza class. For simplicity, you can consider there will be only 3 categories of pizzas and they are: Chicken, Beef, Cheese. #Write your code here dom = Dominos("Domino's Pizza") print("1.=================================") p1 = Pizza("Spicy Chicken","Spicy Chicken","Onion","Capsicum") dom.addPizza(p1) p2 = Pizza("Margherita","Mozzarella Cheese") print("2.=================================") p3 = Pizza("Beef Kala Bhuna") print("3.=================================") p3.setToppings("Curried Beef","Capsicum","Paprika","Onion") print("4.=================================") dom.addPizza(p2,p3) p4 = Pizza("Chicken Dominator","Barbecue Chicken,Spicy Chicken,Grilled Chicken") p5 = Pizza("Beefzza","Minced Beef","Beef Pepperoni","Onion","Jalapeno") dom.addPizza(p4,p5)…Subject: Java Programming Hi Expert Sir, this (A, B) is one question...... please read and solve it carefully. and Don't submit the wrong answer. It's very important to me.... thank you Write a program to calculate the midpoint of two 2D coordinate points. A) Among them, the Point class represents two-dimensional coordinate points and has private member variables x and y, representing the values of the abscissa and ordinate, initialized by the constructor. B) Four methods setX (), getX (), setY (), and getY () are used to set and obtain the coordinates. In addition, a member method midPoint (Point p), which takes a Point object as a parameter, calculates the midpoint of the two coordinates and returns a new two-dimensional point. It is required to reflect the encapsulation characteristics in the program. Instantiate two two-dimensional points (4, 5) and (6, 8) in the main function of the class Test. Calculate the midpoint of the two by calling the midPoint of one of them and return…For this assignment, you will develop the planning necessary for constructing a class that implements a Bag ADT in Java. Your program will store corresponding items for an On-Line Food Delivery Service. Specifically, your program should consider an item's name and price and manage the customer's shopping cart. The following are example values your class will be using for data: Customer Number = 1; item_Name="Can of Soup"; Price = $4.00; After selecting your values for data, what are the required operations that must be used to create the Bag Interface? Your deliverable will consist of the following: Pseudocode for your proposed program Flowchart of the operations of adding items to the shopping cart and removing items from the cart.
- Take this the Java Gringrots problem below turn it into a running program. where the main should find out how many galleons are from 100,000 knuts. : " Write a Java program using a class identified as Gringots.This Java class has a main, and the following protected member functions: Member function galleons2Sickles has an integer parameter value, and returns an integer value*17Member function sickles2galleons has an integer parameter value, and returns an integer value / 17Member function sickles2nuts has an integer parameter value, and returns an integer value*29Member function knuts2sickles has an integer parameter value, and returns an integer value/29 Member function Galleons2Knuts has an integer parameter value, and then uses member functions Galleons2Sickles and Sickles2Knuts to convert, and then returns the integer. Member function Knuts2Galleons has an integer parameter value, and then uses member functions Knuts2Sickles and Sickles2Galleons to convert, an dthen returns the…Help write the code for the follwing problem starting from scratch Write a complete C++ program in three files here that asks the user to enter a radius for a circle then calculates and prints its' area. The area should be calculated using the formula area = 3.14 * radius * radius. You must have a class called Circle that stores the radius as a double value and can calculate its' own area via a method called calcArea that takes no parameters and returns the area. The circle class may not print the area or radius! Hint: calcArea should take no parameters and return a double. For this version, make radius private and write setter (mutator) and getter (accessor) methods and/or constructors as needed to modify (set) and retrieve (get) the value of radius. Input Validation: If a negative radius is passed to an object of the Circle class, whether through a setter or a constructor, set the radius to 0 instead of using the negative value. This program MUST be split into three files: Header…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…
- IN C++, Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables - a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. Provide a set and a get method for each instance variable. In addition, provide a method named getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a double value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to0. Write a test app named InvoiceTest that demonstrates class Invoice's capabilities.URGENT FOR JAVA Write a class about a book which has following properties: • isbn • price • titleIn a Test class we are supposed to create objects as below: Book b1= new Book(); Book b2= new Book(544444, “Java”); Book b3= new Book(54444444, C++, 5.6); Book b4= new Book (“Python, 7.9, 8888899988); and we are supposed to print objects with the following statement: 5. System.out.println(b3); The the output should be:“Title of the book is C++, ISBN is 54444444”, price is 5.6 TL Now complete the Book class that enable to execute statements that mentioned in the Test class. Except the 5 items that mention above, please test: 6. Test the f(n) with 2 different numbers 7. Update the price of the b4 object.8. Test the Q3 method.Here _Class ja URGENT FOR JAVA Write a class about a book which has following properties: • isbn • price • titleIn a Test class we are supposed to create objects as below: Book b1= new Book(); Book b2= new Book(544444, “Java”); Book b3= new Book(54444444, C++, 5.6); Book b4= new Book (“Python, 7.9, 8888899988); and we are supposed to print objects with the following statement: 5. System.out.println(b3); The the output should be:“Title of the book is C++, ISBN is 54444444”, price is 5.6 TL Now complete the Book class that enable to execute statements that mentioned in the Test class. Except the 5 items that mention above, please test: 6. Test the f(n) with 2 different numbers 7. Update the price of the b4 object.8. Test the Q3 method. of n in enable. .