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

199


                       เขียนโปรแกรมโดยใช้ภาษาซี  ค านวณวิธีการคิดค่าเสื่อมราคาสินทรัพย์
                       ตัวโปรแกรม (Source Code)

                              #include<stdio.h>
                              #include<conio.h>
                              #include<stdlib.h>
                              main()

                              {
                              char ans;
                              int choice;
                              float price,salvage,reduce,bookvalue,rate;

                              int year,n,y,sumyear=0;
                              do
                                  {

                                   system("cls");
                                   printf("\nMENU Depreciation\n");
                                   printf("1.Straight-Line\n");
                                   printf("2.Sum of the year\n");
                                   printf("3.Double-Deckububg Balance\n");

                                   printf("4.END\n");
                                   printf("\n");
                                   printf("input your choice [1-4 ONLY] ");scanf("%d",&choice);

                                   switch (choice)
                                            {
                                            case 1: {
                                                   printf("input Asset Value ");scanf("%f",&price);

                                                   printf("input Salvage ");scanf("%f",&salvage);
                                                   printf("input Life Time ");scanf("%d",&year);
                                                   reduce = (price-salvage)/year;
                                                   printf("reduce = %.2f\n",reduce);

                                                   bookvalue=price;
   195   196   197   198   199   200   201   202   203   204   205