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

188


                       เขียนโปรแกรมโดยใช้ภาษาซี  ค านวณหาอัตราการผ่อนช าระค่าสินค้าต่องวด
                       ตัวโปรแกรม (Source Code)

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

                              {
                              char ans;
                              float price,down,leasing,rate,n,interate,total,pay;
                              do

                                   {
                                   printf("input price ==> ");scanf("%f",&price);
                                   printf("input down ==> ");scanf("%f",&down);

                                   leasing=price-down;
                                   printf("*** Leasing = %.2f\n",leasing);
                                   printf("input rate per year ==> ");scanf("%f",&rate);
                                   printf("input number of year ==> ");scanf("%f",&n);
                                   interate=leasing*(rate/100)*n;

                                   printf("*** Interate = %.2f\n",interate);
                                   total=leasing+interate;
                                   printf("*** Total = %.2f\n",total);

                                   pay=total/(n*12);
                                   printf("*** Pay for Month = %.2f\n",pay);
                                   printf("\ndo you want to continue[y/n]==> ");ans=getche();
                                   system("cls");

                                    }
                              while(ans=='y'||ans=='Y');
                              getch();
                              }


                                  โปรแกรม payment.cpp ค านวณหาอัตราการผ่อนช าระค่าสินค้าต่องวด
   184   185   186   187   188   189   190   191   192   193   194