Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8406571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:08:44+00:00 2026-06-09T23:08:44+00:00

I’m trying to write a program that • Defines an array of five circles

  • 0

I’m trying to write a program that

• Defines an array of five circles objects where radius is set using the random number provided by the random class utilising the parameterised constructor

• Defines a second array of five circles objects where radius is set using the random number provided by the random class utilising the setRadius method

• Displays the areas of each circle within each array using getArea()

The problem I need help with to display the areas of each circle within each array using getArea() method, I need to access the array which has the radius values of five circle in each array and then work out the area 3.14 * Radius * Radius. Then display the area to the screen.

Also after doing some research, do I need to Instantiate Circle object
which I entered in Circle myCircle;. However it came with an error saying

1>main.obj : error LNK2019: unresolved external symbol “public:
__thiscall Circle::Circle(void)” (??0Circle@@QAE@XZ) referenced in function _main

Circle.h file

#pragma once
#include <string>

class Circle 
{
private:
    float Radius;

public:
    Circle(); // initialised radius to 0
    Circle(float r); // accepts an argument and assign its value to the radius attribute
    void setRadius(float r); // sets radius to a value provided by its radius parameter (r)
    float getRadius(); // returns the radius of a circle
    float getArea(); // calculates and returns the areas of its circle
};

Random.h file

#pragma once
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

class Random
{
public:
    static void initialiseSeed();
    // random number initialised
    // random number has been initialised to the current time.

    static int random(int lower, int upper);
    // this function will return a positive random number within a specific lower and 
    // upper boundary.
};

Main.cpp file

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <iomanip>
using namespace std;

// Include header files
#include "Circle.h"
#include "Random.h"

int main()
{
    // Instantiate myCircle object
    //Circle myCircle;

    // Array 1
    // an array of five circles objects where radius is set using the random number
    // provided by the random class utilising the parameterised constructor

    int CircleArrayOne [5]; // store the numbers
    const int NUM = 5; // Display 5 random numbers

    srand(time(NULL)); // seed the generator

    // populate the array by calling the random function from the random class
    // within the lower and upper bounds

    for(int x = 0; x < NUM; ++x)
    {
        CircleArrayOne[x] = Random::random(1, 40); // assumed 0 and 40 as the bounds
    }

    // Below is the code I use to output the array to the screen to make sure
    // that is output the correct number of values and it generate number between 1 and 40
    // I am doing this to test the code above that populate the array within lower and upper
    // bounds

    cout << "Checking the radius in the Array 1." << endl;
    for(int i = 0; i < NUM; ++i) 
    {
        cout << CircleArrayOne[i] << endl;
    }

    // Array 2
    // a second array of five circles objects where radius is set using the random number 
    // provided by the random class utilising the setRadius method

    float CircleArrayTwo [5]; // store the numbers
    const int Number = 5; // Display 5 random numbers

    srand(time(NULL)); // seed the generator

    // populate the array with random numbers

    for(int i = 0; i < Number; ++i)
    {
        CircleArrayTwo[i] = rand()%100;
    }

    // Below is the code I use to output the array to the screen to make sure
    // that is output the correct number of values and it generate random values

    cout << "Checking the radius in the Array 2." << endl;
    for(int i = 0; i < Number; ++i)
    {
        cout << CircleArrayTwo[i] << endl;
    }

    // Display the area of each Circle within each array using getArea()

    cout << "\nThe area of each circle within array 1: " << endl;

    cout << "\nThe area of each circle within array 2: " << endl;

    // Display a message that indicates which set of circle has the largest 
    // combined area

    cout << "\nArray: " << "had the largest combined area." << endl;

    // Display a message that indicates which set contains the circle 
    // with the largest area

    cout << "\nArray: " << "contain the circle with the largest area.\n" << endl;

    system("PAUSE");
    return 0;
}

// Calling Circle(float r) from Circle Class
Circle::Circle(float r)
{
    if (r<=0)
    {
        cout << "An invalid radius has been detected." << endl;
        cout << "The radius has been set to 1.0" << endl;
        Radius = 1.0;
    }
    else
        Radius = r;
}

// Calling getArea() from Circle Class
float Circle::getArea()
{
    // Area = pi * radius * radius
    return 3.14 * Radius * Radius;
}

// Calling setRadius(float r) from Circle Class
void Circle::setRadius(float r)
{
    rand()%100;
    Radius = r;
}

// Calling getRadius() from Circle Class
float Circle::getRadius()
{
    return Radius;
}

// Calling random(int lower, int upper) from Random Class
int Random::random(int lower, int upper)
{
    int range = upper - lower + 1;
    return (rand() % range + lower);
}

// Calling initialiseSeed() from Random Class
void Random::initialiseSeed()
{
    srand((unsigned int)time(0));
    rand()%100;
}

How do I get the area of each circle within each array using getArea() function

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:08:45+00:00Added an answer on June 9, 2026 at 11:08 pm

    You haven’t provided a definition for Circle‘s default constructor, add

    Circle::Circle() : Radius(0) {}
    

    to main.cpp.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.