Lab Objectives This lab was designed to reinforce programming concepts from Chapter 4 & 5 of C++ Programming: Program Design Including Data Structures, 8th Edition. In this lab you will practice: Problem Description Based on the provided code, create a C++ program as required to display the information for multiple circles. You may name it as Program6_ControlStructures_YourName.cpp. Programming Steps Develop your program with control structures following these steps. Step 1: 1. Create a program as in the following picture 2. Add one more statement after line 12 to print out the area of this circle Input request & validation • Nested for loops • Using counter-controlled repetition Now this program is to display circumference & area of 10 circles with the counter of each iteration as the radius 1 #include 2 using namespace std; 3 4 6 7 8 int main() { cout << "Your Name will create a program with control structures.\n\n"; const double PI = 3.1415; int ct = 10; 9 10 11 12 13 14 15 16 17 18) for (int i=0; i

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Good morning, can I get help with this c++ homework? Thank you (:

**Step 2:**

Add the `while` loop in the following picture into your program before the `for` loop.

**Instruction:**

- **Let user to decide for how many circles to display information**

```cpp
while(ct<=0) {
    cout << "Please enter an integer: ";
    cin >> ct;
}
cout << "ct is " << ct << endl << endl;
```

**Step 3:**

1. Add the following selective structure into your program so that:
   - In your `for` loop, two `cout` statements are enclosed within the curly braces in this selective structure.

**Instruction:**

- **So, the program is to display the information for circles only when the counter is an even number**

```cpp
if (!(i%2)) {
    // Your code here
}
```

**Sample Output:**

The following is a sample output for the program you are supposed to have finally. You may enter different numbers when you run your program.

```
YourName will create a program with control structures.

Please enter an integer: -9
Please enter an integer: -100
Please enter an integer: 0
Please enter an integer: 5
ct is 5

The circumference of a circle with radius 0 is 0
The area of a circle with radius 0 is 0

The circumference of a circle with radius 2 is 12.566
The area of a circle with radius 2 is 12.566

The circumference of a circle with radius 4 is 25.132
The area of a circle with radius 4 is 50.264

I (YourName) finally have all done!

...Program finished with exit code 0
Press ENTER to exit console.
```
Transcribed Image Text:**Step 2:** Add the `while` loop in the following picture into your program before the `for` loop. **Instruction:** - **Let user to decide for how many circles to display information** ```cpp while(ct<=0) { cout << "Please enter an integer: "; cin >> ct; } cout << "ct is " << ct << endl << endl; ``` **Step 3:** 1. Add the following selective structure into your program so that: - In your `for` loop, two `cout` statements are enclosed within the curly braces in this selective structure. **Instruction:** - **So, the program is to display the information for circles only when the counter is an even number** ```cpp if (!(i%2)) { // Your code here } ``` **Sample Output:** The following is a sample output for the program you are supposed to have finally. You may enter different numbers when you run your program. ``` YourName will create a program with control structures. Please enter an integer: -9 Please enter an integer: -100 Please enter an integer: 0 Please enter an integer: 5 ct is 5 The circumference of a circle with radius 0 is 0 The area of a circle with radius 0 is 0 The circumference of a circle with radius 2 is 12.566 The area of a circle with radius 2 is 12.566 The circumference of a circle with radius 4 is 25.132 The area of a circle with radius 4 is 50.264 I (YourName) finally have all done! ...Program finished with exit code 0 Press ENTER to exit console. ```
**Program 6: Control Structures**

*Due on Sunday, 11/13/2022, by 11:59pm*

### Lab Objectives

This lab is designed to reinforce programming concepts from Chapter 4 & 5 of *C++ Programming: Program Design Including Data Structures, 8th Edition*. In this lab, you will practice:

- Input request & validation
- Nested for loops
- Using counter-controlled repetition

### Problem Description

Based on the provided code, create a C++ program as required to display information for multiple circles. You may name it as `Program6_ControlStructures_YourName.cpp`.

### Programming Steps

Develop your program with control structures following these steps.

#### Step 1:

1. Create a program as in the following picture.
2. Add one more statement after line 12 to print out the area of this circle.

   Now this program is to display the circumference & area of 10 circles with the counter of each iteration as the radius.

***Code Reference:***

```cpp
#include <iostream>
using namespace std;

int main()
{
    cout << "YourName will create a program with control structures.\n\n";

    const double PI = 3.1415;
    int ct = 10;

    for (int i=0; i<ct; i++) { 
        cout << "The circumference of a circle with radius " << i << " is " << 2*PI*i << endl;
    }

    cout << "\n\nI (YourName) finally have all done!";

    return 0;
}
```

#### Step 2:

1. In line 9 of your program, change 10 to -1.

---

This lab aims to guide you through creating a C++ program to calculate and display the circumference and area of circles with increasing radii, using loops and control structures to enhance your programming skills.
Transcribed Image Text:**Program 6: Control Structures** *Due on Sunday, 11/13/2022, by 11:59pm* ### Lab Objectives This lab is designed to reinforce programming concepts from Chapter 4 & 5 of *C++ Programming: Program Design Including Data Structures, 8th Edition*. In this lab, you will practice: - Input request & validation - Nested for loops - Using counter-controlled repetition ### Problem Description Based on the provided code, create a C++ program as required to display information for multiple circles. You may name it as `Program6_ControlStructures_YourName.cpp`. ### Programming Steps Develop your program with control structures following these steps. #### Step 1: 1. Create a program as in the following picture. 2. Add one more statement after line 12 to print out the area of this circle. Now this program is to display the circumference & area of 10 circles with the counter of each iteration as the radius. ***Code Reference:*** ```cpp #include <iostream> using namespace std; int main() { cout << "YourName will create a program with control structures.\n\n"; const double PI = 3.1415; int ct = 10; for (int i=0; i<ct; i++) { cout << "The circumference of a circle with radius " << i << " is " << 2*PI*i << endl; } cout << "\n\nI (YourName) finally have all done!"; return 0; } ``` #### Step 2: 1. In line 9 of your program, change 10 to -1. --- This lab aims to guide you through creating a C++ program to calculate and display the circumference and area of circles with increasing radii, using loops and control structures to enhance your programming skills.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education