Which of the following compiles without a problem? Why? a. product.discount = 20; b. product.setDiscount(20); c. product.setPrice(50);
Q: please make it run using static System.Console; class GreenvilleRevenue { static void Main()…
A: Given Code:- using static System.Console; class GreenvilleRevenue { static void Main() {…
Q: True or false ? Assuming class Quiz { public: void TakeIt ( ); }; Quiz cs2b_quiz; Quiz * p_quiz…
A: class Quiz { public: void TakeIt ( ); }; Quiz cs2b_quiz; //declare cs2b_quiz Quiz * p_quiz =…
Q: class Animal { public String toString() { return "Animal"; } public String f() { return "Animal f";…
A: The solution is provided in the next step.
Q: Make the classes as mentioned above. Make appropriate constructors and functions. Choose access type…
A: The given problem is to be solved using the concept of Object-Oriented Programming where multiple…
Q: Name at least TWO class functions you should add/code for the dynamic data in this class. (HINT:…
A: a) We need to have two functions namely - copy constructor (dynamicClass(const dynamicClass& c)…
Q: DATA STRUCTURES Complexity Analysis 1. Review the defined methods below and write a simplified…
A: In the code given, replace all &lt and &gt with < and > respectively. Defining the…
Q: Given the following code segments: class Programme{ b) private String name; private static int…
A: To Do: To write the above class in better design and pattern.
Q: JAVA Language Caesar Shift Question: Modify the Caesar class so that it will allow various…
A: Algorithm: Caesar Cipher1. Create an abstract class called Cipher. a. Define an abstract method…
Q: * CENGAGE | MINBTAP Programming Exercise 3-10 D Instructions + JobPricing.java 1 import…
A: import java.util.Scanner; public class JobPricing { public static void main(String[] args) {…
Q: Consider the following code: public class DemoClass{ private double PI = 3.1416; void…
A: class DemoClass{ final private double PI = 3.1416; // Use final such that PI can not be modified…
Q: This is C++ Virtual Functions Please use comment lines to show what each line will do and how.…
A: Include the necessary header file for input/output stream operations. Add the using namespace std;…
Q: Create a class called Employee that includes three data members: a first name (type string), a last…
A: Consider given monthly salary as x The yearly salary can be calculated as y_x = 12*x Now, giving 10%…
Q: The following class declaration has errors. Locate as many as you can. class Yard{private:double…
A:
Q: different packages, while in the previous were in the same package. package package_02; public class…
A: 2.1). , the output will be "1" As the other variables y and z will not be visible in the class A as…
Q: In C++ QUESTION 14 class rectangleType { public: void setLengthWidth(double x, double y);…
A: In order to write and test the function definition of perimeter we also need to write the function…
Q: main() function is given below. Based on this function, your task is to write complete code required…
A: A main() function is given below. Based on this function, your task is to write complete code…
Q: b) Given the following code segments: class Programme{ private String name; private static int…
A: A class is contains two types of members. Data members and methods.
Q: Java Programming: Make sure to have parsing statements for parseFor(), parseWhile(), parseIf(),…
A: Coded using Java.
Q: Consider the following code. public class Test { public static void main(String[] args){ NClass nc =…
A: To do: Given MCQ
Q: Consider the following code segment and answer questions 14 and 15. class Point { public: Point…
A: A constructor is a unique method or function used in object-oriented programming that is invoked…
Q: Smoothie constructor should accept a list of ingredients. • Should not be empty => throw…
A: The completed code is given below: using System.Collections.Generic;using System;using…
Q: Problem 3: id: String name: String balance: double Account + Account (id: String, name: String) +…
A: According to the information given:- We have to follow the instruction mentioned in order to get…
Q: Please fill in all the code gaps if possible: (java) public class valueData { private String…
A: Your java code is given below as you required.
Q: write a C++ program Use the definition of Product and order structs and the definition of the…
A: the code is an given below : #include <iostream> using namespace std; // structure to…
Q: Programming language Sliding tiles The mechanics described in this exercise can be used…
A: It is defined as a general purpose programming language with an emphasis on expressiveness and…
Q: public static void main(String [] args) { // Step 2: Construct a Day object representing today and…
A: As per the given problem, we need to perform steps 2 to 9 in Java thereby completing the java…
Q: In C++ or pyhton Design and code a class as described in the following diagram BankAccount…
A: The solution is done using C++. Please refer to the following step for the complete solution to the…
Q: Python Need help with code A rule has three parts: •name –a simple name for the rule (e.g., up,…
A: The bоаrd is а 4x4 grid with fifteen tiles (numbered 1 thrоugh 15 gоing left tо…
Q: Computer Science Need Debugging following these guidelines: program produces correct output…
A: The errors has been removed from the existing code.
Q: Computer Science c++ help comment code please. Complex has multiple parameters to overload i think.…
A: The given class Complex has 2 private attributes real and complex The class has default constructor,…
Q: 25 + BaseAmount; baseAmount+baseAmount; baseAmount = 2 * baseAmount; BaseAmount + 25;
A: which one of the following operations is not legal? 25 + BaseAmount; baseAmount+baseAmount;…
Q: Carefully understand the code given bellow. Analyze the code and suggest any corrections needed with…
A: Correct C++ code: #include <iostream>using namespace std; class Student { //data members…
Q: Problem 1) The following Java Code class is given public class Point { private int xCor; private int…
A: public class Point { private int xCor; private int yCor; public Point(int x,int y) { this.xCor=x;…
Q: Program 2: The driving class CarTest public class CarTest { ||--- // Creates and exercises some Car…
A: Please refer to the following step for the complete solution to the problem above.
Q: please fix what is wrong with the below C# code:
A: 1. In your code the checkGuess function should be separate from main function 2. Main function…
Q: Nutritional information (classes/constructors) PYTHON ONLY Complete the FoodItem class by adding a…
A: Given: Complete the FoodItem class by adding a constructor to initialize a food item. The…
Q: 4. Write part of the code that removes the car from the dealer class that is sold.
A: // part 4:- function to remove class from dealer class public void removeCar() { // delete current…
Q: Analysis the following class definition and answer the following question. class Store{…
A: Here the modifier of the amount is of double data type. And it is protected.
2- Consider the following program:
public class Product
{ private int price;
public void setPrice(int theprice)
{
price = thePrice;
}}
public class SpecialProduct extends Item
{ private int discount;
public void setDiscount(int theDiscount)
{
discount = theDiscount;
}}
public class Main{
public static void main(String[]args){
SpecialProduct product = new SpecialProduct();
}}
Which of the following compiles without a problem? Why?
a. product.discount = 20;
b. product.setDiscount(20);
c. product.setPrice(50);
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
- Please examine the C++ code and make corrections please. ##include<bits / stdc++.h> using namespace std; //employee class class Employee { private: //fields string name, address, phone; double payRate; public: //cosntructors Employee() {} Employee(string n, string a, double p, string ph) { name = n; address = a; payRate = p; phone = p; } //accessors string getName() { return name; } string getAddress() { return address; } string getPhone() { return phone; } double getPayRate() { return payRate; } //setters void setName(string n) { name = n; } void setAddress(string a) { address = a; } void setPhone(string ph) { phone = ph; } void setPayRate(double pr) { payRate = pr; } }; //employee directory class class EmployeeDirectory { private: //all employees are added into this vector vector<Employee> employees; public:…Finish the Java code: Code: class Tile{char letter;int value; //ConstructorTile(char l, int v){letter = l;value = v;} //The function returns value of data member value.public int getValue(){return value;}//The function returns value of data member letter.public char getLetter(){return letter;} //the function return string for value and letterpublic String toString(){return(letter + " with value " + value);} //The function checks for equality of two objects.public boolean equals(Tile t){if(this.letter == t.letter && this.value == t.value)return true;elsereturn false;} } Output: The word HELLO is worth 8 points Its tile with the highest value is: H with value: 4 You have used a total of 5 tiles so far.class implementation file -- Rectangle.cpp class Rectangle { #include #include "Rectangle.h" using namespace std; private: double width; double length; public: void setWidth (double); void setLength (double) ; double getWidth() const; double getLength() const; double getArea () const; } ; // set the width of the rectangle void Rectangle::setWidth (double w) { width = w; } // set the length of the rectangle void Rectangle::setLength (double l) { length l; //get the width of the rectangle double Rectangle::getWidth() const { return width; // more member functions here
- Problem 4) Suppose the following Course class is given: public class Course { private String name;//such as CS, MATH, etc private int grades[];//list of the grades //default and initial valued constructor //all other methods public double average() { double sum=0; for(int i=0;i=90) System.out.printf("me is a student with A letter-grade\n");**please see question attached** (previous program below) #include <iostream>using namespace std;class House{//instance variablesprivate:string location;int price; public://constructorsHouse(){location = "TBD";price = 0;}House(string location,int price){this->location = location;this->price = price;}//Get and set methodsvoid setLocation(string location){this->location = location;}string getLocation(){return location;}void setPrice(int price){this->price = price;}int getPrice(){return price;} };//member functionvoid output(House a){cout <<"Location: " << a.getLocation()<<endl;cout <<"Price: "<<a.getPrice()<<endl;}int main(){House a("1234 qcc st, Bayside, NY",1000000);output(a);House b;output(b); return 0;}Instructions-Java Assignment is to define a class named Address. The Address class will have three private instance variables: an int named street_number a String named street_name and a String named state. Write three constructors for the Address class: an empty constructor (no input parameters) that initializes the three instance variables with default values of your choice, a constructor that takes the street values as input but defaults the state to "Arizona", and a constructor that takes all three pieces of information as input Next create a driver class named Main.java. Put public static void main here and test out your class by creating three instances of Address, one using each of the constructors. You can choose the particular address values that are used. I recommend you make them up and do not use actual addresses. Run your code to make sure it works. Next add the following public methods to the Address class and test them from main as you go: Write getters and…
- (b) Find all the errors in the C++ code below: class Point { private: int x, y: public: Point(int x = 0, int y = 0); int getX() const; // Getters void setX(int x); // Setters void setY(int y); }; Point:: Point(int x, int y) : x(x), y(y) { } // Using initializer list // Getters int Point::getX() const { return x; } int Point::getY) const { return y; } // Setters void Point::setX(int x) { this->x = x; } void Point::setY(int y) { this->y = y; } // Public Functions void print() const { cout « "(" « x« "," « y « ")" « endl; // Member function overloading '+' operator void Point::operator+(Point rhs) const { return Point(x + rhs.x, y + rhs.y); int main() { Point p1(1, 2), p2(4, 5); // Use overloaded operator Point p3 = p1 + p2; p1.print(); // (1,2) p2.print(); / (4,5) p3.print(); / i5,7) Point p5 = p1 + p2 + p3 + p4; p5.print (); // (15,21) cout<c++ We wrote a program in Chapter 4 to find the day of the week for any given date using Zeller’s congruence: weekday = (day + 26 * (month + 1) / 10 + year + year / 4 − year /100 + year /400 ) % 7 To show that any program written in the procedural paradigm can be written in the object-oriented paradigm, design a class Zeller with three data members—day, month, and year—to find the corresponding week day (Saturday to Sunday).Remaining Time: 31 minutes, 51 seconds. ¥ Question Completion Status: What is the error in the below code? Provide your explanation. #include using namespace std; class parent{ private: int i, j; public: parent (int i, int j) class child: public parent { public void show(){ cout<<" i = "<Description: In a hypothetical class, students take two midterms and an optional final. If a student takes the final and gets in it a better score than the lowest of the two midterm scores, then the lowest midterm score would be replaced by the comprehensive final score. The overall score will then be calculated by averaging the three test scores. If the student does not take the optional final, the overall score is calculated using only the two midterm scores. Students’ exam scores are included in the “Question1” tab in the attached worksheet. Empty data entries for the optional comprehensive final means that the student did not take the optional final. Tasks: Task 1: In Question1_Module, code a function that requires midterm1 score, midterm2 score, and comprehensive final as inputs and calculate the overall score per the description above. Task 2: In Question1_Module, code a Sub that uses the function coded in task 1 to fill column ‘I’ of the worksheet and link this…C++ Language Create a UML Diagram for the Class Invoice with the provided code. Use <<constructor>> to define constructors, for each function's variable indicate whether it is a string or a integer. include <string> using namespace std; class Invoice{public:Invoice(string, string, int, int); void setPartNumber(string);string getPartNumber();void setPartDescription(string); string getPartDescription();void setQuantity(int); int getQuantity();void setPricePerItem(int); int getPricePerItem(); int getInvoiceAmount();private:string partNumber; string partDescription; int quantity; int pricePerItem; };Recommended textbooks for youDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag…Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill EducationDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag…Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education