|
| 1 | +#include<stdio.h> |
| 2 | +#include<stdlib.h> |
| 3 | +#include<math.h> |
| 4 | +#include<time.h> |
| 5 | +int main() |
| 6 | +{ |
| 7 | + time_t t; |
| 8 | + time(&t); |
| 9 | + printf("This Program has been written at: %s",ctime(&t)); |
| 10 | + |
| 11 | + printf("\n~~~~Simple Profit Calculation~~~~\n\n"); |
| 12 | + |
| 13 | + int ch; |
| 14 | + float p,r,n,a,i; |
| 15 | + float si; |
| 16 | + |
| 17 | + while(1) |
| 18 | + { |
| 19 | + printf("\t 1. Simple Profit \n"); |
| 20 | + printf("\t 2. Profit Rate\n"); |
| 21 | + printf("\t 3. Time-Line \n"); |
| 22 | + printf("\t 4. Exit\n\n"); |
| 23 | + |
| 24 | + printf("Enter your choice : "); |
| 25 | + scanf("%d",&ch); |
| 26 | + |
| 27 | + if(ch>0&&ch<5) |
| 28 | + { |
| 29 | + switch(ch) |
| 30 | + { |
| 31 | + case 1: |
| 32 | + printf("\nEnter Principal Amount: "); |
| 33 | + scanf("%f",&p); |
| 34 | + printf("Enter Rate of Interest: "); |
| 35 | + scanf("%f",&r); |
| 36 | + printf("Enter Time-line: "); |
| 37 | + scanf("%f",&n); |
| 38 | + |
| 39 | + si=(p*r*n)/100; |
| 40 | + printf("\nSimple Profit: %.2f\n",si); |
| 41 | + a=si+p; |
| 42 | + printf("Total Principal Amount: %.2f\n\n",a); |
| 43 | + |
| 44 | + break; |
| 45 | + |
| 46 | + case 2: |
| 47 | + printf("\nEnter Profit: "); |
| 48 | + scanf("%f",&i); |
| 49 | + printf("Enter Principal Amount: "); |
| 50 | + scanf("%f",&p); |
| 51 | + printf("Enter Time-line: "); |
| 52 | + scanf("%f",&n); |
| 53 | + |
| 54 | + r=(i/(p*n))*100; |
| 55 | + printf("Profit Rate: %.f\n\n",r); |
| 56 | + |
| 57 | + break; |
| 58 | + |
| 59 | + case 3: |
| 60 | + printf("\nEnter Profit: "); |
| 61 | + scanf("%f",&i); |
| 62 | + printf("Enter Principal Amount: "); |
| 63 | + scanf("%f",&p); |
| 64 | + printf("Enter Profit rate: "); |
| 65 | + scanf("%f",&r); |
| 66 | + |
| 67 | + n=i/(p*(r/100)); |
| 68 | + printf("Time-line: %.f\n\n",n); |
| 69 | + |
| 70 | + break; |
| 71 | + |
| 72 | + case 4: |
| 73 | + printf("\n\tHave a nice Day!\n\n"); |
| 74 | + exit(0); |
| 75 | + } |
| 76 | + } |
| 77 | + else |
| 78 | + printf("Invalid Choice!\n\n"); |
| 79 | + } |
| 80 | + return 0; |
| 81 | +} |
0 commit comments