import java.util.Scanner;
public class ch0801{
public static void main( String[] args ){
Rectangle r1 = new Rectangle(4,40) ;
Rectangle r2 = new Rectangle(3.5,35.9) ;
System.out.println("Rectangle1 : width = " + r1.width + " , height = " + r1.height + " , area = " + r1.getArea() + " , perimeter = " + r1.getPerimeter() ) ;
System.out.println("Rectangle2 : width = " + r2.width + " , height = " + r2.height + " , area = " + r2.getArea() + " , perimeter = " + r2.getPerimeter() ) ;
}
}
class Rectangle{
double width ;
double height ;
Rectangle(){
width = height = 1 ;
}
Rectangle( double w , double h ){
width = w ;
height = h ;
}
double getArea(){
return width*height ;
}
double getPerimeter(){
return (width+height)*2 ;
}
}
import java.util.Scanner;
public class ch0802{
public static void main( String[] args ){
Stock myStock = new Stock("JAVA","Sum Microsystems Inc") ;
myStock.setPreviousClosingPrice(4.5) ;
myStock.setCurrentPrice(4.35) ;
System.out.println("Has changed " + myStock.getChangePerent() ) ;
}
}
class Stock{
private String symbol ;
private String name ;
private double previousClosingPrice ;
private double currentPrice ;
Stock(){
}
Stock( String symbol , String name ){
this.symbol = symbol ;
this.name = name ;
}
double getChangePerent(){
return (currentPrice-previousClosingPrice)/previousClosingPrice ;
}
void setPreviousClosingPrice( double previousClosingPrice ){
this.previousClosingPrice = previousClosingPrice ;
}
void setCurrentPrice( double currentPrice ){
this.currentPrice = currentPrice ;
}
}
import java.util.Date;
public class ch0803{
public static void main( String[] args ){
Date date = new Date() ;
long goesTime = 10000 ;
int times = 1 ;
while( times <= 8 ){
date.setTime(goesTime);
System.out.println(date.toString()) ;
goesTime = goesTime * 10 ;
times++ ;
}
}
}
import java.util.Random;
public class ch0804{
public static void main( String[] args ){
Random random = new Random(1000) ;
int i = 0 ;
while( i < 50 ){
int x = random.nextInt(100) ;
System.out.println(x) ;
++i ;
}
}
}
import java.util.GregorianCalendar;
public class ch0805{
public static void main( String[] args ){
myGregorianCalendar calendar = new myGregorianCalendar() ;
calendar.show_date() ;
calendar.set(123456789765L) ;
calendar.show_date() ;
}
}
class myGregorianCalendar{
private GregorianCalendar ca ;
private int year ;
private int month ;
private int day ;
myGregorianCalendar(){
ca = new GregorianCalendar() ;
year = ca.get(GregorianCalendar.YEAR) ;
month = ca.get(GregorianCalendar.MONTH) + 1 ;
day = ca.get(GregorianCalendar.DAY_OF_MONTH) ;
}
void sho