#include //main header file for input/output operations #include //declares a set of functions to compute common mathematical operations using namespace std; //to avoid using std repeatedly float getTriangleArea(float b,float h) //function used to find Area of Triangle { return (b*h)/2; } float getTrianglePerimeter(float b,float h) //function to find Perimeter of Triangle { float hy=sqrt(b*b+h*h); //formula for finding hypotenuse return h+hy+b; //in order to return the perimeter } float getRectangleArea(float w,float l) //function used to find Area of Rectangle { return w*l; } float getRectanglePerimeter(float w,float l) //function used to find Perimeter of Rectangle { return 2*(w+l); } float getCircleArea(float r) //function used to find Area of Circle { return 3.14*r*r; } float getCircleCircumference(float r) //function used to find circumference of Circle { return 3.14*r*2; } int main() //main function { int choice; //taking the input of choice float b, h, w, l, r; //used to take input of dimensions cout<<"Choose one from the choices \n1-Right Triangle \n2-Rectangle \n3-Circle \n"; //output to choose from the choices cin>>choice; if(choice==1) //if statement for the first choice { cout<<"Enter the base of the Triangle : "; cin>>b; if(!cin); cout<<"Enter the height of the Triangle : "; cin>>h; if(!cin); cout<<"\nThe Area of the Triangle is : "<>w; if(!cin); cout<<"Enter the length of the Rectangle : "; cin>>l; if(!cin); cout<<"\nThe Area of the Rectangle is : "<>r; if(!cin); cout<<"\nThe Area of the Circle is : "<

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
#include <iostream> //main header file for input/output operations
#include <math.h> //declares a set of functions to compute common mathematical operations

using namespace std; //to avoid using std repeatedly

float getTriangleArea(float b,float h)  //function used to find Area of Triangle
{
    return (b*h)/2;
}
float getTrianglePerimeter(float b,float h)  //function to find Perimeter of Triangle
{  
    float hy=sqrt(b*b+h*h);  //formula for finding hypotenuse
    return h+hy+b;  //in order to return the perimeter
}
float getRectangleArea(float w,float l)   //function used to find Area of Rectangle
{
    return w*l;
}
float getRectanglePerimeter(float w,float l)   //function used to find Perimeter of Rectangle
{
    return 2*(w+l);
}
float getCircleArea(float r)   //function used to find Area of Circle
{
    return 3.14*r*r;
}
float getCircleCircumference(float r)   //function used to find circumference of Circle
{
    return 3.14*r*2;
}

int main() //main function
{  
    int choice; //taking the input of choice
    float b, h, w, l, r; //used to take input of dimensions
    cout<<"Choose one from the choices \n1-Right Triangle \n2-Rectangle \n3-Circle \n"; //output to choose from the choices
    cin>>choice;
    if(choice==1) //if statement for the first choice
    {
        cout<<"Enter the base of the Triangle : ";
        cin>>b;
        if(!cin);
        cout<<"Enter the height of the Triangle : ";
        cin>>h;
        if(!cin);
        cout<<"\nThe Area of the Triangle is : "<<getTriangleArea(b,h)<<"\nThe Perimeter of the triangle is : "<<getTrianglePerimeter(b,h)<<endl;
    }

    else if(choice==2) //if statement for the second choice
    {
        cout<<"Enter the width of the Rectangle : ";
        cin>>w;
        if(!cin);
        cout<<"Enter the length of the Rectangle : ";
        cin>>l;
        if(!cin);
        cout<<"\nThe Area of the Rectangle is : "<<getRectangleArea(w,l)<<"\nThe Perimeter of the Rectangle is : "<<getRectanglePerimeter(w,l)<<endl;
    }

    else if(choice==3) //if statement for the third choice
    {
        cout<<"Enter the radius of the Circle : ";
        cin>>r;
        if(!cin);
        cout<<"\nThe Area of the Circle is : "<<getCircleArea(r)<<"\nThe Perimeter of the triangle is : "<<getCircleCircumference(r)<<endl; //outputs the Area and Perimeter of the circle using stored variables
    }

    else{
        cout<<"Please enter the correct Input"; //If the input is (!cin) which is invalid
    }


   
    return 0; //exit code of the program indicating successful completion of the program
 
my problem here is that, when the input is invalid it doesnt print "please enter the correct input" instead, it just prints 0. the else statement doesnt work
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Events
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY