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

using C language Create a bitwise calculator that ask user for input two input, first int,...
using C language Create a bitwise calculator that ask user for input two input, first int, bitwise operation, second int (i.e 5 & 9) only those bitwise operation are allowed: & ~ ^ | << >>. If user uses wrong operators stop program and ask again. Convert the first int and second int into 8 BITS binary (00000000) and use bitwise operator given by user to either AND, OR, XOR, etc (ie 1001 & 1111)
C CODE PLZ! All instructions for what to do in code #include <stdio.h> int main(int argc,...
C CODE PLZ! All instructions for what to do in code #include <stdio.h> int main(int argc, char **argv) { int n, k, l, r, t, d, i; char str[65]; /* Make the user enter a non-negative integer */ printf("Please enter a non-negative integer: "); scanf("%d", &n); while (n < 0) { printf("Sorry, your input is incorrect.\n"); printf("Please enter a non-negative integer: "); scanf("%d", &n); } /* Convert the integer to reversed binary: e.g. 6 gets converted to 011 */ if...
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...
Please code C# 10. Write a program that allows a user to input names and corresponding...
Please code C# 10. Write a program that allows a user to input names and corresponding heights (assumed to be in inches). The user can enter an indefinite number of names and heights. After each entry, prompt the user whether they want to continue. If the user enters true, ask for the next name and height. If the user enters false, display the name of the tallest individual and their height. Sample run: “Name?” James “Height?” 50 “Continue?” True “Name?”...
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.
C Write a function int sort(int** arr, int n) that takes as input an array of...
C Write a function int sort(int** arr, int n) that takes as input an array of int pointers, multiplies the ints the pointers point to by -1, and then sorts the array such that the values pointed to by the pointers are in decreasing order. For example, if the array is size 10 the pointer at index 0 will point to the largest value after multiplying by -1 and the pointer at index 9 will point to the smallest value...
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT