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
Lisa [10]
3 years ago
15

Program 7 - Circle You write ALL the code, then run it - Produce the correct output. Turn in code and screen print of successful

run, for credit * Write a class for a Circle * Input only the radius. * Write functions that Calculate the circles Circumference, Area and Diameter, and print out the value of the radius * Include error checking for radius, must be greater than zero. Test all combinations

Computers and Technology
1 answer:
fgiga [73]3 years ago
7 0

Answer:

Here is the Circle class:

public class Circle {   // class definition

private int radius;    // private data member of type int of class Circle named radius that stores the value of radius

public Circle(int r) {   // parameterized constructor of class Circle that takes radius as argument

 radius = r;  }    // sets value of radius as r

public int getRadius() {   // accessor method to get the value of radius

 return radius;  }   // returns the current value of radius

public int Diameter() {   // method to compute diameter of a circle

 return radius * 2;  }   // multiply radius value by 2 to compute diameter of Circle

 

public double Area() {   // method to compute area of a circle

 return Math.PI  * Math.pow(radius, 2);   }   //the formula of area is

π x radius² where value of π is get using Math.PI

 

 public double Circumference() {   // // method to compute circumference of a circle

 return 2* Math.PI * radius;   }   }  //the formula of circumference is

2 x π x radius where value of π is get using Math.PI

Explanation:

Here is the Main class:

import java.util.Scanner;  //to accept input from user

public class Main {  //definition of Main class

public static void main(String[] args) {  //start of main method

   

    Scanner scanner = new Scanner (System.in);  //creates Scanner object to take input from user

    System.out.println("Enter radius: ");  //prompts user to enter radius

    int r = scanner.nextInt();  //reads the value of radius from user

 Circle c = new Circle(r);  // calls Constructor of Circle passing r as argument to it using the object c of class Circle

 

    if(c.getRadius()<=0){  //calls getRadius method to get current value of radius using objec and checks if this value (input value of r ) is less than or equal to 0

        System.out.println("Error!");   }  //when above if condition evaluates to true then print this Error! message

    else {  //if the value of radius is greater than 0

System.out.println("the radius of this Circle is: " +c.getRadius());  //calls getRadius method to return current value of r (input value by user)

System.out.println("the diameter of this Circle  is: " + c.Diameter());  //calls Diameter method to compute the diameter of Circle and display the result on output screen

System.out.printf("the circumference of this Circle  is: %.2f", c.Circumference());  //calls Circumference method to compute the Circumference of Circle and display the result on output screen

System.out.println();  //prints a line

System.out.printf("the Area of this Circle  is: %.2f", c.Area()); } }  }

//calls Area method to compute the Area of Circle and display the result on output screen

The program and its output is attached.

You might be interested in
PLEASE HELPPPPPPP What should you always disconnect before installing hardware inside a computer’s case?
Ad libitum [116K]

Answer:

a) all cabling hope it helps

3 0
2 years ago
A computer scientist from the 1960's who developed the mouse, computer networking, and used a small musical keyboard to control
PIT_PIT [208]
Steve Jobs im pretty sure
7 0
3 years ago
The instant pivot button is displayed in the statistics and visualization tabs when a _______ search is run.
Arisa [49]

Answer:

<h2>The instant pivot button is displayed in the statistics and visualization tabs when a <u>non-transforming</u>  search is run. </h2>

Explanation:

<h3>Transforming Search:</h3>

It can be defined as a search in which transforming commands are used that involve, charts and stats to convert data of events that is gained by the search in to tables (statistical). These tables can further be used for the basis of visualizing data in the form of charts.

Non-Transforming Search:

The search that do no contains produce event lists that can be viewed in Events tab. while using non-transforming search, i we want to generate tables or charts we must follow the points below:

  • Click ob statistics and Visualization tab.
  • Select pivot to open the search.
  • All the visualizations can be generated in this editor.

<h2>i hope it will help you!</h2>
5 0
3 years ago
The primary source of help for technical problems with BC Online (computer settings, password, etc.) is:
solmaris [256]

The primary source of help for technical problems with BC Online (computer settings, password, etc.) is: The Instructor

<h3>Computer Technical Problems</h3>

         Usually when we have problems on our computers, depending on the type of problem we can call the attention of a technician or follow the advice of an instructor or the message prompt on the software or website.

        However, when it comes to technical problems such as Computer settings or password, we have to make sure we follow the instructions given by the instructor primarily especially because BC Online from the question is a type of Government Registry Information that is used by the citizens with the aid of instructors.

Read more on computer technical problems at;

brainly.com/question/17506968

3 0
2 years ago
HELP ME PLEASE
rosijanka [135]

Answer:

Variable, operator, expression, value.

Explanation:

We could use variables, operators, expressions, and values in a mathematical formula, we're going to do an example with every part.

For this example we're going to use a simple sum formula:

First, we have 3 variables:

sum;

sum1;

sum2;

Second, we have 3 operators:

=, + and *

Third, we have our expression and 1 value:

sum = sum1 + (sum2 * 5);

(sum2 * 5) = expression;

5 = value;

We're going to see the result when we print the variable sum.

8 0
3 years ago
Read 2 more answers
Other questions:
  • During the Requirements Definition stage of a systems development​ project, the employees who will be the primary users of the n
    15·1 answer
  • I have tried installing "windows media player" on my computer but at a point, something disrupts its instalment or I am asked to
    7·1 answer
  • A manager would like information on the knowledge base searches conducted by customers and call center agents. Which two metrics
    10·1 answer
  • A proper divisor of a positive integer $n$ is a positive integer $d &lt; n$ such that $d$ divides $n$ evenly, or alternatively i
    8·1 answer
  • HELP FAST PLEASE
    6·1 answer
  • 1)What is the hydropower resources/energy?
    7·1 answer
  • Create a multimedia project that contains the text element and all the contents that you have studied about that element
    13·1 answer
  • How many levels of heading tags are allowed in html?
    13·2 answers
  • What is the complete path and filename of the file where ports and their associated protocols are defined
    12·1 answer
  • Digital communication and production chapter 17
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!