The document describes an example Java program that defines classes for a banking application including accounts, customers, and transactions. Key points:
1) It defines interfaces for interest rates and transactions that account classes can implement.
2) An abstract Account class and concrete SBAccount class that extends Account are defined.
3) A Customer class holds an SBAccount and allows transactions like deposit, withdraw, interest calculation.
4) A BankDemo class demonstrates creating a customer and performing sample transactions.
Slick is a modern database query and access library for Scala. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred. You can write your database queries in Scala instead of SQL, thus profiting from the static checking, compile-time safety and compositionality of Scala. Slick features an extensible query compiler which can generate code for different backends.
This talk covers how to integrate D3 with SVG & Angular to create awesome visualisations, leveraging the modularity of D3 and it's data binding, with angular data binding and the reusability of directives.
Source code for this talk:
https://github.com/adamkleingit/d3-svg-angular
Slick is a modern database query and access library for Scala. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred. You can write your database queries in Scala instead of SQL, thus profiting from the static checking, compile-time safety and compositionality of Scala. Slick features an extensible query compiler which can generate code for different backends.
This talk covers how to integrate D3 with SVG & Angular to create awesome visualisations, leveraging the modularity of D3 and it's data binding, with angular data binding and the reusability of directives.
Source code for this talk:
https://github.com/adamkleingit/d3-svg-angular
I dont know what is wrong with this roulette program I cant seem.pdfarchanaemporium
I don\'t know what is wrong with this roulette program I can\'t seem to get it to run.
Game Class:
public class Game {
public static void main(String[] args) {
Table table = new Table();
BinBuilder bb = new BinBuilder();
Outcome black = new Outcome(\"Black\", 35);
Bet bet = new Bet(10, black);
table.placeBet(bet);
Bin bin = bb.wheel.get(8);
System.out.println(bin.toString());
System.out.println(table.bets.toString());
System.out.println(black.toString());
ListIterator i = table.bets.listIterator();
Iterator b = bin.outcomes.iterator();
while(i.hasNext()) {
System.out.println(i.next().outcome.name.toString());
while(b.hasNext()){
System.out.println(b.next().name.toString());
if(i.next().outcome.equals(b.next())){
System.out.println(\"Win!\");
}
else{
System.out.println(\"Win :/\");
}
}
}
}
}
Player Class
public class Player {
public Table table;
public Outcome black;
public Bet bet;
public Player(Table table) {
table = new Table();
black = new Outcome(\"Black\", 1);
}
void placeBets() {
Bet bet = new Bet(100, black);
table.placeBet(bet);
}
void win(Bet bet) {
System.out.println(\"You\'ve won: \" + bet.winAmount());
}
void lose(Bet bet) {
System.out.println(\"You lost!\" + bet.loseAmount() + \":/\");
}
}
Outcome class
public class Outcome implements Comparable {
public String name;
public int odds;
public Outcome(String name, int odds){
this.name = name;
this.odds = odds;
}
public int winAmount(int amount){
return amount*this.odds;
}
public boolean equals(Outcome other){
return (this.name.equals(other.name));
}
public String toString() {
Object[] values= { name, new Integer(odds) };
String msgTempl= \"{0} ({1}:1)\";
return MessageFormat.format( msgTempl, values );
}
@Override
public int compareTo(E arg0) {
if(this.equals(arg0)){
return 0;
}
return 1;
}
}
Table Class
public class Table {
public int limit = 1000;
public LinkedList bets;
public Table() {
bets = new LinkedList();
}
public boolean isValid(Bet bet) {
int sum = 0;
for(Bet bett: bets) {
sum += bett.amountBet;
}
return (sum>limit);
}
public void placeBet(Bet bet) {
bets.add(bet);
}
ListIterator iterator() {
return bets.listIterator();
}
}
Wheel Class
public class Wheel extends TreeSet {
Vector bins;
NonRandom rng;
Set all_outcomes;
Wheel(NonRandom rng){
this.rng = rng;
rng = new NonRandom();
all_outcomes = new TreeSet();
bins = new Vector(38);
for (int i=0; i<38; i++){
bins.add(i, new Bin());
}
}
Bin next(){
int rand = rng.next(38);
return bins.elementAt(rand);
}
Bin get(int bin){
return bins.elementAt(bin);
}
public Outcome getOutcome( String name ){
TreeSet result= new TreeSet();
for( Iterator i = all_outcomes.iterator(); i.hasNext(); ) {
Outcome oc= i.next();
if( oc.name.contains(name) ) {result.add( oc );}
}
return result.first();
}
public void addOutcome(int bin, Outcome outcome) {
all_outcomes.add(outcome);
this.bins.elementAt(bin).add(outcome);
}
}
Bet Class
public class Bet {
public int amountBet;
public Outcome outcome;
public Bet(int amount, Outcome outcome) {
this.outcome = o.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
2. E:java programing>java BookDemo
BOOK NAME :the yogi
BOOK ID :111
BOOK AUTHOR :baba
Updated details are :
BOOK NAME :titanic
BOOK ID :222
BOOK AUTHOR :cameroon james
3. EXP.NO:-01 LAB EXERCISE:-
import java.lang.*;
import java.util.*;
class Point
{
double x,y;
Point()
{
x=y=0;
}
Point(double a,double b)
{
x=a;y=b;
}
Point(Point l)
{
x=l.x;
y=l.y;
}
double Finddistance(double a,double b)
{
return (Math.sqrt((x-a)*(x-a)+(y-b)*(y-b)));
}
double Finddistance(Point l)
{
return (Math.sqrt((x-l.x)*(x-l.x)+(y-l.y)*(y-l.y)));
}
void display()
{
System.out.println("("+x+ ","+y+ ")");
}
public static void main(String args[])
{
Point p1=new Point(3.25,7.89);
Point p2=new Point(5.37,18.12);
Point p3=new Point(p2);
p1.display();
p2.display();
4. p3.display();
double c=p1.Finddistance(7.9,16.25);
System.out.println("distance between given points and p1 is:"+c);
c=p1.Finddistance(p3);
System.out.println("distance between p1 and p3 is:"+c);
}
}
E:java programing>javac Point.java
E:java programing>java Point
(3.25,7.89)
(5.37,18.12)
(5.37,18.12)
distance between given points and p1 is:9.566195691078036
distance between p1 and p3 is:10.447358517826409
5. EXP.NO:-02 PRELAB EXERCISE:-
SHAPE2D:-
import java.lang.*;
import java.util.*;
abstract class Shape2d
{
double x,y;
Shape2d(double a,double b)
{
x=a;y=b;
}
abstract double area();
abstract void display();
}
class Rectangle extends Shape2d
{
Rectangle(double a,double b)
{
super(a,b);
}
double area()
{
return(x*y);
}
void display()
{
System.out.println("length="+x+"breadth="+y+"Area of rectangle="+area());
}
}
class Triangle extends Shape2d
{
Triangle(double a,double b)
{
super(a,b);
}
double area()
{
return(0.5*x*y);
}
void display()
6. {
System.out.println("length="+x+"breadth="+y+"Area of triangle="+area());
}
}
class Shape2dDemo
{
public static void main(String args[])
{
Shape2d s=new Rectangle(1,2);
s.display();
s=new Triangle(1,2);
s.display();
}
}
E:java programing>javac Shape2dDemo.java
E:java programing>java Shape2dDemo
length=1.0breadth=2.0Area of rectangle=2.0
length=1.0breadth=2.0Area of triangle=1.0
8. void calc_interest()
{
balance+=(0.04*balance);
System.out.println("current balance with one year interest="+balance);
}
}
class Customer
{
int custid;String name,address;
SBAccount m;
Customer(int id,String cname,String caddress,int accno,double initialbalance)
{
custid=id;
name=cname;
address=caddress;
m=new SBAccount(accno,initialbalance);
System.out.println("custid="+id+"n name="+cname+"n address="+caddress + "n
accountno=" +accno +"n balance="+initialbalance);
}
void transaction(int a)
{
Scanner s= new Scanner(System.in);
switch(a)
{
case 1:
System.out.println("enter the amount=");
a=s.nextInt();
m.deposit(a);
break;
case 2:
System.out.println("enter the amount=");
a=s.nextInt();
m.withdraw(a);
break;
case 3:
m.calc_interest();
break;
}
}
9. }
class BankDemo
{
public static void main(String args[])
{
Scanner s= new Scanner(System.in);
int i=0;
Customer c=new Customer(1,"harry","12,herbert town,mars",221003116,50000.00);
while(i!=1)
{
System.out.println("enter 1 for deposit ,n enter 2 for withdraw,n enter 3 for calculating
interest ,n enter 4 for exit :");
int b=s.nextInt();
if(b==4)
{
i=1;
System.out.println("visit again");
}
else
c.transaction(b);
}
}
}
E:java programing>javac BankDemo.java
E:java programing>java BankDemo
custid=1
name=harry
address=12,herbert town,mars
accountno=221003116
balance=50000.0
enter 1 for deposit ,
enter 2 for withdraw,
enter 3 for calculating interest ,
enter 4 for exit :
1
enter the amount=
500
10. current balance=50500.0amount deposited=500.0
enter 1 for deposit ,
enter 2 for withdraw,
enter 3 for calculating interest ,
enter 4 for exit :
2
enter the amount=
300
current balance=50200.0amount withdrawed=300.0
enter 1 for deposit ,
enter 2 for withdraw,
enter 3 for calculating interest ,
enter 4 for exit :
3
current balance with one year interest=52208.0
enter 1 for deposit ,
enter 2 for withdraw,
enter 3 for calculating interest ,
enter 4 for exit :
4
visit again
11. EXP.NO:-03 PRELAB EXERCISE:-
package shape2d;
import java.lang.*;
import java.util.*;
public interface twod
{
double area();
double perimeter();
}
package shape2d;
import java.lang.*;
import java.util.*;
public class Circle implements twod
{
double r;
public Circle(double a)
{
r=a;
}
public double area()
{
return (3.14*r*r);
}
public double perimeter()
{
return (2*3.14*r);
}
}
package shape2d;
import java.lang.*;
import java.util.*;
public class Rectangle implements twod
{
double l,br;
public Rectangle(double a,double b)
{
12. l=a;br=b;
}
public double area()
{
return (l*br);
}
public double perimeter()
{
return (2*(l+br));
}
}
package shape2d;
import java.lang.*;
import java.util.*;
public class Square implements twod
{
double side;
public Square(double x)
{
side=x;
}
public double area()
{
return (side*side);
}
public double perimeter()
{
return (4*side);
}
}
import java.lang.*;
import java.util.*;
import shape2d.*;
class ShapeDemo
{
public static void main(String args[])
{
Circle f=new Circle(1.0);
13. System.out.println("Area of Circle="+f.area());
System.out.println("Perimeter of Circle="+f.perimeter());
Square g=new Square(2.0);
System.out.println("Area of Square="+g.area());
System.out.println("Perimeter of Square ="+g.perimeter());
Rectangle c=new Rectangle(1.0,2.0);
System.out.println("Area of Rectangle="+c.area());
System.out.println("Perimeter of Rectangle="+c.perimeter());
}
}
E:java programing>javac shape2dtwod.java
E:java programing>javac shape2dSquare.java
E:java programing>javac shape2dRectangle.java
E:java programing>javac shape2dCircle.java
E:java programing>javac ShapeDemo.java
E:java programing>java ShapeDemo
Area of Circle=3.14
Perimeter of Circle=6.28
Area of Square=4.0
Perimeter of Square =8.0
Area of Rectangle=2.0
Perimeter of Rectangle=6.0
14. EXP.NO:-03 LAB EXERCISE:-
package pkbanking.pkinterface;
import java.lang.*;
import java.util.*;
public interface InterestRate
{
double sbrate=0.04;
}
package pkbanking.pkinterface;
import java.lang.*;
import java.util.*;
public interface Transaction
{
double min_balance=500.0;
void withdraw(double a);
public void deposit(double a);
}
package pkaccount;
import java.lang.*;
import java.util.*;
abstract public class Account
{
protected int accnumber;
protected double balance;
public Account(int a,double b)
{
accnumber=a;
balance=b;
}
}
package pkaccount.sb;
import java.lang.*;
import pkaccount.*;
import pkbanking.pkinterface.*;
import java.util.*;
public class SBAccount extends Account implements Transaction,InterestRate
15. {
public SBAccount(int an,double ib)
{
super(an,ib);
}
public void deposit(double amount)
{
if(amount>0)
{
balance+=amount;
System.out.println("current balance="+balance+"amount deposited="+amount);
}
}
public void withdraw(double amount)
{
if((balance-amount)>min_balance)
{
balance-=amount;
System.out.println("current balance="+balance+"amount withdrawed="+amount);
}
else
System.out.println("insufficient balance found "+"current balance="+balance+"amount
withdraw request="+amount);
}
public void calc_interest()
{
balance+=(sbrate*balance);
System.out.println("current balance with one year interest="+balance);
}
}
package pkcustomer;
import pkaccount.sb.*;
import java.lang.*;
import java.util.*;
public class Customer
{
int custid;
String name,address;
16. SBAccount m;
public Customer(int id,String cname,String caddress,int accno,double initialbalance)
{
custid=id;
name=cname;
address=caddress;
m=new SBAccount(accno,initialbalance);
System.out.println("custid="+id+"n name="+cname+"n address="+caddress + "n
accountno=" +accno +"n balance="+initialbalance);
}
public void transaction(int a)
{
Scanner s= new Scanner(System.in);
switch(a)
{
case 1:
System.out.println("enter the amount=");
a=s.nextInt();
m.deposit(a);
break;
case 2:
System.out.println("enter the amount=");
a=s.nextInt();
m.withdraw(a);
break;
case 3:
m.calc_interest();
break;
}
}
}
import java.lang.*;
import pkcustomer.*;
import java.util.*;
class BankDemo
{
public static void main(String args[])
{
Scanner s= new Scanner(System.in);
17. int i=0;
Customer c=new Customer(1,"harry","12,herbert town,mars",221003116,50000.00);
while(i!=1)
{
System.out.println("enter 1 for deposit ,n enter 2 for withdraw,n enter 3 for calculating
interest ,n enter 4 for exit :");
int b=s.nextInt();
if(b==4)
{
i=1;
System.out.println("visit again");
}
else
c.transaction(b);
}
}
}
E:java programing>javac pkbankingpkinterfaceInterestRate.java
E:java programing>javac pkbankingpkinterfaceTransaction.java
E:java programing>javac pkaccountAccount.java
E:java programing>javac pkaccountsbSBAccount.java
E:java programing>javac pkcustomerCustomer.java
E:java programing>javac BankDemo.java
E:java programing>java BankDemo
custid=1
name=harry
address=12,herbert town,mars
accountno=221003116
balance=50000.0
enter 1 for deposit ,
enter 2 for withdraw,
enter 3 for calculating interest ,
enter 4 for exit :
1
enter the amount=
500
current balance=50500.0amount deposited=500.0
enter 1 for deposit ,
enter 2 for withdraw,
18. enter 3 for calculating interest ,
enter 4 for exit :
2
enter the amount=
300
current balance=50200.0amount withdrawed=300.0
enter 1 for deposit ,
enter 2 for withdraw,
enter 3 for calculating interest ,
enter 4 for exit :
3
current balance with one year interest=52208.0
enter 1 for deposit ,
enter 2 for withdraw,
enter 3 for calculating interest ,
enter 4 for exit :
4
visit again
20. public static void main(String arg[])
{
try {
int i,y=0,z;Book ob[]=new Book[5];char c;String m,n;
DataInputStream obe=new DataInputStream(System.in);Scanner s=new Scanner(System.in);
ob[0]=new Book("Stephen Hawking","The Nature of Space and Time",1500.00,"Princeton
University Press",1);
ob[1]=new Book("Mazidi","8051microcontroller",600.00,"Dorling Kindersley",4);
ob[2]=new Book("Ali Bahrami","OOSD",300.00,"Tata McGraw Hill",10);
ob[3]=new Book("Rabindranath Tagore","Gitanjali",800.00,"Scribner",8);
ob[4]=new Book("Rabindranath Tagore","The Heart of God",1000.00,"Tuttle Publishing",3);
System.out.println("tDetails of the books are :n ");
for(i=0;i<5;i++)
{
ob[i].display();
}
do{
System.out.println("Enter the Author and Title of the Book : ");
m=obe.readLine();
n=obe.readLine();
for(i=0;i<5;i++)
{
if(ob[i].Author().equals(m))
{
if(ob[i].Title().equals(n))
{
y=1;ob[i].display();
System.out.println("ntEnter the number of copies required :");
z=Integer.parseInt(obe.readLine());
if(z<=ob[i].StockPos()&&z>0)
{System.out.println("Total amount for "+z+" copies of "+n+"Book is="+(z*ob[i].Price()));}
else if(z>ob[i].StockPos())
{ System.out.println("Required copies not in stock");}
else if(z<0)
{throw new IllegalArgumentException("Negative Number is Entered"); }
else if(z==0)
{System.out.println("Have you wont need the Book!");}
}
else
y=0;
21. }
}
if(y==0)System.out.println("Requested Book is not available in the BookShop");
System.out.println("Do You Wish To Buy The Book! [ Press 'n' to come out to the Book Shop
]");
c=s.next().charAt(0);
}while(c!='n');
System.out.println("tVisit Again");
}
catch(Exception e){System.out.println(e.getMessage());}
}
}
C:app>javac BookDemo.java
C:app>java BookDemo
Details of the books are :
BOOK AUTHOR :Stephen Hawking
BOOK TITLE :The Nature of Space and Time
BOOK PRICE :1500.0rupees
BOOK PUBLISHER :Princeton University Press
BOOK STOCK POSITION :1 no.s
BOOK AUTHOR :Mazidi
BOOK TITLE :8051microcontroller
BOOK PRICE :600.0rupees
BOOK PUBLISHER :Dorling Kindersley
BOOK STOCK POSITION :4 no.s
BOOK AUTHOR :Ali Bahrami
BOOK TITLE :OOSD
BOOK PRICE :300.0rupees
BOOK PUBLISHER :Tata McGraw Hill
BOOK STOCK POSITION :10 no.s
BOOK AUTHOR :Rabindranath Tagore
22. BOOK TITLE :Gitanjali
BOOK PRICE :800.0rupees
BOOK PUBLISHER :Scribner
BOOK STOCK POSITION :8 no.s
BOOK AUTHOR :Rabindranath Tagore
BOOK TITLE :The Heart of God
BOOK PRICE :1000.0rupees
BOOK PUBLISHER :Tuttle Publishing
BOOK STOCK POSITION :3 no.s
Enter the Author and Title of the Book :
Mazidi
8051microcontroller
BOOK AUTHOR :Mazidi
BOOK TITLE :8051microcontroller
BOOK PRICE :600.0rupees
BOOK PUBLISHER :Dorling Kindersley
BOOK STOCK POSITION :4 no.s
Enter the number of copies required :
3
Total amount for 3 copies of 8051microcontrollerBook is=1800.0
Do You Wish To Buy The Book! [ Press 'n' to come out to the Book Shop ]
k
Enter the Author and Title of the Book :
Mazidi
8051microcontroller
BOOK AUTHOR :Mazidi
BOOK TITLE :8051microcontroller
BOOK PRICE :600.0rupees
BOOK PUBLISHER :Dorling Kindersley
BOOK STOCK POSITION :4 no.s
Enter the number of copies required :
23. 5
Required copies not in stock
Do You Wish To Buy The Book! [ Press 'n' to come out to the Book Shop ]
l
Enter the Author and Title of the Book :
Mazidi
8051microcontroller
BOOK AUTHOR :Mazidi
BOOK TITLE :8051microcontroller
BOOK PRICE :600.0rupees
BOOK PUBLISHER :Dorling Kindersley
BOOK STOCK POSITION :4 no.s
Enter the number of copies required :
-1
Negative Number is Entered
24. EXP.NO:-04 LAB EXERCISE:-
import java.util.*;
class OperationFailedException extends Exception{
String des;
public OperationFailedException(String d) {
des=d;
}
public OperationFailedException(String d,Throwable e) {
des=d;
System.out.println(" " + ((OperationFailedException)e).des);
}
public String toString(){
return ("Output character = "+des ) ;
}
}
class BadOperandException extends Exception{
int op;
public BadOperandException(int op1) {
op=op1;
}
public String toString(){
return ("Output character = "+op) ;
}
}
class BadOperatorException extends Exception{
char opr;
public BadOperatorException(char opr1) {
opr=opr1;
}
public String toString(){
return ("Output character = "+opr) ;
}
}
class main1
{
26. OperationFailedException e2=new OperationFailedException("INVALID
SECOND OPERAND");
OperationFailedException e1=new OperationFailedException("INVALID
OPERAND",e2);
e1.initCause(new BadOperandException(j));
throw e1;}
}
catch(OperationFailedException f)
{
System.out.println("Caught:"+f);
System.out.println("Caught:"+f.getCause());
}
}
else{
OperationFailedException e2=new OperationFailedException("INVALID FIRST
OPERAND");
OperationFailedException e1=new OperationFailedException("INVALID
OPERAND",e2);
e1.initCause(new BadOperandException(i));
throw e1;}
}
catch(OperationFailedException f)
{
System.out.println("Caught:"+f);
System.out.println("Caught:"+f.getCause());
}
}
}
C:app>javac main1.java
C:app>java main1
Enter two operands and operator as input:
20000
1000
*
20000000
27. C:app>java main1
Enter two operands and operator as input:
1000
1000
*
INVALID FIRST OPERAND
Caught:Output character = INVALID OPERAND
Caught:Output character = 1000
C:app>java main1
Enter two operands and operator as input:
20000
1000
$
Caught:Output character = INVALID OPERATOR
Caught:Output character = $
C:app>java main1
Enter two operands and operator as input:
20000
100
/
INVALID SECOND OPERAND
Caught:Output character = INVALID OPERAND
Caught:Output character = 100
28. EXP.NO:-05 PRELAB EXERCISE:-
import java.lang.*;
import java.util.*;
class factorial extends Thread
{
public void run()
{
try
{
System.out.println("FACTORIAL THREAD PRIORITY = "+this.getPriority());
Scanner s= new Scanner(System.in);
System.out.println("status of multab while completing task is:"+this.isAlive());
System.out.println("Enter the limit of factorial: ");
int n=s.nextInt();
int j=1;
for(int i=1;i<=n;i++)
{
j=j*i;
}
System.out.println("factorial of "+n+"is"+j);
Thread.sleep(500);
}
catch(InterruptedException e){}
}
}
class sum extends Thread
{
public void run()
{
System.out.println("SUM THREAD PRIORITY = "+this.getPriority());
try
{
Scanner s= new Scanner(System.in);
System.out.println("Enter the limit of sum of the series: ");
int n=s.nextInt();
int j=0;
for(int i=1;i<=n;i++)
{
29. j=j+i;
}
System.out.println("sum of the 1 to "+n+" numbers is"+j);
Thread.sleep(500);
}
catch(InterruptedException e){}
}
}
class multab extends Thread
{
public void run()
{
System.out.println("MULTAB THREAD PRIORITY = "+this.getPriority());
try
{
Scanner s= new Scanner(System.in);
System.out.println("Enter the limit of multiplication table: ");
int n=s.nextInt();
System.out.println("Enter the number which has to be multiplied: ");
int k=s.nextInt();
for(int i=1;i<=n;i++)
{
System.out.println(i+"*"+k+"="+(k*i));
Thread.sleep(500);
}
}
catch(InterruptedException e){}
}
}
class ThreadBasic
{
public static void main(String args[]) throws Exception
{
factorial t1=new factorial();
sum t2=new sum();
multab t3=new multab();
t1.setPriority(10);
t2.setPriority(5);
30. t3.setPriority(2);
t1.start();
t1.join();
System.out.println("status of multab after completing task is:"+t1.isAlive());
t2.start();
t2.join();
t3.start();
}
}
E:java programing>javac ThreadBasic.java
E:java programing>java ThreadBasic
FACTORIAL THREAD PRIORITY = 10
status of multab while completing task is:true
Enter the limit of factorial:
5
factorial of 5 is 120
status of multab after completing task is:false
SUM THREAD PRIORITY = 5
Enter the limit of sum of the series:
3
sum of the 1 to 3 numbers is 6
MULTAB THREAD PRIORITY = 2
Enter the limit of multiplication table:
2
Enter the number which has to be multiplied:
3
1*3=3
2*3=6
31. EXP.NO:-05 LAB EXERCISE:-
import java.util.*;
import java.lang.*;
class Queue
{
int q[],front, rear, size, len,m;
public Queue(int n)
{
size=n;
len = 0;
q = new int[size];
front =rear = -1;
}
public boolean isEmpty()
{
return front == -1;
}
public int size()
{
return len ;
}
public void add(int i)
{
if (rear == -1)
{
front = rear = 0;
q[rear] = i;
}
else if ( rear + 1 < size)
q[++rear] = i;
len++ ;
}
public int remove()
{
if (!isEmpty())
{
len-- ;
m = q[front];
if ( front == rear)
32. {
front = rear = -1;
}
else
front++;
} return m;
}
synchronized void get() throws InterruptedException
{
while (isEmpty())
{
Thread.sleep(1000);
System.out.println("Queue is empty " + Thread.currentThread().getName() + " is waiting
, size: " + size());
wait();
}
Thread.sleep(1000);
int i = (Integer) remove();
System.out.println("Consumed: " + i);
notify();
}
synchronized void put(int i) throws InterruptedException
{
while (size() == size)
{
Thread.sleep(1000);
System.out.println("Queue is full " + Thread.currentThread().getName() + " is waiting ,
size: " +size());
wait();
}
Thread.sleep(1000);
add(i);
System.out.println("Produced: " + i);
notify();
}
}
class Producer implements Runnable
{
Queue Qobj;
33. public Producer(Queue obj)
{
this.Qobj = obj;
}
public void run()
{
int counter = 0;
while (true)
{
try{ Qobj.put(counter++); }catch(Exception e){}
}
}
}
class Consumer implements Runnable
{
Queue Qobj;
public Consumer(Queue obj)
{
this.Qobj = obj;
}
public void run()
{
while (true)
{
try{ Qobj.get(); }catch(Exception e){}
}
}
}
public class ProducerConsumer
{
public static void main(String[] args)
{
int QSize = 5;
Queue q=new Queue(QSize);
new Thread(new Producer(q), "Producer").start();
new Thread(new Consumer(q), "Consumer").start();
}
}
34. E:java programing>javac ProducerConsumer.java
E:java programing>java ProducerConsumer
Produced: 0
Produced: 1
Produced: 2
Produced: 3
Produced: 4
Queue is full Producer is waiting , size: 5
Consumed: 0
Consumed: 1
Consumed: 2
Consumed: 3
Consumed: 4
Queue is empty Consumer is waiting , size: 0
Produced: 5
Produced: 6
Produced: 7
Produced: 8
Produced: 9
Queue is full Producer is waiting , size: 5
Consumed: 5
Consumed: 6
Consumed: 7
Consumed: 8
Consumed: 9
Queue is empty Consumer is waiting , size: 0
Produced: 10
Produced: 11
Produced: 12
Produced: 13
Produced: 14
Queue is full Producer is waiting , size: 5
Consumed: 10
.
.
.
36. k.capitalizePlurals(a1);
System.out.println("ArrayList after capitalizePlurals=t"+a1);
k.removePlurals(a1);
System.out.println("ArrayList after removing Plural words=t"+a1);
k.reverse(a1);
System.out.println("ArrayList after reversing the order of the elements in words=t"+a1);
}
public void reverse(ArrayList<String> a1)
{
Collections.reverse(a1);
}
public void capitalizePlurals(ArrayList<String> a1)
{
for(int i=0;i<a1.size();i++)
{
String s=a1.get(i);
if(s.charAt(s.length()-1)=='s')
{
a1.set(i,s.toUpperCase());
}
}
}
public void removePlurals(ArrayList<String> a1)
{
for(int i=0;i<a1.size();i++)
{
String s=a1.get(i);
if((s.charAt(s.length()-1)=='s' )||(s.charAt(s.length()-1)=='S'))
a1.remove(i);
}
}
}
E:java programing>javac ArrayList11.java
E:java programing>java ArrayList11
Original String ArrayList= [hello, photons, sorry, space, comics]
ArrayList after capitalizePlurals= [hello, PHOTONS, sorry, space, COMICS]
ArrayList after removing Plural words= [hello, sorry, space]
ArrayList after reversing the order of the elements in words= [space, sorry, hello]
37. EXP.NO:-06 LAB EXERCISE:-
import java.lang.*;
import java.util.*;
class Point
{
double x,y;
Point()
{
x=y=0;
}
Point(double a,double b)
{
x=a;y=b;
}
Point(Point l)
{
39. double d=t1.Finddistance(t2);
System.out.println("distance between p[" +i+"]"+" and p["+(i+1)+"]"+"points are:"+d);
i++;
}
double d=p2.Finddistance(7.9,16.25);
System.out.println("given points are: ");
p2.display();
System.out.println("distance between given points and p2 is:"+d);
}
}
E:java programing>javac Point.java
E:java programing>java Point
p[1]= (3.25,7.89)
p[2]= (5.37,18.12)
distance between p[1] and p[2]points are:10.447358517826409
p[3]= (5.37,18.12)
p[4]= (0.0,0.0)
distance between p[3] and p[4]points are:18.8989761627449
given points are: (5.37,18.12)
distance between given points and p2 is: 3.146076922136521
EXP.NO:-07 PRELAB EXERCISE:-
import java.util.*;
import java.lang.*;
class TREESET
{
public static void main(String a[])
{
TreeSet<String> a1=new TreeSet<String>();
a1.add("hello");
a1.add("photons");
a1.add("sorry");
a1.add("space");
a1.add("comics");
TREESET k=new TREESET();
40. System.out.println("Original String TREESET=t"+a1);
k.capitalizePlurals(a1);
k.removePlurals(a1);
k.reverse(a1);
}
public void reverse(TreeSet<String> a1)
{
TreeSet <String>treereverse = new TreeSet<String>();
treereverse = (TreeSet)a1.descendingSet();
System.out.println("TREESET after reversing the order of the elements in
words=t"+treereverse);
}
public void capitalizePlurals(TreeSet<String> a1)
{
List<String> list = new ArrayList<String>(a1);
for(int i=0;i<list.size();i++)
{
String s=list.get(i);
if(s.charAt(s.length()-1)=='s')
{
list.set(i,s.toUpperCase());
}
}
a1 = new TreeSet<String>(list);
System.out.println("TREESET after capitalizePlurals = "+a1);
}
public void removePlurals(TreeSet<String> a1)
{
List<String> list = new ArrayList<String>(a1);
for(int i=0;i<list.size();i++)
{
String str=list.get(i);
if(str.charAt(str.length()-1)=='s'|| str.charAt(str.length()-1)=='S')
{
a1.remove(str);
}
}
System.out.println("TREESET after removing plurals = "+a1);
}
}
41. E:java programing>javac TREESET.java
Note: TREESET.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
E:java programing>java KOPT
Original String TREESET= [comics, hello, photons, sorry, space]
TREESET after capitalizePlurals = [COMICS, PHOTONS, hello, sorry, space]
TREESET after removing plurals = [hello, sorry, space]
TREESET after reversing the order of the elements in words= [space, sorry, hello]
EXP.NO:-07 LAB EXERCISE:-
import java.util.*;
import java.lang.*;
class point
{
double x,y;
point(double a,double b)
{
x=a;
y=b;
}
double find_distance(point p)
{
double dis,xd,yd;
xd=x-p.x;
42. yd=y-p.y;
dis=Math.sqrt(xd*xd+yd*yd);
return(dis);
}
void display()
{
System.out.print("("+x+","+y+") ");
}
}
class ComparePts implements Comparator<point>
{
public int compare(point p1,point p2)
{
point org=new point(0,0);
double d1=p1.find_distance(org);
double d2=p2.find_distance(org);
if(d1<d2)return(-1);
if(d1>d2)return(1);
else return(0);
}
}
class HPoint
{
public static void main(String a[])
{
int i;
double x,y,d1;
Scanner s=new Scanner(System.in);
point p[]=new point[10];
HashSet<point> hs=new HashSet<point>();
for(i=0;i<10;i++)
{
System.out.println("Enter x & y for point "+(i+1));
x=s.nextDouble();
y=s.nextDouble();
p[i]=new point(x,y);
hs.add(p[i]);
}
43. TreeSet<point> ts=new TreeSet<point>(new ComparePts());
Iterator t=hs.iterator();
while(t.hasNext())
{
point pt=(point)t.next();
ts.add(pt);
}
System.out.println("Points in ascending Order:");
Iterator t1=ts.iterator();
while(t1.hasNext())
{
point pt=(point)t1.next();
pt.display();
System.out.println();
}
System.out.println("Distance between every pair:");
Iterator it=hs.iterator();
while(it.hasNext())
{
point t3,t2;
t3=(point)it.next();
t2=(point)it.next();
d1=t3.find_distance(t2);
System.out.print("Distance between the points:");
t3.display();
t2.display();
System.out.println(" = "+d1);
}
}
}
E:java programing>javac HPoint.java
E:java programing>java HPoint
Enter x & y for point 1 1 2
Enter x & y for point 2 2 3
Enter x & y for point 3 3 4
Enter x & y for point 4 4 5
Enter x & y for point 5 5 6
Enter x & y for point 6 6 7
44. Enter x & y for point 7 7 8
Enter x & y for point 8 8 9
Enter x & y for point 9 9 10
Enter x & y for point 10 10 11
Points in ascending Order:
(1.0,2.0)
(2.0,3.0)
(3.0,4.0)
(4.0,5.0)
(5.0,6.0)
(6.0,7.0)
(7.0,8.0)
(8.0,9.0)
(9.0,10.0)
(10.0,11.0)
Distance between every pair:
Distance between the points:(5.0,6.0) (1.0,2.0) = 5.656854249492381
Distance between the points:(2.0,3.0) (7.0,8.0) = 7.0710678118654755
Distance between the points:(3.0,4.0) (6.0,7.0) = 4.242640687119285
Distance between the points:(10.0,11.0) (8.0,9.0) = 2.8284271247461903
Distance between the points:(9.0,10.0) (4.0,5.0) = 7.0710678118654755
EXP.NO:-08 LAB EXERCISE:-
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class tank extends Applet implements Runnable,ActionListener
{
int y=200,sf=0,rf=0;
Thread t;
Button b1,b2,b3,b4;
public void init()
{
b1=new Button("Start");
b2=new Button("Stop");
b3=new Button("Resume");