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
Colt1911 [192]
3 years ago
9

Consider the following statements: #include #include class Temporary { private: string description; double first; double second;

public: Temporary(string = "", double = 0.0, double = 0.0); void set(string, double, double); double manipulate(); void get(string&, double&, double&); void setDescription(string); void setFirst(double); void setSecond(double); }; Write the definition of the member function set() so that the instance variables are set according to the parameters. Write the definition of the constructor so that it initializes the instance variables using the function set() Write the definition of the member function manipulate() that returns a decimal number (double) as follows: If the value of description is "rectangle", it returns first * second If the value of description is "circle" it returns the area of a circle with radius first if the value of description is "cylinder" it returns the volume of a cylinder with radius first and height second. HINT: the volume of a cylinder is simply the area of the circle at the base times the height. If the value of description is "sphere" it returns the volume of the sphere with radius first. Otherwise it returns -1.0;
Computers and Technology
1 answer:
Anna007 [38]3 years ago
6 0

#include <iostream>  

#include <iomanip>  

using namespace std;  

class temporary  

{  

public:  

void set(string, double, double);  

void print();  

double manipulate ();  

void get (string&, double&, double&);  

void setDescription(string);  

void setFirst(double);  

void setSecond(double);  

string getDescription() const;  

double getFirst () const;  

double getSecond () const;  

temporary(string = "", double = 0.0, double = 0.0);  

private:  

string description;  

double first;  

double second;  

};  

void temporary::set(string a, double dblA, double dblB)  

{  

description = a;  

first = dblA;  

second = dblB;  

}  

void temporary::print()  

{  

cout << "\nDescription: " << left << setw(20) << description << endl <<  

" first: " << fixed << setw(10) << setprecision(2) << first << endl <<  

" second: " << fixed << setw(10) << setprecision(2) << second << endl;  

}  

double temporary::manipulate()  

{  

return first / 3.0 + second / 4.0;  

}  

void temporary::get(string& strDesc, double& dblFirst, double& dblSecond)  

{  

strDesc = description;  

dblFirst = first;  

dblSecond = second;  

}  

temporary::temporary(string d, double a, double b) : description(d), first(a), second(b) {}  

void temporary::setFirst(double dblFirst){first = dblFirst;}  

void temporary::setSecond(double dblSecond){second = dblSecond;}  

void temporary::setDescription(string desc){description = desc;}  

string temporary::getDescription() const {return description;}  

double temporary::getFirst () const{return first;}  

double temporary::getSecond () const {return second;}  

int main()  

{  

cout << "temporary a;";  

temporary a;  

a.print();  

cout << "a.setFirst(3.0): ";  

a.setFirst(3.0);  

a.print();  

cout << "a.setSecond(4.5): ";  

a.setSecond(4.5);  

a.print();  

cout << "a.setDescription(\"Picture Frame\") ";  

a.setDescription("Picture Frame");  

a.print();  

cout << "a.print(): ";  

a.print();  

return 0;  

}

You might be interested in
class secretType { public: static int count; static int z; secretType(); secretType(int a); void print(); static void incrementY
DanielleElmas [232]

Answer:

The answer to this question can be given as:

In this class definition, there are two constructors.  

Explanation:

In the class definition two constructors are different in type but first we explain constructor that can be as:

Constructor: constructor are special member functions whose task is to initialized as an object of its class.

Rule for defining constructor:

A constructor doesn’t have a return type not even void.

The name of the constructor must be the same as the class name.

A constructor is called automatically when a new instance of an object is created.

Type of constructor:

  1. default constructor.
  2. parameterized constructor.
  3. copy constructor.

In the question there are two type of constructor is used that can be given as:

default constructor:  

The constructor without any parameters is called a default constructor. This type of constructor is called automatically when a new instance of an object is created.

parametrized constructor:

In the parameterized constructor we use at least one parameter in the constructor that is called the parameterized constructor. In the parameterized constructor we can initialize each instance of the class with several values.

Example :

class AB   //define class  

{  

   String name; //define variable

   AB()   //default constructor

   {

   System.out.print("hello...");  //message.

   }

   AB(String name)  //parametrized constructor.

