Blogger templates

Searching...
Tuesday, March 26, 2013

এটিএম বুথ

9:55 AM
সমস্যাটি সমাধান করার জন্য আমাদের প্রোগ্রামিং বিষয়ক গ্রুপ Programmer's Association of CSE 4th Intake এ দিয়েছে আমার  বন্ধু আসির মোসাদ্দেক সাকিব। আমি তার সমাধান এখানে দিলাম।
এটিএম বুথ
------------
রিমির একটি এটিএম কার্ড আছে। সে এটা দিয়ে শপিং এর জন্য টাকা তোলে। তার এই এটিএম কার্ড দিয়ে শুধুমাত্র ৫ এর গুণিতক পরিমাণ টাকা তোলা যায়। প্রতিবার টাকা তোলার জন্য ৪.৫০ টাকা সার্ভিজ চার্জ হিসেবে কেটে নেওয়া হয়। এখন তোমাকে রিমির এটিএম থেকে টাকা তুলার পর কতো টাকা থাকে তা বের করার জন্য একটি প্রোগ্রাম লিখতে হবে।
প্রোগ্রামের শুরুতে ব্যালেন্স কতো আছে তা ইনপুট দিতে হবে।
এরপর কতো টাকা তুলতে ইচ্ছুক তা ইনপুট দিতে হবে।
যদি টাকা উত্তোলন করা সম্ভব হয় তাহলে টাকা উত্তোলন করার পর ব্যালেন্সে কতো হবে তা পর্দায় দেখাতে হবে। যদি ব্যালেন্সের বেশি টাকা উত্তোলন করতে বলা হয় তাহলে দেখাবে Insufficient Balance ! আর যদি ৫ এর গুণিতক না হয় তাহলে দেখাতে হবে Invalid Input!

তিনটি ক্ষেত্রে চলো উদাহরণ দেখে নিইঃ
উদাহরন ১:
------------
What is the current balance: 120
How many money do you want to withdraw: 45
Amount successfully withdrawn!
Current Balance: 70.5

উদাহরন ২:
------------
What is the current balance: 120
How many money do you want to withdraw: 125
Insufficient Balance!
Current Balance: 120

উদাহরন ৩:
------------
What is the current balance: 120
How many money do you want to withdraw: 41
Invalid Input!
Current Balance: 120
 
 
#include <stdio.h>
int main()
{
    int withdraw;
    double balance, charge = 4.5;
    printf("What is the current balance: ");
    scanf("%lf", &balance);
    printf("How many money do you want to withdraw: ");
    scanf("%d", &withdraw);
    if (balance >= (withdraw+charge) && withdraw%5 == 0) {
        printf("Amount successfully withdrawn! \n");
        printf("Current Balance: %0.1lf \n", balance - (charge + withdraw));
    }

    else if ((withdraw+charge)>balance) {
        printf("Insufficient Balance! \nCurrent Balance: %0.1lf \n", balance);
    }

    else {
        printf("Invalid Input! \nCurrent Balance: %0.1lf \n", balance);
    }
    return 0;
}

2 comments:

  1. এতো সুন্দর করে কোড করার জন্য তোমাকে ধন্যবাদ।

    ReplyDelete