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 is in percentage e.g
4.5%(f)Get_Monthly_intrest:-return themonthly interest, it is
calculated as balance * Get_Monthly_intrestRate()
________________________________________________________________________________________________________________________________
Write a program simple prints “Wonder of the objects” inside the
main method. Without using any print statement or concrete methods
or dot operators inside the main methods.
_________________________________________________________________________________________________________________________________
Create a class name stock that contains:-1)A String data field name symbol for the stock_ symbol.2)A string data field name of company3)A double data field name previousCloseingPrice that store the stock price for previous day4)A double data field name currentPrice that store the stock price for the current time5)A method getChangepercent() that return the percentage changed in previousCloseingPrice and currentPrice.e.gstock Symbol is ORCL and stock name = Oracle Carporation , the previousCloseingPrice=34.5 and current change price is 34.35 and display the price change percentage.
_____________________________________________________________________________________________________________________________________
Design a class FAN to represent fan . The class contains:-a.Three constants named Slow, Medium and FAST with the values 1,2 and 3 to denote the FAN Speed.b.A private intdata field named speed that specifies the speed of the fan (Default is Slow)c.A private Boolean data field named ‘on’ that specifies whether the fan is on ( the default is false)d.A private double data field named radius that specifies the radius of the fan )default is 5)e.A string data field named colorthat specifies the colorof the fan (the default is blue)f.Define default constructor g.Method tostring() that returns a string description for the fan. If the Fan is on the method returns the fan speed, color, and radiusin one combined string. If fan is not on the method returns the fan colorand radiusalong with the string “fan is off” in one combined string.h.WAP to creates two FAN objects. Assign maximumspeed, radius 10 , color Yellow and turn it on to the first Object . Assign medium speed,radius 5 , color blue and turn it off to the second objects. Display the object by invoking to string method.
Program code to copy
Fan.java
Fan.java
public class Fan
{
public static final int SLOW=1,MEDIUM=2,FAST=3; // static final attributes with constant values
private int speed;
private boolean f_on;
private double radius;
private String color;
Fan()
{
speed=SLOW;
f_on=false;
radius=5;
color="blue";
}
Fan(int speed,double radius,String color,boolean f_on) //Constructor to store values
{
this.speed=speed;
this.radius=radius;
this.color=color;
this.f_on=f_on;
}
public void tostring() // toString method used to return String data of Fan
{
if(f_on==true) // Checking Whether Fan is on/off
{
System.out.println("Fan is on \n the speed is ="+speed+"\n the color is ="+color+"\n the radius is ="+radius);
}
else
{
System.out.println("Fan is off \n the color of fan is ="+color+"\n the radius of fan is ="+radius);
}
}
public static void main(String[] args)
{
Fan obj1 = new Fan(FAST,10,"yellow",true);
Fan obj2 = new Fan(MEDIUM,5,"blue",false);
obj1.tostring();
obj2.tostring();
}
}
Sample output
BankAccount.java
BankAccount.java
import java.io.*;
import java.util.*;
class Bank
{
private String nameOfDepositor;
private int accNum;
private boolean accType;
private double bal, AnnualInterestrate;
void set(String n,int num,boolean acc,double B, double rate)
{
nameOfDepositor=n;accNum=num;accType=acc;bal=B;AnnualInterestrate=rate;
}
void deposit(double d)
{
bal+=d;
}
void withdraw(double w)
{
if(bal>=w && bal-w>50)
bal-=w;
else
System.out.println("Insufficient Balance in your account");
}
void disp()
{
System.out.println("Name of account Holder is :"+nameOfDepositor);
System.out.println("Current Balance in your Savings Bank account is :"+bal );
}
double Get_Monthly_interestRate()
{
AnnualInterestrate=((0.01*AnnualInterestrate)/12);
return AnnualInterestrate;
}
void Get_Monthly_interest()
{
System.out.println("Monthly Interest for the available account balance is Rs. "+bal*Get_Monthly_interestRate());
}
}
public class BankAccount
{
public static void main(String[] args) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Scanner sc=new Scanner(System.in);
System.out.println("\n*******************WELCOME TO JAVA BANK********************");
System.out.print("Please enter your name :");
String s=in.readLine();
System.out.print("\nPlease enter your account number :");
int no=Integer.parseInt(in.readLine());
System.out.print("\nDo you have Savings Account at our branch?");
boolean ss=sc.nextBoolean();
if(ss==true)
{
System.out.println("You can proceed.... ;) ");
}
else
{
sc.close();
}
System.out.print("\nEnter balance of your account: ");
double bl=Double.parseDouble(in.readLine());
System.out.println("Enter Annual Interest Rate in Percentage: ");
double r=sc.nextDouble();
Bank ob=new Bank();
ob.set(s,no,ss,bl,r);
ob.disp();
System.out.print(" YOU WANT TO WITHDRAW MONEY(Y/N) : ");
String w=in.readLine();
if(w.equalsIgnoreCase("y"))
{
System.out.print("\nEnter amount : ");
double amnt=Double.parseDouble(in.readLine());
ob.withdraw(amnt);
ob.disp();
ob.Get_Monthly_interest();
System.out.println("*******************THANKS FOR USING JAVA BANK*****************");
System.exit(0);
}
}
}
sample output
stock_Q6.java
stock_Q6.java
class Stock
{
private String symbol;
private String name;
private double previousClosingPrice;
private double currentPrice;
public Stock(String symbol, String name)
{
this.symbol = symbol;
this.name = name;
}
public String getSymbol()
{
return symbol;
}
public void setSymbol(String symbol)
{
this.symbol = symbol;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public double getCurrentPrice()
{
return currentPrice;
}
public void setCurrentPrice(double currentPrice)
{
this.previousClosingPrice = this.currentPrice;
this.currentPrice = currentPrice;
}
public double getPreviousClosingPrice()
{
return previousClosingPrice;
}
public void setPreviousClosingPrice(double previousClosingPrice)
{
this.previousClosingPrice = previousClosingPrice;
}
public double getChangePercent()
{
return (((currentPrice - previousClosingPrice) / previousClosingPrice)*100);
}
}
public class stock_Q6
{
public static void main(String[] args)
{
Stock stock1 = new Stock("ORCL", "Oracle Corporation");
stock1.setCurrentPrice(34.5);
stock1.setCurrentPrice(34.35);
System.out.println("Stock Name: " + stock1.getName() + " Symbol: " + stock1.getSymbol());
System.out.println("Previous Price: " + stock1.getPreviousClosingPrice());
System.out.println("Current Price: " + stock1.getCurrentPrice());
System.out.println("Percentage Changed: " + stock1.getChangePercent()); //Increase or Decrease in percentage as per the previous price and current price
}
}
sample output
THE FOLLOWING PROGRAM IS NEEDED IN JAVA LANGUAGE Design a class torepresent account, include the following...
please write in Java and include the two classes Design a class named Fan (Fan.java) to represent a fan. The class contains: An int field named speed that specifies the speed of the fan. A boolean field named fanStatus that specifies whether the fan is on (default false). A double field named radius that specifies the radius of the fan (default 5). A string field named color that specifies the color of the fan (default blue). A no-arg (default) constructor...
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...
(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...
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...
9.7 (The Account class) Design a class named Account that contains: • A private int data field named id for the account (default o). • A private double data field named balance for the account (default o). • A private double data field named annualInterestRate that stores the current interest rate (default o). Assume that all accounts have the same interest rate. • A private Date data field named dateCreated that stores the date when the account was created. •...
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...
Design a class named BankAccount that contains: 1. A private int data field named accountId for the account. 2. A private double data field named accountBalance for the account (default 0). 3. A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. 4. A private Date data field named dateCreated that stores the date when the account was created. 5. A private int data field named numberOfDeposits...
PYTHON PROGRAMMING LANGUAGE Design a class named Savings Account that contains: A private int data field named id for the savings account. A private float data field named balance for the savings account. A private float data field named annuallnterestRate that stores the current interest rate. A_init_ that creates an account with the specified id (default 0), initial balance (default 100), and annual interest rate (default 0). . The accessor and mutator methods for id, balance, and annuallnterestRate. A method...
Need help creating a Java program with mandatory requirements! VERY IMPORTANT: The George account class instance must be in the main class, and the requirement of printing a list of transactions for only the ids used when the program runs(Detailed in the Additional simulation requirements) is extremely important! Thank you so very much! Instructions: This homework models after a banking situation with ATM machine. You are required to create three classes, Account, Transaction, and the main class (with the main...
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...