Problem #3: Write a program that reads the width, height and a character from the user, then calculates the perimeter of the rectangle if the character is 'P' or the area of the rectangle if the character is 'A'. The program should prints 'Wrong character' if the character is different than “P" and 'A'. The program keeps reading values until the user decides to stop. The perimeter of a rectangle; p= 2(w +h). The area of a rectangle; a = w x h. Sample Run: Enter the width and height: 6 6 Enter a character: A The area is 36.0 Do you want to continue? [N to stop]: y Enter the width and height: 3 4 Enter a character: P The perimeter is 14.0 Do you want to continue? [N to stop]: Y Enter the width and height: 3 4 Enter a character: C Wrong character Do you want to continue? [N to stop]: Y Enter the width and height: 3 4 Enter a character: A The area is 12.0 Do you want to continue? [N to stop]: N

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 31PE
icon
Related questions
Question
Problem #3:
Write a program that reads the width, height and a character from the user, then calculates
the perimeter of the rectangle if the character is 'P' or the area of the rectangle if the character
is 'A'. The program should prints 'Wrong character' if the character is different than "P" and
'A'. The program keeps reading values until the user decides to stop.
The perimeter of a rectangle; p= 2(w +h).
The area of a rectangle; a = w x h.
Sample Run:
Enter the width and height: 6 6
Enter a character: A
The area is 36.0
Do you want to continue? [N to stop]: y
Enter the width and height: 3 4
Enter a character: P
The perimeter is 14.0
Do you want to continue? [N to stop]: Y
Enter the width and height: 3 4
Enter a character: C
Wrong character
Do you want to continue? [N to stop]: Y
Enter the width and height: 3 4
Enter a character: A
The area is 12.0
Do you want to continue? [N to stop]: N
Transcribed Image Text:Problem #3: Write a program that reads the width, height and a character from the user, then calculates the perimeter of the rectangle if the character is 'P' or the area of the rectangle if the character is 'A'. The program should prints 'Wrong character' if the character is different than "P" and 'A'. The program keeps reading values until the user decides to stop. The perimeter of a rectangle; p= 2(w +h). The area of a rectangle; a = w x h. Sample Run: Enter the width and height: 6 6 Enter a character: A The area is 36.0 Do you want to continue? [N to stop]: y Enter the width and height: 3 4 Enter a character: P The perimeter is 14.0 Do you want to continue? [N to stop]: Y Enter the width and height: 3 4 Enter a character: C Wrong character Do you want to continue? [N to stop]: Y Enter the width and height: 3 4 Enter a character: A The area is 12.0 Do you want to continue? [N to stop]: N
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr