Answer to Question #163767 in C++ for Anonymous

Question #163767

Create a program that will compute:

  1. The area and circumference of a circle. Prompt the user to enter the radius. Use 3.14159 for pi.
  2. The area and the perimeter of a rectangle. Prompt the user to enter the length and the width.
  • Use the plan you created last week. If need be revise your pseudocode and algorithm to match expect output and Mimir test cases. 
  • Once again desk check your pseudocode and algorithm.
  • Do not allow for invalid input.
  • Allow for positive values only.
  • Format to 3 decimal places

 

  • Name file main.cpp
  • To Mimir submit: .cpp file
  • Submit your pseudocode and desk check along with your code to Mimir in a separate file
  • Pseudocode and desk check should be in the format of a pdf, picture, or notepad.
  • Include your name, date at the top of the code as a comment.
  • Restate project assignment question as a comment
  • Include detailed comments throughout your code.
1
Expert's answer
2021-02-14T23:59:27-0500
#include <iostream>
#include <cmath>
using namespace std;
void circle (int radius) {
    const float pi = 3.14159;
    cout << "The area of the circle: " << pi * pow(radius, 2) << endl;
    cout << "The circumference of the circle: " << 2 * pi * radius << endl;
}
void rectangle (int length, int width) {
    cout << "The area of the rectangle: " << width * length << endl;
    cout << "The perimetr of the rectangle: " << 2 * (width + length) << endl;
}
int main () {
    int w, l;
    float r;
    cout << "Enter radius of the circle: "; cin >> r;
    circle(r);
    cout << "Enter length of rectangle: "; cin >> l;
    cout << "Enter width of rectangle: "; cin >> w;
    rectangle(l, w);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment