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
im doing this last minute and literally none of my neighbors or people that my dad works with use excel so if anyone could help
notsponge [240]

Example #1: My mom uses excel to write down all the groceries that she is keeping track of.

Example #2: My dad uses excel to write down the ammount of time he spends with my brothers.

I hope this helps!!!!

7 0
3 years ago
____________________-control statements allow you to determine the order in which statements execute in a program.
Olin [163]

Answer:

Selection Control Statement

Explanation:

The three basic types of control structures are sequential, selection and iteration.

1. Sequential is the default control structure, statements are executed line by line in the order in which they appear.

2. The selection structure is used to test a condition. A sequence of statements is executed depending on whether or not the condition it true or false. This means the program chooses between two or more alternative paths. Condition refers to any expression or value that returns a Boolean value, meaning true or false.

The iteration or repetition structure repeatedly executes a series of statements as long as the condition is true. The condition may be predefined or open-ended. "While," "do/while" and "for" loop are the three types of iteration statements. 3. A loop can either be event controlled or counter controlled. An event-controlled loop executes a sequence of statements till and event occurs while a counter-controlled loop executes the statements a predetermined number of times.

8 0
3 years ago
Def area(length, height):
Basile [38]

Following are the <em><u>python complete code </u></em>to calculate the area:

Program Explanation:

  • Defining a method "area" that takes two variables "length, height" in the parameters.
  • Inside the method, a variable "area" is declared that calculates the area by multiplies "length and width".
  • After calculating the area a return keyword is used that returns its value.
  • Outside the method, a print method is declared that calls the area method by accepting value into its parameters.

Program:

def area(length, height):#defining a method area that takes two parameters "length, height"  

  area = length * height#defining a variable area that calculates the area by multiplies length and width  

  return area#using return keyword that returns area value  

print(area(9,8))#using a print method that calls area method by accepting the value  

Output:

Please find the attached file.

  • <u>In this code, the </u><u>method call</u><u> is missing therefore, the final answer is</u> "Option A".

Learn more:

brainly.com/question/24819022

6 0
1 year ago
Write a function to compute the Affine cipher. The input parameters for the function will be a, b, m and the plaintext. The func
Anettt [7]

Answer:

//CPP program to illustate Affine Cipher  

 

#include<bits/stdc++.h>  

using namespace std;  

 

//Key values of a and b  

const int a = 17;  

const int b = 20;  

 

string encryptMessage(string msg)  

{  

   ///Cipher Text initially empty  

   string cipher = "";  

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

   {  

       // Avoid space to be encrypted  

       if(msg[i]!=' ')  

           /* applying encryption formula ( a x + b ) mod m  

           {here x is msg[i] and m is 26} and added 'A' to  

           bring it in range of ascii alphabet[ 65-90 | A-Z ] */

           cipher = cipher +  

                       (char) ((((a * (msg[i]-'A') ) + b) % 26) + 'A');  

       else

           //else simply append space character  

           cipher += msg[i];      

   }  

   return cipher;  

}  

 

string decryptCipher(string cipher)  

{  

   string msg = "";  

   int a_inv = 0;  

   int flag = 0;  

     

   //Find a^-1 (the multiplicative inverse of a  

       //in the group of integers modulo m.)  

   for (int i = 0; i < 26; i++)  

   {  

       flag = (a * i) % 26;  

         

       //Check if (a*i)%26 == 1,  

               //then i will be the multiplicative inverse of a  

       if (flag == 1)  

       {  

           a_inv = i;  

       }  

   }  

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

   {  

       if(cipher[i]!=' ')  

           /*Applying decryption formula a^-1 ( x - b ) mod m  

           {here x is cipher[i] and m is 26} and added 'A'  

           to bring it in range of ASCII alphabet[ 65-90 | A-Z ] */

           msg = msg +  

                      (char) (((a_inv * ((cipher[i]+'A' - b)) % 26)) + 'A');  

       else

           //else simply append space characte  

           msg += cipher[i];  

   }  

 

   return msg;  

}  

 

//Driver Program  

int main(void)  

{  

   string msg = "AFFINE CIPHER";  

     

   //Calling encryption function  

   string cipherText = encryptMessage(msg);  

   cout << "Encrypted Message is : " << cipherText<<endl;  

     

   //Calling Decryption function  

   cout << "Decrypted Message is: " << decryptCipher(cipherText);  

 

   return 0;  

}  

8 0
3 years ago
Write matlab programs to convert the following to binarynumbers.
Aleks04 [339]

Answer:

decimal_no = 23;

binary_no = dec2bin(decimal_no);

matlab answer=10111  /*it is a string in matlab*/

now you just have to change the values of decimal_no

On putting 87

the answer is 1010111

On putting 378

the answer is 101111010.

On putting 2388

the answer is 100101010100.

Explanation:

We have used the inbuilt function in matlab dec2bin(decimal Number) it returns the binary number as a string.

4 0
2 years ago
Other questions:
  • Write a C++ program that prompt the user to enter three points (x1, y1), (x2, y2), (x3,y3) of a triangle and
    14·1 answer
  • You are testing a site and realize that when you click a graphic link you see an outline but no picture. What is wrong with the
    5·1 answer
  • A user contacted the help desk to report that the laser printer in his department is wrinkling the paper when printed. The user
    5·1 answer
  • When pasting text and tables,which of these paste options is generally available
    9·1 answer
  • Which of the operating systems listed below was the last to be released
    8·1 answer
  • Suppose you are an ad-serving company and you maintain a log of cookie data for ads you serve to the Web pages for a particular
    14·1 answer
  • 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
    6·1 answer
  • Write a SELECT statement that returns these columns from the Orders table: The CardNumber column The length of the CardNumber co
    12·1 answer
  • An electronic ____ is an application you use to perform numeric calculations and to analyze and present numeric data.
    9·1 answer
  • David plays racing games on his way to work. He uses the analog stick to navigate his vehicle through other artificial intellige
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!