/*
* @(#)Card
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.java_homework.HW1.Part1;
/**
* Java平时作业1,第一部分
* @version 1.0.0.0 Feb 25, 2008
* @author eleven
*/
public class Card {
public void Card(String name, String address, String email, String phone) {
System.out.println("--------------------------------");
System.out.println("Name: " + name);
System.out.println("Address: " + address);
System.out.println("Email: " + email);
System.out.println("Phone: " + phone);
System.out.println("--------------------------------");
}
public static void main(String[] args) {
Card card = new Card();
card.Card("Eleven", "Software School, Yunnan University", "eleven026@gmail.com", "12888546307");
}
}
/*
* @(#)ComputeInterest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.java_homework.HW1.Part2;
/**
* Java平时作业,第一次第2部分,计算利息
* @version 1.0.0.0 Feb 25, 2008
* @author eleven
*/
public class ComputeInterest {
private double interestRate = 0.05;
private static double balance;
public ComputeInterest() {
System.out.println("-------------------------------------------------------------");
System.out.println("The balance is " + balance);
System.out.println("---");
double newbalance_year1 = balance * (1 + interestRate);
System.out.println("The balance at the end of the first year is " + newbalance_year1);
double newbalance_year2 = newbalance_year1 * (1 + interestRate);
System.out.println("The balance at the end of the second year is " + newbalance_year2);
double newbalance_year3 = newbalance_year2 * (1 + interestRate);
System.out.println("The balance at the end of the third year is " + newbalance_year3);
double newbalance_year4 = newbalance_year3 * (1 + interestRate);
System.out.println("The balance at the end of the forth year is " + newbalance_year4);
double newbalance_year5 = newbalance_year4 * (1 + interestRate);
System.out.println("The balance at the end of the fifth year is " + newbalance_year5);
System.out.println("-------------------------------------------------------------");
}
public static void main(String[] args) {
balance = 10000;
ComputeInterest computeInterest = new ComputeInterest();
}
}
/*
* @(#)PrimeGenerator
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.java_homework.HW1.Part3;
/**
* Java平时作业,第一次第3部分,产生素数
* @version 1.0.0.0 Mar 11, 2008
* @author eleven
*/
public class PrimeGenerator {
/**
* 根据给出的起始数字,判断并产生素数
*/
public int IsPrime(int number) {
int returnValue = 0;
if (number == 2) {
returnValue = 1;
} else {
for (int i = 2; i < number; i++) {
if (number % i != 0) {
returnValue = 1;
} else {
returnValue = 0;
break;
}
}
}
return returnValue;
}
}
/*
* @(#)GetPrime
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.java_homework.HW1.Part3;
import java.util.ArrayList;
import java.util.List;
/**
* Java平时作业,第一次第3部分,得到素数
* @version 1.0.0.0 Mar 12, 2008
* @author eleven
*/
public class GetPrime {
/**
* 根据给出的起始数字,调用PrimeGenerator类中的IsPrime()方法对起始数字之间的所有数字进行判断,
* 并将判断的素数保存到ArrayList中,供Prime类调用。
*/
public List GetPrime(int startNumber, int endNumber) {
List primeArrayList = new ArrayList();
PrimeGenerator primeGenerator = new PrimeGenerator();
for (int i = startNumber; i <= endNumber; i++) {
if (primeGenerator.IsPrime(i) == 1) {
primeArrayList.add(i);
}
}
System.out.println("The Primes you want to get between " + startNumber + " and " + endNumber + " are");
return primeArrayList;
}
}
/*
* @(#)Prime
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.java_homework.HW1.Part3;
import java.util.List;
/**
* Java平时作业,第一次第3部分,main函数
* @version 1.0.0.0 Mar 12, 2008
* @author eleven
*/
public class Prime {
public static void main(String[] args) {
GetPrime getPrime = new GetPrime();
List prime = getPrime.GetPrime(1, 100);
for (Object primeNumber : prime) {
System.out.println(primeNumber);
}
}
}
* @(#)Card
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.java_homework.HW1.Part1;
/**
* Java平时作业1,第一部分
* @version 1.0.0.0 Feb 25, 2008
* @author eleven
*/
public class Card {
public void Card(String name, String address, String email, String phone) {
System.out.println("--------------------------------");
System.out.println("Name: " + name);
System.out.println("Address: " + address);
System.out.println("Email: " + email);
System.out.println("Phone: " + phone);
System.out.println("--------------------------------");
}
public static void main(String[] args) {
Card card = new Card();
card.Card("Eleven", "Software School, Yunnan University", "eleven026@gmail.com", "12888546307");
}
}
/*
* @(#)ComputeInterest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.java_homework.HW1.Part2;
/**
* Java平时作业,第一次第2部分,计算利息
* @version 1.0.0.0 Feb 25, 2008
* @author eleven
*/
public class ComputeInterest {
private double interestRate = 0.05;
private static double balance;
public ComputeInterest() {
System.out.println("-------------------------------------------------------------");
System.out.println("The balance is " + balance);
System.out.println("---");
double newbalance_year1 = balance * (1 + interestRate);
System.out.println("The balance at the end of the first year is " + newbalance_year1);
double newbalance_year2 = newbalance_year1 * (1 + interestRate);
System.out.println("The balance at the end of the second year is " + newbalance_year2);
double newbalance_year3 = newbalance_year2 * (1 + interestRate);
System.out.println("The balance at the end of the third year is " + newbalance_year3);
double newbalance_year4 = newbalance_year3 * (1 + interestRate);
System.out.println("The balance at the end of the forth year is " + newbalance_year4);
double newbalance_year5 = newbalance_year4 * (1 + interestRate);
System.out.println("The balance at the end of the fifth year is " + newbalance_year5);
System.out.println("-------------------------------------------------------------");
}
public static void main(String[] args) {
balance = 10000;
ComputeInterest computeInterest = new ComputeInterest();
}
}
/*
* @(#)PrimeGenerator
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.java_homework.HW1.Part3;
/**
* Java平时作业,第一次第3部分,产生素数
* @version 1.0.0.0 Mar 11, 2008
* @author eleven
*/
public class PrimeGenerator {
/**
* 根据给出的起始数字,判断并产生素数
*/
public int IsPrime(int number) {
int returnValue = 0;
if (number == 2) {
returnValue = 1;
} else {
for (int i = 2; i < number; i++) {
if (number % i != 0) {
returnValue = 1;
} else {
returnValue = 0;
break;
}
}
}
return returnValue;
}
}
/*
* @(#)GetPrime
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.java_homework.HW1.Part3;
import java.util.ArrayList;
import java.util.List;
/**
* Java平时作业,第一次第3部分,得到素数
* @version 1.0.0.0 Mar 12, 2008
* @author eleven
*/
public class GetPrime {
/**
* 根据给出的起始数字,调用PrimeGenerator类中的IsPrime()方法对起始数字之间的所有数字进行判断,
* 并将判断的素数保存到ArrayList中,供Prime类调用。
*/
public List GetPrime(int startNumber, int endNumber) {
List primeArrayList = new ArrayList();
PrimeGenerator primeGenerator = new PrimeGenerator();
for (int i = startNumber; i <= endNumber; i++) {
if (primeGenerator.IsPrime(i) == 1) {
primeArrayList.add(i);
}
}
System.out.println("The Primes you want to get between " + startNumber + " and " + endNumber + " are");
return primeArrayList;
}
}
/*
* @(#)Prime
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.java_homework.HW1.Part3;
import java.util.List;
/**
* Java平时作业,第一次第3部分,main函数
* @version 1.0.0.0 Mar 12, 2008
* @author eleven
*/
public class Prime {
public static void main(String[] args) {
GetPrime getPrime = new GetPrime();
List prime = getPrime.GetPrime(1, 100);
for (Object primeNumber : prime) {
System.out.println(primeNumber);
}
}
}