Write a function, maxRadius, to find an index of a Planet with the largest radius in the array. The function should

Answers

Answer 1

Answer:

Follows are the code to this question:

#include<iostream>//defining header file

#include<string>//defining header file

using namespace std;

const double Pi =3.141592653589793238463;//defining double constant variable

class Planet  

{

private:

string planet_name;//defining string variable

double radius;//defining double variable

public:

Planet()//defining default constructor

{

this->planet_name="";//use this keyword to hold value

this->radius=0.0;//use this keyword to hold value

}

Planet(string name, double radius)//defining parameterized constructor  

{

this->planet_name = name;//use this keyword to hold value

this->radius=radius;//use this keyword to hold value

}

string getName() const//defining getName method  

{

return this->planet_name;//use return keyword for return string value

}

double getRadius() const//defining getRadius method  

{

return this->radius;//use return keyword for return radius value

}

double getVolume() const //defining getVolume method

{

return 4*radius*radius*radius*Pi/3;////use return keyword for return volume value

}

};

int maxRadius(Planet* planets, int s)//defining a method maxRadius that accept two parameter

{

double maxRadius=0;//defining double variable

int index_of_max_radius=-1;//defining integer variable

for(int index=0; index<s; index++)//defining for loop for calculate index of radius  

{

if(planets[index].getRadius()>maxRadius)//defining if block to check radius

{

maxRadius = planets[index].getRadius();//use maxRadius to hold value

index_of_max_radius=index;//hold index value

}

}

return index_of_max_radius;//return index value

}

int main()//defining main method

{

Planet planets[5];//defining array as class name

planets[0] = Planet("On A Cob Planet",1234);//use array to assign value  

planets[1] = Planet("Bird World",4321);//use array to assign value

int idx = maxRadius(planets,2);//defining integer variable call method maxRadius

cout<<planets[idx].getName()<<endl;//print value by calling getName method

cout<<planets[idx].getRadius()<<endl;//print value by calling getRadius method

cout<<planets[idx].getVolume()<<endl;//print value by calling getVolume method

}

Output:

Bird World

4321

3.37941e+11

Explanation:

please find the complete question in the attached file:

In the above-program code, a double constant variable "Pi" is defined that holds a value, in the next step, a class "Planet" is defined, in the class a default and parameter constructor that is defined that hold values.

In the next step, a get method is used that return value, that is "planet_name, radius, and volume".

In the next step, a method "maxRadius" is defined that accepts two-parameter and calculate the index value, in the main method class type array is defined, and use an array to hold value and defined "idx" to call "maxRadius" method and use print method to call get method.  

Write A Function, MaxRadius, To Find An Index Of A Planet With The Largest Radius In The Array. The Function

Related Questions

The state way of grading drivers is called what?

*

Answers

Oh yeah I forgot what you did you do that I mean yeah I forgot to tell you something about you lol lol I don’t want to see it anymore

To create a public key signature, you would use the ______ key.

Answers

Answer:

To create a public key signature, you would use the _private_ key.

Explanation:

To create a public key signature, a  private key is essential to enable authorization.

A private key uses one key to make data unreadable by intruders and for the data to be accessed the same key would be needed to do so.

The login details and some important credentials to access user data contains both the user's public key data and private key data. Both private key and public key are two keys that work together to accomplish security goals.

The public key uses different keys to make data readable and unreadable.

The public key is important to verify authorization to access encrypted data by making sure the access authorization came from someone who has the private key. In other words, it's a system put in place to cross-check the holder of the private key by providing the public key of the encrypted data that needed to be accessed. Though, it depends on the key used to encrypt the data as data encrypted with a public key would require a private key for the data to be readable.

Custom function definitions:________.
A. Must be written before they are called by another part of your program
B. Must declare a name for the function
C. Must include information regarding any arguments (if any) that will be passed to the function
D. all of the above

Answers

Answer:

D. all of the above

Explanation:

A option is correct and function definition must be written before they are called by another part of your program. But in languages such as C++ you can write the prototype of the function before it is called anywhere in the program and later write the complete function implementation. I will give an example in Python:

def addition(a,b): #this is the definition of function addition

    c = a + b

    return c    

print(addition(1,3)) #this is where the function is called

B option is correct and function definition must declare a name for the function. If you see the above given function, its name is declared as addition

