Question

In: Computer Science

In c++, Can anyone make these code int user input as user have to put all...

In c++, Can anyone make these code int user input as user have to put all the amount.

int main()
   {
       Polygon p1(3,4,4.5,5.5);
       Polygon p2(4,4,5.5,6.5);
       Polygon p3(5,4,6.5,7.5);
      
       cout<<"Area of Polygon#1:"<<p1.getArea()<<endl;
       cout<<"Perimeter of Polygon#1:"<<p1.getPerimeter()<<endl;
      
       cout<<"\nArea of Polygon#2:"<<p2.getArea()<<endl;
       cout<<"Perimeter of Polygon#2:"<<p2.getPerimeter()<<endl;
      
       cout<<"\nArea of Polygon#3:"<<p3.getArea()<<endl;
       cout<<"Perimeter of Polygon#3:"<<p3.getPerimeter()<<endl;
      
      
      
   return 0;  
   }

Solutions

Expert Solution

Dear student, I have modified the code according to your requirements.
Please upvote if you are satisfied with the answer.
Please do comment below if you have any doubts thanks.



int main()
{

float a,b,c,d,e,f,g,h,i,j,k,l;

cout<<"Enter the values for Plogon 1: ";
cin>>a>>b>>c>>d;

cout<<"Enter the values for Plogon 2: ";
cin>>e>>f>>g>>h;

cout<<"Enter the values for Plogon 3: ";
cin>>i>>j>>k>>l;



Polygon p1(a,b,c,d);
Polygon p2(e,f,g,h);
Polygon p3(i,j,k,l);
  
cout<<"Area of Polygon#1:"<<p1.getArea()<<endl;
cout<<"Perimeter of Polygon#1:"<<p1.getPerimeter()<<endl;
  
cout<<"\nArea of Polygon#2:"<<p2.getArea()<<endl;
cout<<"Perimeter of Polygon#2:"<<p2.getPerimeter()<<endl;
  
cout<<"\nArea of Polygon#3:"<<p3.getArea()<<endl;
cout<<"Perimeter of Polygon#3:"<<p3.getPerimeter()<<endl;
  
  
return 0;
}


Related Solutions

in C please! Write a code that asks user for input N and calculates the sum...
in C please! Write a code that asks user for input N and calculates the sum of the first N odd integers. There should be a "pure" method that calculates the sum separately that Main method should call when printing the output.
C++ How to make this code take a class object instead of int for the vector...
C++ How to make this code take a class object instead of int for the vector queue and be able to enqueue and dequeue the object? #include <iostream> #include <float.h> #include <bits/stdc++.h> using namespace std; void print_queue(queue<int> Q) //This function is used to print queue { while (!Q.empty()) { cout<< Q.front() << " "; Q.pop(); } } int main() { int n = 10; vector< queue<int> > array_queues(n); //Create vector of queues of size 10, each entry has a queue...
MIPS ASSEMBLY Have the user input a string and then be able to make changes to...
MIPS ASSEMBLY Have the user input a string and then be able to make changes to the characters that are in the string until they are ready to stop. We will need to read in several pieces of data from the user, including a string and multiple characters. You can set a maximum size for the user string, however, the specific size of the string can change and you can’t ask them how long the string is (see the sample...
Can anyone make a documentation and comments for the following code? Documentation in doxgen format please....
Can anyone make a documentation and comments for the following code? Documentation in doxgen format please. Thank you! And simple comments for the code. Thank s. template <typename T> bool LinkedList<T> :: search(const T& item) const { // if list is not empty display the items Node<T>* current = first; while (current != NULL) { if (current->info == item) { return true; } current = current->link; } return false; } template <typename T> void LinkedList<T> :: deleteNode(const T& item) {...
C++ How do you make a 2d array with a user input. For example, the row...
C++ How do you make a 2d array with a user input. For example, the row and columns of the 2d array will be the same so the program can create a square matrix.
CODE IN C PLEASE Ask for user to input 4 different numbers Use pointers in calculations...
CODE IN C PLEASE Ask for user to input 4 different numbers Use pointers in calculations instead of variables to calculate the sum of those 4 numbers Print the sum Use a pointer to a pointer for print operation
Can anyone translate this to flowgorith. #include<stdio.h> int main()    {    int seatingChart[10];       //array...
Can anyone translate this to flowgorith. #include<stdio.h> int main()    {    int seatingChart[10];       //array for seating chart       int fc = 0, ec = 5,i;       //starting positions for first class and economy class       printf("Welcome to the Airline Reservation System (ARS)\n\n");       for(i=0;i<10;i++)       //initializing the array with zero        {        seatingChart[i] = 0;        }    char choice;       do        {        int ch;   ...
Translate the following function f to MIPS assembly code. int f(int a, int b, int c,...
Translate the following function f to MIPS assembly code. int f(int a, int b, int c, int d) { return func(func(a,b), func(b+c,d)); } Assume the followings. • The prototype of function func is “int func(int a, int b);”. • You do not need to implement function func. The first instruction in function func is labeled “FUNC”. • In the implementation of function f, if you need to use registers $t0 through $t7, use the lower-numbered registers first. • In the...
Code using assembly language Create a program using the Irvine32 procedures were the user can input...
Code using assembly language Create a program using the Irvine32 procedures were the user can input a list of 32-bit unsigned integers an “x” number of times, then display these integers to the console in reverse order. Hint: Use loops and PUSH & POP instructions. Extra Challenge: Inform the user with a message what to do; also, tell them what they are seeing.
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input operator>> a bigint in the following manner: Read in any number of digits [0-9] until a semi colon ";" is encountered. The number may span over multiple lines. You can assume the input is valid. Overload the operator+ so that it adds two bigint together. Overload the subscript operator[]. It should return the i-th digit, where i is the 10^i position. So the first...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT