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
Jasmine is writing a shopping app. She has created a variable to keep track of the number of items in the shopping cart. Everyti
Gemiola [76]

Answer:

b. cart total + 1

Explanation:

A. cart total=1 do increment the total with every 1 click here, it only 're-assigns cart total with value 1 for every click, hence it's always 1.

B. In every click, 1 is always added to the previous value of cart total, like addItemButton(cart total+1) or so.

C. This would have worked too if "cart total" and "cartTotal" where of same type.

D. cart total is just being initially defined here.

E. Likewise here, var shows that cart total has just only been declared.

6 0
2 years ago
Ms. Lawson, a primary school teacher, told her students that a photograph of the president is in the public domain. What does sh
dezoksy [38]

Answer:

He belongs to the nation

7 0
2 years ago
"a web client that connects to a web server, which is in turn connected to a bi application server, is reflective of a"
Bingel [31]

The web client that connects to a web server, which is in turn connected to a bi-application server, is reflective of a one-tier architecture.

<h3>What is a website?</h3>

A website is a collection of web pages and related material that is published on at least one server and given a shared domain name.

A one-tier architecture is reflected in the web application that connects to a web server, which is coupled to a bi-application server.

Thus, the web client that connects to a web server, which is in turn connected to a bi-application server, is reflective of a one-tier architecture.

Learn more about the website here:

brainly.com/question/19459381

#SPJ4

8 0
1 year ago
With the _____, users do not need to be concerned with new software versions and compatibility problems because the application
Simora [160]
The answer is push with the push 
7 0
3 years ago
Read 2 more answers
A technician is troubleshooting a Windows computer and needs to stop the explorer.exe process.Multiple attempts to open Task Man
Kisachek [45]

The technician should Locate the PID for the explorer.exe process using the task-list tool.

Please follow these procedures to restart Explorer.exe from the command prompt:

By selecting the Start button, typing cmd, and then selecting the Command Prompt search result that displays, you can launch a Windows Command Prompt.

Type taskkill /F /IM explorer.exe & start explorer command into the Command Prompt once it has opened, then hit the Enter key on your keyboard. This command will end the explorer.exe process and restart it right away, allowing you to access your desktop once more.

You will observe the Windows desktop briefly disappearing after you enter the command, followed by a restart. The Explorer.exe process has now been restarted, so you can close the Windows Command Prompt.

Learn more about command here-

brainly.com/question/18955190

#SPJ4

4 0
1 year ago
Other questions:
  • Steve wants to become a successful graphic design entrepreneur. Which entrepreneurial approach will help him succeed? A. working
    14·1 answer
  • A blank is the full web Address for particular website<br> (Computer technology)
    14·1 answer
  • How does an agile team maintain requirement?​
    9·2 answers
  • If the physical memory size is doubled without changing any of its other parameters, the number of entries in the page table
    5·1 answer
  • When parking on hills or an unlevel surface, make sure your_____is
    15·2 answers
  • In ____________________ testing, security personnel simulate or perform specific and controlled attacks to compromise or disrupt
    10·1 answer
  • . Which of the following refers to the informal rules for how to behave online? A.
    9·1 answer
  • Based on the information in the table, which of the following tasks is likely to take the longest amount of time when scaled up
    14·1 answer
  • What are the possible consequences of plagiarism?
    15·1 answer
  • What type of block start a sequence?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!