Page 201 - เอกสารประกอบการสอนพื้นฐานการเขียนโปรแกรมคอมพิวเตอร์
P. 201

200



                                                   printf("Years  Reduce         Book Value\n");

                                                   for(n=1;n<=year;n++)
                                                     {
                                                     bookvalue=bookvalue-reduce;
                                                     printf("%d      %.2f       %.2f\n",n,reduce,bookvalue);

                                                     }
                                                   }break;
                                            case 2: {
                                                   printf("input Asset Value ");scanf("%f",&price);

                                                   printf("input Salvage ");scanf("%f",&salvage);
                                                   printf("input Life Time ");scanf("%d",&year);
                                                   for(n=1;n<=year;n++)

                                                      {
                                                       sumyear=sumyear+n;
                                                                    }
                                                   y=year;
                                                   bookvalue=price;

                                                   printf("Years  Reduce         Book Value\n");
                                                   for(n=1;n<=year;n++)
                                                       {

                                                         reduce=(price-salvage)*y/sumyear;
                                                          bookvalue=bookvalue-reduce;
                                                         printf("%d  %.2f  %.2f\n",n,reduce,bookvalue);
                                                         y=y-1;

                                                       }
                                                   }break;
                                            case 3: {
                                                   printf("input Asset Value ");scanf("%f",&price);

                                                   printf("input Life Time ");scanf("%d",&year);
                                                   rate= (100/year)*2;
                                                   printf("rate of reduce =%.2f %%\n",rate);
                                                   bookvalue=price;
   196   197   198   199   200   201   202   203   204   205   206