   {  

       this.name = name;  //holding value in name variable.

   }  

}  

class Main  //define class

{  

   public static void main (String[] args)  //main method  

   {  

   AB OB1 =new AB();   //creating class object.

   AB ob2=new AB("XYZ");

   System.out.print(ob2.name);  //print value

   }  

}

Output:

hello... XYZ

5 0
3 years ago
How will 5G technology affect the current classroom? What are some concerns about 5G technology? Is 5G technology worth the risk
notsponge [240]

Answer:Death is a risk of 5g towers

Explanation:Someone caught a video of birds falling dead out of the sky because of the radiation from the 5g towers. There is enough radiation to make your eyes melt before you get close to it.

4 0
3 years ago
#Write a function called find_median. find_median #should take as input a string representing a filename. #The file correspondin
azamat

Answer:

Explanation:

The following is written in Python. It takes in a file, it then reads all of the elements in the file and adds them to a list called myList. Then it sorts the list and uses the elements in that list to calculate the median. Once the median is calculated it returns it to the user. The code has been tested and the output can be seen in the image below.

def find_median(file):

   file = open(file, 'r')

   mylist = []

   for number in file:

       mylist.append(int(number))

   numOfElements = len(mylist)

   mylist.sort()

   print(mylist)

   if numOfElements % 2 == 0:

       m1 = numOfElements / 2

       m2 = (numOfElements / 2) + 1

       m1 = int(m1) - 1

       m2 = int(m2) - 1

       median = (mylist[m1] + mylist[m2]) / 2

   else:

       m = (numOfElements + 1) / 2

       m = int(m) - 1

       median = mylist[m]

   return median

print("Median: " + str(find_median('file1.txt')))

5 0
3 years ago
A service provider recently upgraded one of the storage clusters that houses non-confidential data for clients. The storage prov
VARVARA [1.3K]

Answer:

<em>C. Purging</em>

<em></em>

Explanation:

<em>Data Purging in computer storage is a process that permanently erases and remove data from a storage space</em>.  Data deleting only removes the shortcut to the data but does not remove the data permanently, and can be easily recovered by an expert. <em>Data purging removes data permanently and also frees up the storage or memory space for other uses.</em> Data purging is relatively inexpensive and can be achieved with some special software tool.

Since the storage provider wants the hard drive back in working condition, data purging is the best option.

3 0
3 years ago
ABC Manufacturing Company is located in Hiroshima, Japan. Being prone to earthquakes, the company decided to implement a backup
maxonik [38]

The command interface protocol that I would suggest to the IT administrator is Secure Shell (SSH).

<h3>What is a command interface protocol?</h3>

A command interface protocol can be defined as a standard protocol that is designed and developed to processes commands in the form of lines of text to a software program that is installed on a computer system.

<h3>The types of command interface protocol.</h3>

In Computer technology, there are different types of command interface protocol and these include:

  • SSL
  • TLS
  • SSH

SSH is an acronym for Secure Shell and it is a standard network protocol that gives a IT administrator a secure way to access data over an unsecured network, especially when backing up data.

Read more on SSH here: brainly.com/question/17147683

7 0
1 year ago
Other questions:
  • You can encrypt individual files, but microsoft recommends encrypting at what level?
    9·1 answer
  • As a load is mechanically lifted, the materials ____________________.
    7·1 answer
  • "Write code that prints: Ready! countNum ... 2 1 Start! Your code should contain a for loop. Print a newline after each number a
    7·1 answer
  • Write a Python program calculate summary statistics about a class assignment. First, prompt the user for the number scores to be
    6·1 answer
  • Do the shape of a sign gives you a clue about the information contained on the sign
    7·1 answer
  • C++ Question (if and while loops)
    7·1 answer
  • Describe how catching exceptions can help with file errors. Write three Python examples that actually generate file errors on yo
    12·1 answer
  • You have $5 and earn $1.75 for each roll of wrapping paper you sell. Write an equation in two variables that represents the tota
    12·1 answer
  • What would be the best tool to display the following information from a basketball game?
    6·1 answer
  • The format that you will use on your works cited page when the entry is longer than one line is__________.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!