1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
solong [7]
3 years ago
7

Implement a class Rectangle. Provide a constructor to construct a rectangle with a given width and height, member functions get_

perimeter and get_area that compute the perimeter and area, and a member function void resize(double factor) that resizes the rectangle by multiplying the width and height by the given factor
Computers and Technology
1 answer:
Luba_88 [7]3 years ago
3 0

Answer:

Explanation:

The following code is written in Java. It creates the Rectangle class with the height and width variables. The constructor takes these variables as parameters to create Rectangle objects. It creates the get_perimeter method that sums up two of each side in order to get the perimeter of the Rectangle. A get_area method multiplies the height by the width to get the area. Finally, a resize method takes in a double factor variable and multiplies the height and the width by the factor to get a resized Rectangle object.

class Rectangle {

   double height, width;

   public Rectangle(double height, double width) {

       this.height = height;

       this.width = width;

   }

   

   public double get_perimeter() {

       return (this.height + this.height + this.width + this.width);

   }

   

   public double get_area() {

       return (this.height * this.width);

   }

   

   public void resize(double factor) {

       this.height *= factor;

       this.width *= factor;

   }

}

You might be interested in
Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in
Zina [86]

Answer:

Here is the C++ program:

#include <iostream> // to include input output functions

using namespace std; // to identify objects like cin cout

int counter(string userString, char character) { //function counter

   int count = 0;   // counts the no of times a character appears in the string

   for (int i=0;i<userString.length();i++)  

// loop to move through the string to find the occurrence of the character

       if (userString[i] == character) //if characters is found in the string

           count++;   //counts the occurrence of the character in the string

   return count; }   //returns the no of times character occurs in the string

int main() { //start of the main() function body

   string s; // stores the string entered by the user

   cout<<"Enter a string: "; //prompts user to enter the string

   cin>>s; //reads the string from user

   char ch; //stores the character entered by the user

   cout<<"Enter a character: "; //prompts user to enter a character

   cin>>ch; //reads the character from user

   cout << counter(s, ch) << endl; }  

//calls counter function to find the number of times a character occurs in the //string

Explanation:

The counter function works as following:

It has a count variable which stores the number of occurrences of a character in the userString.

It uses a for loop which loops through the entire string.

It has i position variable which starts with the first character of the string and checks if the first character of userString matches with the required character.

If it matches the character then count variable counts the first occurrence of the character and in the userString and is incremented to 1.

If the character does not match with the first character of the userString then the loops keeps traversing through the userString until the end of the userString is reached which is specified by the length() function which returns the length of the string.

After the loop ends the return count statement is used to return the number of occurrences of the character in the userString.

The main() function prompts the user to enter a string and a character. It then calls counter() function passing string s and character ch arguments to it in order to get the number of times ch appears in s.

The output is attached in a screenshot.

6 0
3 years ago
Let PALINDROME_DFA= | M is a DFA, and for all s ∈ L(M), s is a palindrome}. Show that PALINDROME_DFA ∈ P by providing an algorit
denis-greek [22]

Answer:

Which sentence best matches the context of the word reticent as it is used in the following example?

We could talk about anything for hours. However, the moment I brought up dating, he was extremely reticent about his personal life.

Explanation:

Which sentence best matches the context of the word reticent as it is used in the following example?

We could talk about anything for hours. However, the moment I brought up dating, he was extremely reticent about his personal life.

8 0
2 years ago
A _______ is used to analyze and summarize your data without graphical support. A. PivotChart B. PivotTable C. chart D. table
Norma-Jean [14]
B. pivot table................................................
3 0
3 years ago
The instructions in a program ...
JulsSmile [24]

Answer:

The instructions in a program can only be expressed using a programming language

7 0
2 years ago
How many values will the user submit each time this form is used? Color: RedBlueGreen Quantity:
e-lub [12.9K]

Answer:

2

Explanation:

User submit quantity 2. with Color : Red Blue Green

7 0
3 years ago
Other questions:
  • Use blank to prevent friends who have been drinking from driving
    14·2 answers
  • 4. When you're working with a word processing document and you press the Del key, what happens?
    8·2 answers
  • Which command can be used to manually add a package to the driver store?
    13·1 answer
  • The following algorithm computes the average height for a list of basketball player heights. Initialize a variable sum to 0. For
    11·2 answers
  • How can you autohide the taskbar in Windows 10?
    8·2 answers
  • PLEASE HELP QUICK WILL GIVE BRAINLY
    6·1 answer
  • Gemima wants to order the different kinds of food alphabetically on the table. Which actions should she take? Check all that app
    8·2 answers
  • How would you describe the relationship between blocks of code and commands?<br>HELP​
    10·1 answer
  • Question No. 5:
    7·1 answer
  • Tamara is writing a program to organize students in a class and needs to use operators to organize student grades, then compare
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!