This assignment has two parts both of which must be within a



This assignment has two parts, both of which must be within a single program. Part 1: Write a program which displays the following menu: Geometry Calculator: 1. Calculate the area of a circle 2. Calculate the area of a rectangle 3. Calculate the area of a triangle 4. Quit If the user enters 1, have the user enter the radius of a circle, then calculate the circle\'s area. If the user enters 2, have the user enter the length and width of a rectangle, then calculate its area If the user enters 3, have the user enter the length of the triangle\'s base and its height, and calculate its area. If the user enters 4, have Part 1 of the program end Validations: the user must enter a valid number from the menu, and all other entries must be greater than zero. Display the area of the chosen shape after the user selects a choice (areas should be displayed to 3 decimal points). After coding part #1, code your program so the user enters your full name, including the appropriate spaces. Then have the user enter your height in feet and inches, in decimal-like format (see Explanation below). Assume any height is possible. Then display your name and display your height in inches, as a whole number (no decimals). double\" Hint: to avoid mixing \"int\" and \"double\" in calculations, variables should be all data type

Solution


#include <iostream> // std::cout
#include <stack> // std::stack
#include <vector> // std::vector
#include <deque> // std::deque
using namespace std;
#include <string>


int main(int argc, char const *argv[])
{
   int type;
   cout << \"enter choice : \";
   cin >> type;
   double radius;
   double length, width;
   double base, height;

   if(type == 1){
      
       cout << \"enter radius of circle : \" ;
       cin >> radius;

       cout << 3.14*radius*radius << \" is the area of circle \" << endl;


   }else{
       if(type == 2){
          
           cout << \"enter length and width of rectangle : \" << endl ;

          

           cin >> length;
           cin >> width;

           cout << 3.14*radius*radius << \" is the area of circle\" << endl;

       }else{
           if (type == 3)
           {
              
           cout << \"enter base, height of triangle \" << endl ;

          

           cin >> base;
           cin >> height;

           cout << 0.5*base*height << \" is the area of triangle\" << endl;

              
           }else{
               if(type == 4){
                   return 0;
               }else{

               }
           }
       }
   }

   // second part

  
   string name;
   cout << \"enter name :\" ;
   cin >> name;
   cout << \"enter height :\" ;
   cin >> height;

   cout << name << \" \" << (int)height << endl;

   return 0;
}

 This assignment has two parts, both of which must be within a single program. Part 1: Write a program which displays the following menu: Geometry Calculator: 1
 This assignment has two parts, both of which must be within a single program. Part 1: Write a program which displays the following menu: Geometry Calculator: 1

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site