C++ program that computes the area and perimeter of a specified shape
#include <iostream>
#include <cmath>
using namespace std;
void rectangle() //Defining function for rectangle
{ int h,w;
cout << "Enter height: ";
//taking input
cin >> h;
cout << "Enter width: ";
cin >> w;
cout << "The perimeter of the rectangle is " <<2*h+ 2*w << " and the area is " <<h*w << endl; //printing output
}
void triangle() //Defining function for triangle
{ int s1,s2,s3,h,w;
cout << "Side 1: "; //Taking input
cin >> s1;
cout << "Side 2: ";
cin >> s2;
cout << "Side 3: ";
cin >> s3;
cout << "Enter the height: ";
cin >> h;
cout << "Enter the base length: ";
cin >> w;
cout << "The perimeter of the triangle is " <<s1+s2+s3 << " and the area is " <<(.5)*w*h << endl; //printing output
}
void circle()//Defining Function for the circle
{
const double p=3.14;
int w;
cout << "Enter the radius: "; //Taking input
cin >> w;
cout << "The perimeter of the circle is " << p*2*w << " and the area is " << p*w*w<< endl; //printing output
}
int main() //driver function
{
int s;
cout << "Enter the shape (1 for rectangle,2 for triangle, 3 for circle): ";
//Asking user for the shape
cin >> s;
switch(s) //checking which shape it chooses
{
case 1:
rectangle(); //If user type 1 ,then calling rectangle function
break;
case 2:
triangle(); //If user type 2 ,then calling triangle function
break;
case 3:
circle(); //If user type 3,then calling circle function
break;
default:
cout <<"Enter valid choice for shape"; //If user type other than 1,2,3
}
return 0;
}
Output
Enter the shape (1 for rectangle,2 for triangle, 3 for circle): 1
Enter height:2
Enter width: 3
The perimeter of the rectangle is 10 and the area is 6
Write down the complete procedure for creating ExcelSheet.
Answer:
The complete procedure for creating Excel Sheet:
Excel sheets is defined as which are typically in tabs near the bottom left hand corner of the window, when a sheet gets open, it can only be viewed one at a time, however you can generated formulas and select the data from other sheets that can be used on another sheet's formula. Separated sheets are valuable for inserted separate charts and graphs, organizing the information from sheet.You are given three sheets with any new excel sheet.The default names are Sheet 1, Sheet 2, and Sheet 3 and are named on the tabs. These names can be changed accordingly by clicking on the tab name.We can also add the boundaries and label the rows.A final class can't be extended.
*True
*False
Answer:
The answer is True.
Explanation:
The final class cannot be extended because in java final keyword means "no modification". If it is applied to a variable or anything else then that value becomes a constant after that it cannot be modified.So in cases of class if final keyword is used it means that class cannot be extended.
Which window control button appears only when a window is maximized? ()
Maximize
Minimize
Restore
Close
Answer:
Restore
Explanation:
When the window is in minimized mode we get minimize, maximize, close buttons there.
When the window is in maximized mode we get minimize, restore, close buttons there.
A painting company has determined that for every 115 square feet or wall space, one gallon of paint and eight hours of labor will be required. The company charges $.18.00 per hour for labor . Write a program that allows the user to enter the number of rooms to be painted and the price of the paint per gallon. It should also ask for the square feet of wall space in each room. The program should have methods that return the following:
* The number of gallons of paint required
* The hours of labor required
*The cost of the paint
*The labor charges
*The Total cost of the paint job
The program to calculate the total paint cost and other values is given below.
#include <iostream>
using namespace std;
int main() {
int rooms, laborChrg = 18;
float paintChrg;
float feetPerRoom[rooms];
float paintReq, laborHrs, paintCost, laborCost, totalCost, totalsqft=0;
cout<<"Enter the number of rooms to be painted "<<endl;
cin>>rooms;
for(int i=0; i <= rooms; i++)
{
cout<<"Enter the square feet in room "<<endl;
cin>>feetPerRoom[i];
// shortcut operator which is equivalent to totalsqft = totalsqft + feetPerRoom[i];
totalsqft += feetPerRoom[i];
}
cout<<"Enter the cost of the paint per gallon "<<endl;
cin>>paintChrg;
laborHrs = (totalsqft/115)*8;
laborCost = laborHrs * laborChrg;
paintReq = totalsqft/115;
paintCost = paintReq * paintChrg;
totalCost = laborCost + paintCost;
cout<<"The number of gallons of paint required "<<paintReq<<endl;
cout<<"The hours of labor required "<<laborHrs<<endl;
cout<<"The cost of the paint is "<<paintCost<<endl;
cout<<"The labor charges are "<<laborHrs<<endl;
cout<<"The Total cost of the paint job is "<<totalCost<<endl;
return 0;
}
Explanation:
The header files for input and output are imported.
#include <iostream>
using namespace std;
All the variables are taken as float except labour charge per hour and number of rooms.
The user is asked to input the number of rooms to be painted. An array holds the square feet in each room to be painted.
cout<<"Enter the number of rooms to be painted "<<endl;
cin>>rooms;
for(int i=0; i <= rooms; i++)
{
cout<<"Enter the square feet in room "<<endl;
cin>>feetPerRoom[i];
totalsqft += feetPerRoom[i];
}
The above code asks for square feet in each room and calculates the total square feet to be painted simultaneously.
All the data to be displayed is calculated based on the values of labor charge per hour and gallons of paint needed, given in the question.
laborHrs = (totalsqft/115)*8;
laborCost = laborHrs * laborChrg;
paintReq = totalsqft/115;
paintCost = paintReq * paintChrg;
totalCost = laborCost + paintCost;
All the calculated values are displayed in the mentioned order.
Specialized vocabularyis known as:
o Equivocal terms
o Jargon
o Trigger words
o Biased language
Answer:
"Jargon"
Explanation:
Great question, it is always good to ask away and get rid of any doubts that you may be having.
Specialized vocabulary is sometimes also known as "Jargon" . These are sets of words that are used specifically and uniquely for specific sets of groups or organizations.
For example Lawyers Judges and other law enforcement officials have their own Specialized vocabulary that are better understood by other people in Law enforcement, people that are not part of Law Enforcement might have a hard time understanding.
I hope this answered your question. If you have any more questions feel free to ask away at Brainly.
Which method(s) must a serializable class, implement?
? It must always implement both readObject andwriteObject
? It must implement either readObject orwriteObject, or both, depending upon the
desired behavior
? No Need to implement any methods
? None of the given option is correct
Answer: None of the given option is correct
Explanation:
A serializable class is implemented, when an object is serializable interface. If you want to serialize one of your classes, then the class must implemented in the Serializable interface. To implement the serializable interface, convert a class into the series of bytes and when serializable object might reference your class. Serializable classes are useful when you wanted to persist cases of the class or send them over wire.
An interface does not have ____.
A) return types
B) instance fields
C) abstract methods
D) public methods
Answer:
B - instance fields
Explanation:
Fields/variables declared within interfaces are by default final, public or static and hence will not be considered as an instance variable/field but a class variable. Although interfaces can be used to define instance methods, they will never have instance variables.
Assuming deq is a deque object, the expression deq.push_front(elem) deletes the first element from deq.
True
False
Answer: False
Explanation:
This code code not deletes element from deq. This insert element at the beginning of deq. if it was deq.pop_front(elem) then it would have deleted the first element.
Therefore, it is false.
What are minimum numbers of pins required for serialcommunication? Also write
their names?
Answer:
Serial communication are connected using 2 types of connector
Explanation:
The two types of connector for serial communication are:
1. Nine pin connector.
2. Twenty five pin connector.
for 9 pin connector we have:
pin 1 = data carrier detect
pin 2= received data
pin 3= transmitted data
pin 4= data terminal ready
pin 5= signal ground
pin 6= data set ready
pin 7= request to send
pin 8= clear to send
pin 9= ring indicator
Here, the minimum number of pins can be pin 2,3 and 5 which are receive, transmit and ground signal to establish a communication without handshaking.
The minimum number of pins actually depend on the type of software we use.
Which of the following statements isNOT true about abstract data types (ADTs)?A list is anexample of an ADT.ADTs hide theimplementation details of operations from users.Java provides allthe ADTs you need, therefore you do not need to create any newones.An ADT is anabstraction of a commonly appearing data structure.
Answer:
Java provide all the ADTs you need,therefore you do not need to create any newones.
This statement is not true.
Explanation:
ADTs are those data types which we use but we didn't know their inner working that is how it is working what is happening inside.It is commonly used for Data Structures for example:- In stack we use push and pop operations to insert and to delete element from a stack respectively but we didn't know how it is happening inside.How the stack is implemented and etc.Java provides most of the ADT's but not all.
The statement that is wrong as regards abstract data types in this question is C: Java provides all the ADTs you need, therefore you do not need to create any new ones.
The abstract datatype can be regarded as special kind of datatype, whereby the behavior of the data is been defined by a set of values as well as a set of operations.ADTs can perform operation such as hiding of the implementation details of operations from users. It can be regarded as an abstraction of data structure that appear more oftenExamples of ADT are;
StackQueueListTherefore, option C is correct.
Learn more at:
https://brainly.com/question/23883878?referrer=searchResults
What is difference between rand() and srand() ?
Answer:
rand() function generate the random number within the range.
srand() function decide the starting point for random function or set the seed for rand() function.
Explanation:
rand() function which is used to generate the random number within the range.
srand() function is used to decide the starting point for random function.
In sort meaning, it set the seed for rand() function.
if srand() function not used, the random function generate the same output again and again because the starting point is fixed for generating the random number.
if srand() function used it change the starting point every time and random function generate the output different in every time.
Write matlab programs to convert the following to binarynumbers.
a) 23
b)87
c) 378
d)2388
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.
If you want a user to enter exactly 20 values, which loop would be the best to use?
1. do-while
2. while
3. for
4. infinite
5. None of these
Answer: For loop
Explanation:
Using the for loop we can get the exact number of values/outcomes we require.
For example: printf(enter 20 numbers");
for(int i=0; i<20;i++)
{
scanf("%d", &number);
}
So, this is an implementation of for loop in C. Using it we can enter exact 20 numbers not less or more than that.
Therefore, for loop is the answer.
The for loop is the best choice when you want to run a loop a known amount of times. In this specific example, you can use the for loop to gather 20 pieces of user input.
Explanation:If you want a user to enter exactly 20 values, the best loop to use would be the for loop. The for loop is specifically designed for situations where we know in advance how many times the loop needs to execute. In this case, we know the loop needs to execute exactly 20 times to accept 20 input values from the user, so using a for loop would be the most appropriate choice.
Here's an example of how you can structure a for loop in this situation:
for(int i = 0; i < 20; i++) {
// User input code here }
This loop will run 20 times, allowing you to gather 20 pieces of user input.
Learn more about For Loop here:https://brainly.com/question/32789432
#SPJ6
Which ofthe following sentence beginnings would be best to use in apersuasive request?
a- We think it would begood if you . . .
b- We need you to give . ..
c- Will you please . . .?
d- It would be appreciatedif you....
Answer:
d- It would be appreciated if you...
Explanation:
Persuasive request
It is a request to change one's belief,attitude by the help of the written submission like letter etc.
There are three components-
Opening-Start with something different like quotes or greeting etc.
Body-It include main thing to focus on it.
Closing-It is the reminder of the appeal.
b We need you to give .. c- Will you please . . .? These two are directly going for the change(body),we will eliminate these.
a- We think it would be good if you . . . ,it is also approaching the result and we are using 'WE' so we can also eliminate this.
d- It would be appreciated if you....,In this we are starting with greeting. So it is a persuasive request.
. Where is the bootstrap program usually located?
Answer and Explanation:
The bootstarp loader is also know as bootstrapping a bootstrap loader is usually located in EPROM (erasable programmable read only memory). It is a non volatile memory. The booststrap loader is automatically exicuted by the processor when we turn on the computer.Non volatile memory is that memory in which retain their content even when the power is swithed off.
Answer: Bootstrap program is generally found in the ROM (read only memory) else EEPROM (Electrically erasable programmable read-only memory)
Explanation:Bootstrap loader or program is referred as the program that gets into action or execution when there is the rebooting process in the operating system and it initializes it. It is usually located in EEPROM of the system. After the restarting of the computer system , all the loaded data gets transferred into the RAM(Random access memory).
Mergesort uses the divide-and-conquer technique to sort a list.
True
False
Answer:
True: Merge Sort sorts a list using divide-conquer approach.
Merge_Sort(B,p,n) //p is the starting index of array B and n is the last index.
1. if(p<n)
2. q ← (p+n)/2 //divides the list into two sub-lists
2. Merge_Sort(B, p, q) //sorts the left half
3. Merge_Sort(B, q+1, n) //sorts the right half.
4. Merge(B, p, q, n)
Merge(B, p, q, n)
1.l ← q-p+1. //no. of elements in left half
2.m ← n-q //no. of elements in right half.
3.for x ← 1 to l
4. Left[x] = B[p+x -1] //The elements of left half are copied to Left array
5.for y ← 1 to m.
6. Right[y]= B[q+y] //The elements of right half are copied to right array
7. x ← 1, y ←1
8.for z ← p to n.
9. if( Left[x] ≤ Right[y] ) // to merge the two lists Left and Right, the //elements are compared.
10. { A[z] ← Left[x] //smaller one comes to the merged list.
11. x++. }
12. else
13. { A[z] ← Right[y]
14. y++ }
Explanation:
The Merge_Sort(A, p, n) algorithm first divides the whole array into two halves. Then again divides the sub-lists into it's halves and so on.
Then using merge algorithm it compares the elements of both halves one by one and keep it in sorted order.
Memory cache is referred to as ______. A. SRAM c. SROM b. DRAM d. DROM
Answer:
Answer is A. SRAM
Explanation:
Memory cache is called static RAM.
prove that the dual of the exclusive-OR gate is also itscomplement
Answer:
Explanation:
The dual of a function means replace AND with OR and replace OR with AND.
XOR gate of A , B is
[tex]A \, XOR\, B = AB' + A'B[/tex]
So, Dual of A XOR B is ( replace AND with OR and OR with AND)
[tex]= (A+B')(A'+B)[/tex]
Complement of A XOR B is [tex](A XOR B) ' = (AB' + A'B) ' = ((A)' + (B')') ((A')' + (B)') = (A'+B)(A+B')[/tex] (In finding compliment AND becomes OR and OR becomes AND ).
By inter changing the above product of terms
Complement of [tex]A XOR B = (A + B') (A' + B)[/tex]
So, Dual of A XOR B = Complement of A XOR B.
Explain the following terms in a sentence or two in C++context.a)Orthogonalityb) Expresibilityc) Language domain andparadigmd)Portability
Answer:
a)Orthogonality
IBM C++ implements compatibility characteristics at the C 99 language stage and with GNU C language extensions to maintain compatibility as a super-set of C. IBM C++ also promotes a subset of C++ GNU extensions. Like the IBM C language extensions, the orthogonal and non-orthogonal language functions of the C++ extensions.
b) Expresibility
Expresibility relates to what can be said in the language of regular expression, most lex generators enable sets of letters, Kleene star(Vˣ) and plus, and alternation. Consider what happens if you have C++ with embedded assembly code: the C++ code is likely to belexer under one set of rules, and the management of lexical mode indicates how control can be transferred from one mode to another.
c) Language domain and paradigm
C++ is a programming language that promotes multiple paradigms, including classes, overloaded features, templates, modules, and more.
Using C++ wealthy collection of over-loadable operators as a domain-specific language, a category representing a matrix could overload multiplication(*) and other arithmetic operators, enabling implementation codes to be handled similarly to the numerical sort.
d) Portability
C++ includes the entire variety from low-level to high-level programming, making it ideal for composing portable software, but in embedded systems engineering code portability is often overlooked. With software becoming increasingly complicated, and hardware becoming increasingly interchangeable, this supervision becomes a issue when software has to be transported to a new platform.
____ is the encapsulation of method details within a class.
a.
Implementation hiding
b.
A calling method
c.
Instantiation
d.
An interface
Implementation hiding is the encapsulation of method details within a class. Implementation can be interpreted as those specifications which can be altered without altering the correctness of an application. Wrapping data/methods within classes (descriptions of the way all objects of this type will look/act) in combination with implementation hiding is called encapsulation. Information users need to know about behaviors should be available without dependence on implementation specifications.
Why do we need the binary system?
Answer:
We need to have binary numbers because that is how computers process data.
Explanation:
Please briefly describe your QA / testing process?
Answer: The QA/Testing process consist of the following:
1. Requirement specification
2. Reviewing the code.
3. Unit testing
4. Integration test
5. Performance testing
Explanation:
We start of by the requirement specification try to gather all the information accurately. Then begins the coding process where there is review of the code so that they perform their desired purpose. After modules are completed we perform unit testing of the different modules individually and also do the integration testing once all the modules are completed. At the end we perform the performance testing to take a note on their desired output and other quality parameters.
Write a C++ programthat reads in the side of a square and prints out a pattern on$
symbols representing thatsquare. The program should work for side sizes between
2 and 10. For example, ifa size of 4 is entered, the following output should be
produced:
$$$$
$$$$
$$$$
Answer:
#include<iostream>
using namespace std;
//main function
int main(){
//initialize the variables
int side;
//print the message
cout<<"Please enter the side of square: ";
cin>>side; //read the vale and store in the variable.
// for loop
for(int i=1;i<=side;i++){ //lop for rows
for(int j=1;j<=side;j++){ //loop for column
cout<<"$"; //print the '*'
}
cout<<endl;
}
}
Explanation:
Create the main function and declare the variable side.
print the message on the screen for the user and then store value enter by the user on the variable side.
take the nested for loop for print the pattern.
nested for loop means, loop inside another loop it is used for print the pattern having rows and columns.
the first loop updates the row number and the second the loop print the character '$' in the column-wise.
in the code,
if i = 1, for loop check the condition 1 <= 5 if the value of side is assume 5.
condition is true and the program moves to the second for loop and starts to print the character '$' five times after that, print the new line.
then, the above process repeat for different rows and finally, we get the pattern in square shape.
.Compare and contrast Primary storage and Secondarystorage.?
Answer:
Primary memory is the main memory ,Secondary memory can be external devices like CD, floppy magnetic discs etc
thats it to it really those are some of the reason
After you create an array variable, you still need to ____ memory space.
a.
reserve
b.
create
c.
organize
d.
dump
Answer:
Answer is (a) reserve
Explanation:
Usually when we create an array variable, in some language the memory is allocated automatically. But in some the memory is not allocated automatically. So we need to reserve the memory space for the array.
For example in C++ dynamic memory allocation we need to allocate memory using new keyword.
Which of the following can be used to record the behavior of classes?
A) Javadoc comments
B) Nouns and verbs in the problem description
C) Polymorphism
D) UML notation
Answer:
A) Javadoc comments
Explanation:
It is used for documenting the java source code in HTML and java code documentation. The difference between multi-line comment and javadoc is that ,javadoc uses extra asterisk, For example-
/**
* This is a Javadoc
*/
It is used to record the behavior of classes.There are various tags used in this like @author,{@code},@exception and many more.
Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print: 7 9 11 10 10 11 9 7
Answer:
JAVA program to display the array elements both forward and backward is given.
public class MyProgram {
public static void main(String args[]) {
int len = 5;
int[] courseGrades = new int[len];
courseGrades[0] = 7;
courseGrades[1] = 10;
courseGrades[2] = 11;
courseGrades[3] = 9;
courseGrades[4] = 10;
System.out.println("The elements of array are ");
for(int i=0; i<len; i++)
{
System.out.print(courseGrades[i]+" ");
}
// new line is inserted
System.out.println();
System.out.println("The elements of array backwards are ");
for(int i=len-1; i>=0; i--)
{
// elements of array printed backwards beginning from last element
System.out.print(courseGrades[i]+" ");
}
// new line is inserted
System.out.println();
}
}
OUTPUT
The elements of array are
7 10 11 9 10
The elements of array backwards are
10 9 11 10 7
Explanation:
This program uses for loop to display the array elements.
The length of the array is determined by an integer variable, len.
The len variable is declared and initialized to 5.
int len = 5;
The array of integers is declared and initialized as given.
int[] courseGrades = new int[len];
We take the array elements from the question and initialize them manually.
First, we print array elements in sequence using for loop.
for(int i=0; i<len; i++)
To display in sequence, we begin with first element which lies at index 0. The consecutive elements are displayed by incrementing the value of variable i.
The array element is displayed followed by space.
System.out.print(courseGrades[i]+" ");
Next, we print array elements in reverse sequence using another for loop.
for(int i=len-1; i>=0; i--)
To display in reverse sequence, the last element is displayed first. The previous elements are displayed by decrementing the value of variable i.
At the end of each for loop, new line is inserted as shown.
System.out.println();
The length and elements of the array are initialized manually and can be changed for testing the program.
Loops are used to perform operations that would be repeated in a certain number of times; in other words, loops are used to perform repetitive and iterative operations
The loop statements are as follows:
for(int i = 0; i<sizeof(courseGrades)/sizeof(courseGrades[0]);i++){
cout<<courseGrades[i]<<" ";
}
cout<<endl;
for(int i=sizeof(courseGrades)/sizeof(courseGrades[0]) - 1; i >=0; i--){
cout<<courseGrades[i]<<" ";
}
cout<<endl;
The flow of the above loops is as follows
The first for loop prints the elements in a forward order.The second for loop prints the elements in a backward order.Read more about loops at:
https://brainly.com/question/11857356
What is an example of the most important role of a systems analyst in any corporation?
Answer: The system analyst is one of the most important members in any organisation. These system analyst has to analyse different data of the organisation which would help to bring out the different any new business policy changes or any kind of improvement.
Explanation:
An example to know this better would be the system analyst of a telecom company. Here the role of the system analyst would be bring out the design and implementation of new telecom information system and also should be aware of previous data of the organization. The system analyst would also be responsible to bring out the new business policies based on latest telecom standards and ensure the systems conforms to the latest standards.
.Compositionally designed systems have the followingcharacteristics except:
A.dynamic definition B.classes built from componentclasses C.encapsulation D.white-box reuse
Answer: C) encapsulation
Explanation:
As, encapsulation is the process by which the data is included from the protocol of the upper layer into lower layer of the protocol in the computer networking. Basically, in the networking it is the method of abstraction, as it allowed different functions by adding different layer. In encapsulation, the IP encapsulated packet are sent over the data link layers protocol for example ethernet.
What is the output of the following code segment? int n = 0; for (int k = 0; k< 2; k++) {n=n +2;} cout << n; oo 0 1 O O O
Answer:
4
Explanation:
The loop is used to execute the part of code or statement again and again until a condition is not true.
syntax of for loop:
for(initialize; condition; increment/decrement){
statement;
}
in the question, the value of n is zero.
then, for loop check the condition k<2, initially the value of k is zero. so, the condition is true and execute the code n = 0 +2=2
Then, k is increment by 1. so, the value of k is 1.
then, again loop run and check the condition 1<2, it true. then n = 2+2=4.
then, k is increment by 1. so, the value of k is 2.
Then, again check the condition 2<2, condition false and program terminate the loop and finally print the value 4.