Java Programming (MindTap Course List)
9th Edition
ISBN: 9781337397070
Author: Joyce Farrell
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 6PE
Program Plan Intro
Calculate the area and diameter of Circle
Program plan:
Filename: “Circle.java”
- Define the “Cirle” class
- Declare the required variables.
- Define constructor
- Set the radius value as 1.
- Call the “calc” method.
- Define the “setRadius” method
- Set the value
- Call the “calc” method
- Define the “getRadius” method
- Return the radius
- Define the “getDiameter” method
- Return the diameter
- Define the “getArea” method
- Return the area
- Define the “calc” method
- Calculate the diameter of the circle
- Calculate the area of the circle.
Filename: “TestCircle.java”
- Define the “TestCircle” class
- Define the main method.
- Create the objects for “Circle” class
- Call the “setRadius” method with different values
- Call the “display” method
- Define the “display” method
- Display the radius, diameter, and area of the circle.
- Define the main method.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
PYTHON:
Define the Artist class with a constructor to initialize an artist's information and a print_info() method. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. print_info() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise.
Define the Artwork class with a constructor to initialize an artwork's information and a print_info() method. The constructor should by default initialize the title to "None", the year created to 0, and the artist to use the Artist default constructor parameter values.
Ex: If the input is:
Pablo Picasso 1881 1973 Three Musicians 1921
the output is:
Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921
If the input is:
Brice Marden 1938 -1 Distant Muses 2000
the output is:
Artist: Brice Marden, born 1938 Title: Distant Muses, 2000
I have the code but I am getting errors that I can't seem to get rid of any suggestions would be appreciated
0o.Absolutely answer please
Write a program that calculates the average of courses, overall grade, and letter grade. Suppose that your students take four courses - English, Mathematics, Science, and History. You should design a class that accepts all four course's numeric scores, calculates average and overall grade, and decides letter grade based on the overall grade. Your class should have a constructor, get and set methods of each course, a method that calculates the average of four courses, a method that calculates overall grade, and a method that decides letter grade. The overall grades are calculated as the following rate:
Average of All four courses: 50%
Quiz: 40%
Attendance: 10%
The letter grade is based on the following:
90.0 to 100.0 - A
80.0 to 89.9 - B
70.0 to 79.9 - C
65.0 to 69.9 - D
less than 65 - F
Your program demonstrates the class by asking the user to input four-course numeric scores, creating an object, and then reporting each course's score, average, overall…
Instructions
This assignment must follow directions exactly. Create a class Lab02 with a main method, and put all of the following code into the main method:
Print the prompt shown below and ask the user for the number of exemptions.
The number of exemptions is an integer.
Print the prompt shown below and ask the user for their gross salary.
The gross salary represents dollars, which can be entered with or without decimal points.
Print the prompt shown below and ask the user for their interest income.
The interest income represents dollars, which can be entered with or without decimal points.
Print the prompt shown below and ask the user for their capital gains income.
The capital gains represents dollars, which can be entered with or without decimal points.
Print the prompt shown below and ask the user for the amount of charitable contributions.
The charitable contributions represents dollars, which can be entered with or without decimal points.
Perform the calculation of…
Chapter 4 Solutions
Java Programming (MindTap Course List)
Ch. 4 - Prob. 1RQCh. 4 - Prob. 2RQCh. 4 - Prob. 3RQCh. 4 - Prob. 4RQCh. 4 - Prob. 5RQCh. 4 - Prob. 6RQCh. 4 - Prob. 7RQCh. 4 - Prob. 8RQCh. 4 - Prob. 9RQCh. 4 - Prob. 10RQ
Ch. 4 - Prob. 11RQCh. 4 - Prob. 12RQCh. 4 - Prob. 13RQCh. 4 - Prob. 14RQCh. 4 - Prob. 15RQCh. 4 - Prob. 16RQCh. 4 - Prob. 17RQCh. 4 - Prob. 18RQCh. 4 - Prob. 19RQCh. 4 - Prob. 20RQCh. 4 - Prob. 1PECh. 4 - Prob. 2PECh. 4 - Prob. 3PECh. 4 - Prob. 4PECh. 4 - Prob. 5PECh. 4 - Prob. 6PECh. 4 - Prob. 7PECh. 4 - Prob. 8PECh. 4 - Prob. 9PECh. 4 - Prob. 10PECh. 4 - Prob. 11PECh. 4 - Prob. 1GZCh. 4 - Prob. 2GZ
Knowledge Booster
Similar questions
- Create a class called Point which will have 2 co-ordinate value x & y and will be able to calculate the distance between two points. Write appropriate constructor and method of the class. Create another class called Shape, which takes different number of points to create a triangle, rectangle and circle. And also able to calculate the area and perimeter for the different shapes. Write the appropriate overloading method for this shape class. Write appropriate main function to test the shape class.arrow_forwardThanks in advance. Modify a class named Circle with fields named radius, diameter, and area. Include a constructor that sets the radius to 1 and calculates the other two values. Also include methods named setRadius() and getRadius(). The setRadius() method not only sets the radius, but it also calculates the other two values. (The diameter of a circle is twice the radius, and the area of a circle is pi multiplied by the square of the radius. Use the Math class PI constant for this calculation.) class Circle {private double radius;private double area;private double diameter;Circle() {}public void setRadius(double r) {}public double getRadius() {}private void computeDiameter() {}private void computeArea() {}public double getDiameter() {}public double getArea() {}} class TestCircle {public static void main (String args[]) {Circle a = new Circle();Circle b = new Circle();Circle c = new Circle(); a.setRadius(1.5);b.setRadius(1500.50); System.out.println("The area of a is "…arrow_forwardConstruct a class named Circle with attributes named radius, diameter and area. Include a constructor that sets the radius to 1 and calculates the other two values. Include get and set methods for all the attributes. The setRadius(0 method not only sets the radius, it also calculates the other two values. The diameter of a circle is twice the radius and the area of a circle is pi multiplied by the square of the radius. Use the Math class PI constant for this calculation.arrow_forward
- Java programarrow_forwardCreate a Class Pet with the following data members Identification: String species : String (e.g. cat, dog, fish etc) breed: String Age (in days): int Weight: float Dead: boolean 1. Provide a constructor with parameters for all instance variables. 2. Provide getters for all and setters for only breed, and weight 3. Provide a method growOld() that increases the age of the pet by one day. A dead pet wont grow old 4. Provide a method growHealthy(float w) that increases the weight of the pet by the given amount w. A dead pet cannot grow healthy. 5. Provide a method fallSick(float w) that reduces the weight of the pet by the given amount. The least weight a pet can have is 0 which will mean that the pet has died. If the value of weigh is 10 kg and the method is called with an argument of 11 kg then you will set it to 0 and set the dead to an appropriate value to mark the death of the pet 6. Provide a toString method that shows an appropriate well formatted string…arrow_forwardSlide Type Slide • Exercise # 1: Define a class Point that represents a point in 2 – D plane. The point has x and y coordinates. Define the following: • A constructor to initialize the x, y coordinates. • A method translate(self, dx,dy) to translate the point object dx , and dy units in x and y directions, respectively. • A method distanceTo (self, point2) to return the distance between the point referenced by self and point2. • getX(self) to return the value of x coordinate. • getY(self) to return the value of y coordinate Test the above class by: • Creating 2 point objects; one with (3,5) as x,y coordinates; the second with (-10,30) as x,y coordinates. • Move the first point 5.5 units in x direction and -12.5 units in y direction using translate method • Find the distance between the 2 points in their current location using distance To method A Sample output resulting from running the above test class is shown below new coordinates of point1= (8.5 , -7.5) Coordinates of point 2 =…arrow_forward
- Construct a class named Circle with attributes named radius, diameter and area. Include a constructor that sets the radius to 1 and calculates the other two values. Include get and set methods for all the attributes. The setRadius() method not only sets the radius, it also calculates the other two values. The diameter of a circle is twice the radius and the area of a circle is pi multiplied by the square of the radius. Use the Math class PI constant for this calculation.arrow_forwardApologize for the miscommunication, The language is in Python Create a simple empty Vehicle class. Update the Vehicle class with two instance variables maximum speed and mileage of the car. Create a class variable of the manufacturer and initialize all class and instance variables. different objects among them two are from one manufacturer and the remaining two are from another manufacturer. Write two methods in the class Vehicle, one for displaying the seating capacity of the vehicle and another one is for calculating fuel used by the car by the equation: Maximum Distance Covered / Mileage of the car. and Display the result from the method. Create two children from the Vehicle class: Bus and Car. Both the child classes will inherit all the variables and methods of the Vehicle class. The car class will modify the members of the parent class in their own way and display it from its class object. Bus will be inherited to another class called MiniBus. Create a new method in…arrow_forward2019 AP® COMPUTER SCIENCE A FREE-RESPONSE QUESTIONS 2. This question involves the implementation of a fitness tracking system that is represented by the StepTracker class. A StepTracker object is created with a parameter that defines the minimum number of steps that must be taken for a day to be considered active. The StepTracker class provides a constructor and the following methods. addDailySteps, which accumulates information about steps, in readings taken once per day activeDays, which returns the number of active days averageSteps, which returns the average number of steps per day, calculated by dividing the total number of steps taken by the number of days tracked The following table contains a sample code execution sequence and the corresponding results. Statements and Expressions Value Returned Comment (blank if no value) StepTracker tr StepTracker(10000); Days with at least 10,000 steps are considered active. Assume that the parameter is positive. new tr.activeDays () ; No…arrow_forward
- JAVAWrite a program that calculates the average of courses, overall grade, and letter grade. Suppose that your students take four courses - English, Mathematics, Science, and History. You should design a class that accepts all four course's numeric scores, calculates average and overall grade, and decides letter grade based on the overall grade. Your class should have a constructor, get and set methods of each course, a method that calculates the average of four courses, a method that calculates overall grade, and a method that decides letter grade. The overall grades are calculated as the following rate: Average of All four courses: 50% Quiz: 40% Attendance: 10% The letter grade is based on the following: 90.0 to 100.0 - A 80.0 to 89.9 - B 70.0 to 79.9 - C 65.0 to 69.9 - D less than 65 - F Your program demonstrates the class by asking the user to input four-course numeric scores, creating an object, and then reporting each course's score, average, overall grade, and letter grade.…arrow_forward#this is a python programtopic: operation overloading, Encapsulation please find the attached imagearrow_forwardCan you use it in a scanner so i can copy paste please. Part 1 A regular triangle is one for which all sides are congruent and all interior angles. Create a class RegularTriangle with a field side (int) Create a constructor which accepts an int parameter and will assign the parameter to field side Create assessor and mutator for this class Create a method getPerimeter() which should return 3*side; Part 2 in the constructor, add a logic that if the input parameter is less than 5 then set the side to 5, if it is >10 then set the side to 10, otherwise set the side to the input value. Screenshot final outputarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT