1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
In-s [12.5K]
3 years ago
5

I want to write a C++ program to read the diameter of a circle. The program should find and display the area and circumference o

f the circle. Define a constant of type double PI = 3.14159
I need code for this program
Computers and Technology
1 answer:
Andreas93 [3]3 years ago
7 0

Answer:

#include <iostream>

const double PI = 3.14159;

int main() {

   double diameter;

   std::cout << "Please enter the diameter of the circle:" << std::endl;

   std::cin >> diameter;

   double radius = diameter / 2;

   double area = radius * radius * PI;

   double circumference = 2 * radius * PI; // or diameter * PI;

   std::cout << "Area: " << area << std::endl;

   std::cout << "Circumference: " << circumference << std::endl;

}

Explanation:

The first line imports the read/write library. The rest should be self-explanatory.

std::cin is the input stream - we use it to get the diameter

std::cout is the output stream - we write the answers (and commentary) there.

std::endl is the special "character" informing the output stream that we want it to put a newline character (and actually print to the output - it might have been holding off on it).

the // in the circumference computation signifies a comment - the program simply ignores this. I've added it to tell the reader that the circumference could have been computed using the diameter,

You might be interested in
You will need to complete the functions these functions: a. get_total This function takes in pennies, nickels, dimes, and quarte
tankabanditka [31]

Answer:

penny = int(input("Enter number of pennies: "))

nickel = int(input("Enter number of nickel: "))

dime = int(input("Enter number of dime: "))

quarter = int(input("Enter number of quarter: "))

def get_total(penny, nickel, dime, quarter):

   total = ((1 * penny) + (5 * nickel) + (10 * dime) + (25 * quarter))/ 100

   print (f"The total amount is {total}")

   

def get_dollars(penny, nickel, dime, quarter):

   dollar = ((1 * penny) + (5 * nickel) + (10 * dime) + (25 * quarter))// 100

   print (f"The dollar part is ${dollar}")

   

def get_left_over_cent(penny, nickel, dime, quarter):

   cent = ((1 * penny) + (5 * nickel) + (10 * dime) + (25 * quarter)) % 100

   print (f"The left over cent is {cent} cents")

 

   

get_total(penny, nickel, dime, quarter)

get_dollars(penny, nickel, dime, quarter)

get_left_over_cent(penny, nickel, dime, quarter)

Explanation:

In the United States, these coins have following values:

Quarter= 25 cents

Dime= 10 cents

Nickel= 5 cents

Penny= 1 cent

The first line collect an input from the user, convert to integer and assign to penny.

The second line collect an input from the user, convert to integer and assign to nickel.

The third line collect an input from the user, convert to integer and assign to dime.

The fourth line collect an input from the user, convert to integer and assign to quarter.

Based on the above definition of penny, nickel, dime and quarter; we defined the various function.

First the get_total function was defined and the total amount was calculated and assigned to total, then the total was output to the user.

Then, the get_dollars function was defined and the dollar part was calculated through dividing the total by 100. (100 cents = $1). The dollar was also output to the user.

Then, the get_left_over_cents function was defined and the cent was calculated by finding the remainder when the total is divided by 100 (cent = total % 100). The symbol "%" represent modulo and is used to find remainder of a division operation.

6 0
3 years ago
Describe shortly about the following Linux directories and theirpurpose,1. lib2. etc3. Boot4. Root5. home
Bingel [31]

Answer:

 Linux directories and their purposes are:

1) lib - Lib file contained the share object library file which necessary to boots system and this directory contain file module stored in the kernel.

2) etc - etc file is the configuration file that they are local in the machines. When the program run these file are stored in the directories. this can be static and do not executable directory.

3) Boot - Boot file are stored in the directory which required processing of linux boot and such files are included in the linux kernel of the file.

4) Root - Root file are the best user root directory and user cannot view this directories from there account. This file usually contain administrative file system.  

5) Home - Home file contained the user directory and it is the default system of linux. Home directory helps user to enable any network system to access there home directories.

5 0
3 years ago
Make The PYTHON Code<br><br> print first 3 character of a string - given "Seattle" expected "Sea"
vlada-n [284]

This program uses a conditional to determine if seafood is safe to consume.

IF (seafood = "mollusk" OR daysFrozen ≥ 7) { rating ← "safe" } ELSE { rating ← "unsafe" }

In which situations will rating be "safe"?

️Note that there may be multiple answers to this question.

Choose all answers that apply:Choose all answers that apply:

1. When sea food is mollusk and day frozen is 1

2.When sea food is mollusk and day froze is 9

3. When see food salmon and day frozen is 7

<em>Did that help?</em>

6 0
2 years ago
Which of the following is used to manage the objects in a database?
kirill [66]

The answer is the B: The Navigation Pane

All the objects in a Microsoft Access database are listed in the Navigation Pane. You can view and manage the categories and groups of objects in the Navigation Pane. You can also hide groups, objects, or the entire Navigation Pane. In addition, you can also use the Navigation pane to sort objects, find objects in a database, and add objects to a custom group.  By default, the navigation pane appears when you open a database in Access.


8 0
3 years ago
Private BLANK are cloud services available to members of a particular organization.
dalvyx [7]

Answer:

A private cloud is a set of applications and resources that are available only to individuals within a specific organization. These resources may be owned by the organization itself or by a third party, and may be hosted inside or outside

Explanation:

.

4 0
3 years ago
Other questions:
  • Which statement is a famous quote from Canadian Communications theorist Marshall mcluhan​
    9·1 answer
  • WordArt styles allow you to add ____.
    9·1 answer
  • Give two reasons why it is important to upgrade your browser when a new version becomes available.
    8·1 answer
  • Write a Java method onlyDigits that takes a string as a parameter. The method should remove from the string all characters, whic
    15·1 answer
  • Where is a 3D modeler most likely to work?
    6·1 answer
  • Someone knows a good compiler for iPad? It has to be an app
    10·1 answer
  • While organizing his computer's power cords, Matt realizes his printer power cord is frayed (coming apart). What should Matt do
    10·1 answer
  • Describe the evolution of computers.​
    7·1 answer
  • What improved image quality in televisions?
    5·1 answer
  • Older systems that often contain data of poor quality are called ________ systems.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!