Fan.java
public class Fan {
// Attributes of Fan Class
private int speed;
private boolean fanStatus = false;
private double radius = 5;
String color = "blue";
// default Constructor
public Fan() {
}
// Parameterized Constructor
public Fan(int speed, boolean fanStatus, double
radius, String color) {
this.speed = speed;
this.fanStatus = fanStatus;
this.radius = radius;
this.color = color;
}
// Setters and Getters
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public boolean isFanStatus() {
return fanStatus;
}
public void setFanStatus(boolean fanStatus) {
this.fanStatus = fanStatus;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
// toString method used to return String data of
Fan
@Override
public String toString() {
String onOrOff;
if (isFanStatus())
onOrOff =
"on";
else
onOrOff =
"off";
if (isFanStatus()) { // Checking
Whether Fan is on/off
return "A " +
this.getRadius() + " inch " + this.getColor()+ " fan at a speed of
" + this.getSpeed();
} else {
return "A " +
this.radius + " inch " + this.getColor()+ " fan; fan is " +
onOrOff;
}
}
}
___________________
TestFan.java
import java.util.Scanner;
public class TestFan {
public static void main(String[] args) {
// Declaring variables
int speed;
boolean fanStatus;
double radius;
String color;
// Scanner object is used to get
the inputs entered by the user
Scanner sc = new
Scanner(System.in);
// Getting the inputs entered by
the user
System.out.print("Enter the speed
of the fan :");
speed = sc.nextInt();
System.out.print("Enter the Fan
Status :");
fanStatus = sc.nextBoolean();
System.out.print("Enter the
radius of the fan :");
radius = sc.nextDouble();
System.out.print("Enter the
color of the fan :");
color = sc.next();
// Creating the Fan class object
by passing the user inputs as arguments
Fan f = new Fan(speed, fanStatus,
radius, color);
// Displaying the Fan class
object Info
System.out.println(f.toString());
}
}
___________________
Output#1:
Enter the speed of the fan :3
Enter the Fan Status :true
Enter the radius of the fan :6.5
Enter the color of the fan :green
A 6.5 inch green fan at a speed of 3
_____________
Output#2:
Enter the speed of the fan :2
Enter the Fan Status :false
Enter the radius of the fan :4.0
Enter the color of the fan :orange
A 4.0 inch orange fan; fan is off
_____________Thank You
please write in Java and include the two classes Design a class named Fan (Fan.java) to...
THE FOLLOWING PROGRAM IS NEEDED IN JAVA LANGUAGE Design a class torepresent account, include the following members: -Data Members a)Name of depositor-Stringb)Account Number –intc)Type of account –Boolean d)Balance amount -doublee)AnnualInterestrate -double Methods: -(a)To assign initial values (use constructor)(b)To deposit an amount.(c)TO withdraw amount with the restriction the minimum balance is 50 rs. Ifyouwithdraw amount reduced the balance below 50 then print the error message.(d)Display the name and balance of the account.(e)Get_Monthly_intrestRate() -Return the monthly interestrate whichis nothing but Annualintrestrate/12. Annualinterestrate...
1. Please write the following program in Python 3. Also, please create a UML and write the test program. Please show all outputs. (The Fan class) Design a class named Fan to represent a fan. The class contains: Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speed. A private int data field named speed that specifies the speed of the fan. A private bool data field named on that specifies...
C++ FanClass.cpp Design a class named Fan to represent a fan. The class contains: Private section: An integer data field name speed that specifies the speed of the fan (1, 2, 3 or custom) A bool data field named on that specified whether the fan is on by default. A double data field named radius that specifies the radius of the fan A string data field named color that specifies the color of the fan. Public section: - Declare the...
Please include comments in the program .The program must be able to be compiled.Design a class named Triangle that extends GeometricObject. This class contains:* Three double data fields named side1, side2, and side3 with default values 1.0 to denote the three sides of a triangle.* A no-arg constructor that creates a default triangle.* A constructor that creates a triangle with the specified side1, side2, and side3.* The accessor methods for all three data fields.* A method named getArea() that returns...
Language is JAVA. Clarification for the Shape class (highlighted): The following requirements specify what fields you are expected to implement in your Shape class; - A private String color that specifies the color of the shape - A private boolean filled that specifies whether the shape is filled - A private date (java.util.date) field dateCreated that specifies the date the shape was created Your Shape class will provide the following constructors; - A two-arg constructor that creates a shape with...
Help please 1) Define a Java class for defining the activity of a TV set. The class contains A private int data field named channel that specifies what channel is currently set for the tuner (channels range from 1 to 120, default is 1) a. b. A private int data field named volumeLevel that specifies the volume level of the TV (range is 1 to 7; default is 1) A private boolean data field named on that determines whether the...
JAVA design a class named Rectangle to represent a rectangle. The class contains: A method named getPerimeter() that returns the perimeter. Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. A no-arg constructor that creates a default rectangle. A constructor that creates a rectangle with the specified width and height. A method named getArea() that returns the area of this rectangle. design...
Following the example of the Circle class in Section 8.2, design a class named Rectangle to represent a rectangle. The class contains: ■ Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. ■ A no-arg constructor that creates a default rectangle. ■ A constructor that creates a rectangle with the specified width and height. ■ A method named getArea() that returns the...
(The Account class) Design a class named Account that contains: A private int data field named id for the account (default 0). A private double data field named balance for the account (default 0). A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. A private Date data field named dateCreated that stores the date when the account was created. A no-arg constructor that creates a default...
Problem 2 (36 pts): You are going to design a class named Computer. The class contains: A string field named manufacturer. A string field named serialNumber. A double field named speed (measured in Gigahertz). A constructor that has a parameter for each data field and sets the data fields with these values. A no-arg constructor that sets string fieldsto and numeric fields to 0. Mutator and Accessor methods for each data field. A method toString) that returns each field value...