C option is correct and function definition must include information regarding any arguments (if any) that will be passed to the function. In the above given example the arguments are a and b. If we define the above function in C++ it becomes: int addition( int a, int b)

This gives information that the two variables a and b that are parameters of the function addition are of type int so they can hold integer values only.

Hence option D is the correct answer. All of the above options are correct.

Write a program that computes and display the n! for any n in the range1...100​

Answers

Answer:

const BigNumber = require('bignumber.js');

var f = new BigNumber("1");

for (let i=1; i <= 100; i++) {

 f = f.times(i);

 console.log(`${i}! = ${f.toFixed()}`);

}

Explanation:

Above is a solution in javascript. You will need a bignumber library to display the numbers in full precision.

Write a method called min that takes three integers as parameters and returns the smallest of the three values, such that a call of min(3, -2, 7) would return -2, and a call of min(19, 27, 6) would return 6. Use Math.min to write your solution.

Answers

Answer:

public class Main

{

public static void main(String[] args) {

 System.out.println(min(3, -2, 7));

}

public static int min(int n1, int n2, int n3){

    int smallest = Math.min(Math.min(n1, n2), n3);

    return smallest;

}

}

Explanation:

*The code is in Java.

Create a method named min that takes three parameters, n1, n2, and n3

Inside the method:

Call the method Math.min() to find the smallest among n1 and n2. Then, pass the result of this method to Math.min() again with n3 to find the min among three of them and return it. Note that Math.min() returns the smallest number among two parameters.

In the main:

Call the method with parameters given in the example and print the result

Methods are named program statements that are executed when called/invoked.

The method in Python, where comments are used to explain each line is as follows:

#This defines the method

def mmin(a,b,c):

   #This calculates the smallest of the three values using math.min

   minNum = min(a,b,c)

   #This prints the smallest value

   return minNum

Read more about methods at:

https://brainly.com/question/14284563

Other Questions
The word monotonous has how many syllables? Find the measure of the missing angle Why do you think it is difficult to define the term"human rights"? How does the control group setup in an experimental differ from the other setups in the same experiment? why was 1917 such a critical year in the war? How were students recruited? MLK PLS PLS PLS HELPP NO FAKE AWNSERS I NEED THEM NOWWwW this graph shows how fast the International Spacd Station travels in orbit around Earth. what is the meaning of the point with an x-coordinate of 2 Find the principal. Annual rate of interest= 11% Period=3 years Total interest= 825 rupees Principal rupees A teacher instituted a new reading program at school. After 10 weeks in the program, it was found that the mean reading speed of a random sample of 19 second grade students was 90.7 wpm. What might you conclude based on this result? Select the correct choice below and fill in the answer boxes within your choice. (Type integers or decimals rounded to four decimal places as needed.) What is the message in the book Salt to the Sea by Ruta Sepetys? Find the sale price of the item. Round to two decimal places if necessary.Original price: $76.00Markdown: 33%The sale price is $ .PLZ ANSWER ASAP! Document 1: The Quran, Surah 5, Verse 32 "On that account We ordained for the Children of Isra`il that if any one slew a person - unless it be for murder or for spreading mischief in the land - it would be as if he slew the whole humanity: and if anyone saved a life, it would be as if he saved the whole humanity." *A : According to the statement, the Quran teaches that each individuals life has equal valueB: According to the statement, that is our civic duty to protect weaker individualsC : According to the statement, it is illegal to kill someone Read the excerpt from Fourteen by Alice Gerstenberg. Which part of the plot structure does the excerpt represent? ""Mr. Farnsworth?"" sneered Mrs. Pringle. ""Its the Prince of Wales that we will turn our attention to now. Who knew a blizzard could be such a wonderful thing!"" A. exposition B. resolution C. rising action D. climax evaluate this | 5+-3-2 | I wish someone here went to Waverly highschool in lansing cuz i really wanna kno if we still go to school the first week of November As the book ends, Scout awakes the morning after the attack, and she sees the town differently.True Or false Ito ang distansya na tumutukoy sa Kung gaano katagat Ang paglalakbay Main character motivation in Arabian nights Janice wants to find the area of a square tabletop.She uses the formula for the area of a square: A=s2, where s is the length of one side of the square.If s= 3 feet what is the area of the tabltop