Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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.
```
expand button
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.
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education