607電腦銷售業績

/******
檔名:JPA06_1.java
題目:TQC+ JAVA6物件導向程式設計 參考答案
時間:2015/06
作者:fang shi mai
******/
public class JPA06_1
{
    public static void main(String args[])
    {
        NB e1 = new NB(1); 
        
        NB e2 = new NB(2);
        
        
    }
}
class NB
{
    String name;
    int cost;
    
    NB(int a)
    {
        if(a==1)
        {
            name="17\"";
            cost=10000;
        }
        else if(a==2)
        {
            name="14\"";
            cost=8500;
        }
        
        this.showData();
    }
    int getCost()
    {
        return cost;
    }
    void showData()
    {
        System.out.printf("一台%s 筆記型電腦的成本:%d\n",name,cost);
    }
}
/******
檔名:JPA06_2.java
題目:TQC+ JAVA6物件導向程式設計 參考答案
時間:2015/06
作者:fang shi mai
******/
public class JPA06_2
{
    public static void main(String args[])
    {

        BasicNB bc = new BasicNB(1,"basic");
        System.out.println("商用電腦成本: " + bc.cost());
        System.out.println("商用電腦售價: " + bc.price());
    
        LuxNB lc = new LuxNB(2,"Lux");
        System.out.println("高階雙核心電腦成本: " + lc.cost());
        System.out.println("高階雙核心電腦售價: " + lc.price());
    }
}
abstract class NB
{
    String name;
    int cost;
    int cpuCost;
    
    NB(int a,String b)
    {
        if(a==1)
        {
            name=b;
            cost=5000;
            cpuCost=1000;
        }
        else if(a==2)
        {
            name=b;
            cost=8500;
            cpuCost=2000;
        }
        
    }
    int getCost()
    {
        return cost;
    }
    void showData()
    {
        System.out.printf("一台%s 筆記型電腦的成本:%d\n",name,cost);
    }
    double price()
    {
        return this.cost()*1.5;
    }
    abstract double cost();
}

class BasicNB extends NB
{
    BasicNB(int a,String b)
    {
        super(a,b);
    }
    double cost()
    {
        return cost+cpuCost+1000;
    }
}
class LuxNB extends NB
{
    LuxNB(int a,String b)
    {
        super(a,b);
    }
    double cost()
    {
        return cost+cpuCost+2000;
    }
}

/******
檔名:JPA06_3.java
題目:TQC+ JAVA6物件導向程式設計 參考答案
時間:2015/06
作者:fang shi mai
******/
public class JPA06_3
{
    public static void main(String[] arge)
    {
        
        String[] map = { "北部" , "中部" , "南部" };
        int[][] salary = {{ 120 , 420 , 315 , 250 , 418,818,900 } , 
                            { 312 , 183 , 215 , 89 , 83,600,700 } , 
                            { 215 , 500 , 430 , 210 , 300,918,880 }};

        
        System.out.println("\n\t  第一電腦科技公司週報表 ( 單 位 : 萬 元 ) ");
        System.out.println( "直營店 \t 一 \t 二 \t 三 \t 四 \t 五 \t六 \t 日 \t  ");
        System.out.println( "=====\t====\t====\t====\t====\t====\t====\t====");
        
        for(int i=0;i<salary.length;i++)
        {
            System.out.print(map[i]);
            for(int j=0;j<salary[i].length;j++)
            {
                System.out.print("\t"+salary[i][j]);
            }
            System.out.print("\n");
        }
    }
}
/******
檔名:JPA06_4.java
題目:TQC+ JAVA6物件導向程式設計 參考答案
時間:2015/06
作者:fang shi mai
******/
public class JPA06_4
{
    public static void main(String[] arge)
    {
        String[] map = { "北部" , "中部" , "南部" };
        int[][] salary = {{ 120 , 420 , 315 , 250 , 418,818,900 } , { 312 , 183 , 215 , 89 , 83,600,700 } , { 215 , 500 , 430 , 210 , 300,918,880 }};
        int cost[] = {1500,1515,1858};
        int sum[] = {0,0,0,0,0,0,0};
        int data[] = {180,200,360};
        int[][]  a_box = salary ;
        
        int i , j , i_max , j_max, min;
        double ratio;
        
        i_max=salary.length;
        j_max=salary[0].length;
        
        for( i = 0 ; i <  i_max ; i++ )
        {
            
            for(j=0;j<j_max;j++)
            {
                sum[i]+=salary[i][j];
            }
            cost[i]+=data[i];
            ratio=(((double)sum[i]-(double)cost[i])/(double)cost[i])*100.0;
            
            System.out.print("\n");            
            System.out.print("第"+(i+1)+"間直營店銷售總成本="+cost[i]);
            System.out.println();
            System.out.print("銷售總營業額="+sum[i]);
            System.out.println();
            System.out.printf("銷售銷售毛利=%.2f",ratio);
            System.out.print("%");
            System.out.println();
            System.out.println();
        }
    }
}
/******
檔名:JPA06_5.java
題目:TQC+ JAVA6物件導向程式設計 參考答案
時間:2015/06
作者:fang shi mai
******/
public class JPA06_5
{
    public static void main(String[] arge)
    {
        
        int[][] salary = {{ 120 , 420 , 315 , 250 , 418,818,900 } , 
                            { 312 , 183 , 215 , 89 , 83,600,700 } , 
                            { 215 , 500 , 430 , 210 , 300,918,880 }};
        
        int i , j , i_max , j_max,cost,sum=0;
        double ratio;
        i_max = salary.length ;
        j_max = salary[0].length ;
        cost=1500+1515+1858+180+200+360;
        
        for( i = 0 ; i <  i_max ; i++ )
        {
            for(j=0;j<j_max;j++)
            {
                sum+=salary[i][j];
            }
        }
        
        
        ratio=(double)(sum-cost)/cost*100;
             
        System.out.print("總銷售總成本="+cost);
        System.out.println();
        System.out.print("總銷售總營業額="+sum);
        System.out.println();
        System.out.printf("總銷售銷售毛利率=%.2f",ratio);
        System.out.print("%");
        System.out.println();
    }
}

沒有留言:

張貼留言