java编程题目

六、编程题。1、某工厂计划今年争取实现净利润500万元以上。该工厂今年第一季度净利润为141.2万元,第二季度净利润为102.3万元,第三季度净利润为118.9万元,第四季度净利润为135.1万元。请编写一个Java源程序,判断该工厂今年全年净利润是否达到目标。

2、从1000到2000这些整数中,找出所有能够被3整除的数,然后把它们输出到屏幕上。

急需答案哦
谢谢大家了啊

这些都是Java编程的基础题,第一道题我给你写的详细点,基本是通过JavaBean的规范来实现的,第二道就很简单了,希望对你有帮助,谢谢了
第一题:
package test.thread;

public class TestRate {
private double first_season_profit;

private double second_season_profit;

private double third_season_profit;

private double fourth_season_profit;

private double plan_year_profit;

/**
* 返回全年的净利润
* @return
*/
private double getYearProfit() {
return first_season_profit + second_season_profit +
third_season_profit + fourth_season_profit;
}

public double getFirst_season_profit() {
return first_season_profit;
}

public void setFirst_season_profit(double firstSeasonProfit) {
first_season_profit = firstSeasonProfit;
}

public double getSecond_season_profit() {
return second_season_profit;
}

public void setSecond_season_profit(double secondSeasonProfit) {
second_season_profit = secondSeasonProfit;
}

public double getThird_season_profit() {
return third_season_profit;
}

public void setThird_season_profit(double thirdSeasonProfit) {
third_season_profit = thirdSeasonProfit;
}

public double getFourth_season_profit() {
return fourth_season_profit;
}

public void setFourth_season_profit(double fourthSeasonProfit) {
fourth_season_profit = fourthSeasonProfit;
}

public double getPlan_year_profit() {
return plan_year_profit;
}

public void setPlan_year_profit(double planYearProfit) {
plan_year_profit = planYearProfit;
}

public static void main(String[] args) {
TestRate test = new TestRate();
test.setFirst_season_profit(141.2);
test.setSecond_season_profit(102.3);
test.setThird_season_profit(118.9);
test.setFourth_season_profit(135.1);
test.setPlan_year_profit(500);
double planYearProfit = test.getPlan_year_profit();
double actualYearProfit = test.getYearProfit();
if (planYearProfit <= actualYearProfit) {
System.out.println("达到预期标准");
} else {
System.out.println("未达到预期标准");
}
}
}

第二题:
package test.thread;

public class TestNumber {
public static void main(String[] args) {
for (int i = 1000; i <= 2000; i++) {
if (i%3 == 0) {
System.out.println("该数能够被3整除,该数是:" + i);
}
}
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-06-08
1.
public class test1
{
public static boolean isTabiao(double d1,double d2,double d3,double d4,double d5)
{
double sun=d1+d2+d3+d4;
if(sun>=d5)
{
return true;
Systen.out.println("全年达标!");
}
else
{
return false;
Systen.out.println("全年未达标!");
}
}
public static void main(String [] args)
{
double total=500;
double first=141.2;
double second=102.3;
double third=118.9;
double fourth=135.1;
isDabiao(fisrt,second,third,fourth,total);
}
}

2.
public class three
{
public static void main(String [] args) {
for(int i=1000;i<=2000;i++)
{
if(i%3==0)
System.out.print(i+"/t");
}
}
}
第2个回答  2011-06-08
第二题:
public class t4 {
public static void main(String[] args) {
for(int i=1000;i<=2000;i++){
if(i%3==0)
System.out.println(i);
}
}
}
相似回答