Java第一次作業
/*
* @(#)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);
}
}
}
相關文章
- JAVA第一次部落格作業Java
- 第一次作業
- 3121001738第一次作業
- 3121003079第一次作業
- 第一次部落格作業
- 第一次結對作業
- 第一次個人作業
- 軟工第一次作業軟工
- 裘立帆-第一次作業
- 柳凱的第一次作業
- 陳志俠第一次作業
- 紀鑫磊第一次作業
- 包珂凡 第一次作業
- 軟體工程第一次作業軟體工程
- OO第一次部落格作業
- oop第一次部落格作業OOP
- wenzhe軟工第一次作業軟工
- 第一次軟體工程作業軟體工程
- ROS第一次課作業分享ROS
- 第一次作業-準備篇
- 第一次作業—準備篇
- OOP第一次作業總結OOP
- 南昌航空大學-22207316-塗高傑-JAVA第一次blog作業Java
- 陳彥吉的第一次作業
- 邱良德的第一次作業
- 2024軟體工程第一次作業軟體工程
- 軟體工程的第一次作業軟體工程
- 3121002760軟體工程第一次作業軟體工程
- gaoliping軟體工程第一次作業軟體工程
- 2021軟體工程第一次作業軟體工程
- 第一次課後作業的提交
- C++ 第一次上機作業C++
- 軟體工程第一次結隊作業軟體工程
- 第一次個人程式設計作業程式設計
- 軟體工程課程第一次作業軟體工程
- 軟體工程第一次個人作業軟體工程
- 第一次作業——圖書管理系統
- 結組作業,第一次衝刺(5)
- [2024SAU]第一次個人作業