Professional Documents
Culture Documents
package sample_2;
package sample_2;
import java.util.Scanner;
public class Rectangle extends GeometricShape{
double length;
double width;
void setLen(double l)
{
if(l>0 )
{
length=l;
}
}
void setBred(double b)
{
if(b>0 )
{
width=b;
}
}
double getLen()
{
return(length);
}
double getBred()
{
return(width);
}
public String toString()
{
return("rectangle: length: "+getLen()+" "+"breadth: "+getBred()+"
bordercolour: "+getBor()+" fill: "+getFill()+" fillcolour "+getFillColour()+"
borderwidth: "+getBorderWidth());
}
public void read()
{
Scanner s=new Scanner(System.in);
System.out.println("enter
bordercolour,fillcolour,fill,length,breadth,borderwidth");
bordercolour=s.next();
fillcolour=s.next();
fill=s.nextBoolean();
length=s.nextDouble();
width=s.nextDouble();
borderwidth=s.nextDouble();
setLen(length);
setBred(width);
setBor(bordercolour);
setFillColour(fillcolour);
setBorderWidth(borderwidth);
setFill(fill);
}
}
package sample_2;
import java.util.Scanner;
double getRadius()
{
return(radius);
}
package sample_2;
public class Demo711 {
public static void main(String args[]) {
OUTPUT
enter bordercolour,fillcolour,fill,radius,borderwidth
white
white
true
7.8
2
shape cant be formed
Circle: radius: 7.8 bordercolour: white fill: true fillcolour white borderwidth:
2.0
THE END
post lab
package sample_2;
import java.util.Scanner;
public class Account {
static String an;
static double bal,rate,dare;
void read()
{
Scanner s=new Scanner(System.in);
System.out.println("enter account number,balance,interest rate");
an=s.next();
bal=s.nextDouble();
rate=s.nextDouble();
setbal(bal);
setinterest(rate);
setAC(an);
}
static void setbal(double b)
{
if(b>0)
{
bal=b;
}
static void setinterest(double i)
{
if(i>0)
{
rate=i;
}
static void setAC(String a)
{
if(a.length()==4 && Integer.parseInt(a)>0)
{
an=a;
}
}
static String getAC()
{
return(an);
}
static double getinterest()
{
return(rate);
}
}
package sample_2;
import java.util.Scanner;
public class CheckingAccount extends Account{
void display()
{
read();
Scanner s=new Scanner(System.in);
int choice;
while(true)
{
System.out.println("enter 1: withdraw");
System.out.println("enter 2: deposit");
System.out.println("enter 3:exit");
System.out.println("enter choice");
choice=s.nextInt();
if(choice==1)
{ if(dare<=20000)
withdraw();
else
System.out.println("your overdraft limit is exceeded");
}
if(choice==2)
{
deposit();
}
if(choice==3)
{
System.out.println("TRANSACTION COMPLETED");
break;
}
}
System.out.println(toString());
}
}
package sample_2;
import java.util.Scanner;
public class SavingAccount extends Account{
void display()
{
read();
Scanner s=new Scanner(System.in);
System.out.println("enter choice");
int choice;
while(true)
{
System.out.println("enter 1: withdraw");
System.out.println("enter 2: deposit");
System.out.println("enter 3:exit");
System.out.println("enter choice");
choice=s.nextInt();
if(choice==1)
{ if(bal>0)
withdraw();
else
System.out.println("your account is overdrawn");
}
if(choice==2)
{
deposit();
}
if(choice==3)
{
System.out.println("TRANSACTION COMPLETED");
break;
}
}
System.out.println(toString());
}
}