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.
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
C Code Edit this code to make it output all unique letters IN LOWERCASE of an...
C Code Edit this code to make it output all unique letters IN LOWERCASE of an input file. For example, with this input: Raspberry Grapefruit Straw berry raspBERRY Blue$$berry apple Pine_apple raspberry The output should be: raspberry grapefruit straw berry blue berry apple pine NOTE: Words with different capitlization, like raspberry and raspBERRY count as 1 unique word, so raspberry should only be seen once in the output. #include <stdio.h> #include <stdlib.h> int main() {     //Pointer to access the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT