銀行c語言代碼,銀行管理系統C語言

本文目錄一覽:

怎樣編寫 c語言 銀行賬戶信息管理系統

參考如下:

#include conio.h 

#include string.h 

#include stdio.h 

#include stdlib.h

char cFile[] = “date.txt”;

struct bank

{

char id[10+1];

char psw[6+1];

double money;

};

welcome1()

{

printf(“\n\n\t\t歡迎使用虛擬銀行自動取款機服務!\t\t\n\n”); 

    printf(“請選擇功能:\n”); 

    printf(“\n=================================================\n”); 

    printf(” ||                請輸入序號                  ||\n”); 

    printf(” ||               1.新用戶開戶。               ||\n”); 

    printf(” ||               2.老用戶登陸。               ||\n”);

    printf(” ||               3.退出系統。                 ||\n”); 

    printf(“=================================================\n”); 

}

welcome2()

{

printf(“\n\n\t\t註冊須知\n\n”);

printf(“**************************************************\n”);

printf(“*            1.請填寫您的真實資料!               *\n”);

printf(“*            2.開戶首期必須存入100元以上         *\n”);

printf(“**************************************************\n”);

}

welcome3()

{

printf(“\n\n\t\t\3 歡迎進入虛擬銀行系統 \3\n\n”);

printf(“\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\n”);

printf(“\1\1\t 請選擇功能:1.取款(最多透資2000);     \1\1\n”);

printf(“\1\1\t             2.存款;                   \1\1\n”);

printf(“\1\1\t             3.查詢餘額;               \1\1\n”);

printf(“\1\1\t             4.修改密碼;               \1\1\n”);

printf(“\1\1\t             5.返回主頁面;             \1\1\n”);

printf(“\1\1\t              任意鍵退出.              \1\1\n”);

printf(“\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\n”);

}

int search(char* user, char* pwd, char* real_pwd)/*判斷帳號是否相同,不相同返回1*/

{

    FILE* file;

    char user_buff[256], pwd_buff[256];

    file = fopen(cFile, “r”);

    if (!file) return 0;

    while (!feof(file))

    {    

        if (fscanf(file, “%s%s\n”, user_buff, pwd_buff) == EOF) return 0;

        if (!strcmp(user_buff, user))

        {

            if (real_pwd) strcpy(real_pwd, pwd_buff);

            return 1;

        }

    }

    fclose(file);

    return 0;

}

int add(char* user, char* pwd, double coin_n)

{

    FILE* file;

    file = fopen(cFile, “a”);

    if (!file) return 0;

    fprintf(file, “%s %s %.2lf\n”, user, pwd, coin_n);

    fclose(file);

    return 0;

}

int wenjian(char* user, char* pwd,double coin)

{

    if (search(user, pwd, NULL)) return 0;

    else add(user, pwd, coin);

    return 1;

}

zhuce()/*註冊*/ 

    struct bank *p; 

    int i=0,k=0,judge1,judge2;

    char name[30];

char sex,ch;

char sh[18];

int n;

p=(struct bank*)malloc(sizeof(struct bank));/*給p分配內存*/

    welcome2();

    printf(“請輸入您的名字(純英文):”);

gets(name);

printf(“請輸入您的性別(男:1 女2):”);

fflush(stdin); 

    scanf(“%c”,sex);

    fflush(stdin); 

printf(“請輸入您的身份證號碼:”);

gets(sh);

for(n=0;nstrlen(name);n++)/*判斷輸入信息是否正確*/

{

   if(name[n]=’0’name[n]=’9′)

   { 

    printf(“您輸入的名字有誤!\n”);

    printf(“\n請選擇:按1返回主頁面. 按任意鍵退出:”);

    fflush(stdin);

    scanf(“%c”,ch);

    fflush(stdin);

    if(ch==’1′){system(“cls”);main();}

    else exit(0);

   }

}

if(sex!=’1’sex!=’2′)/*判斷輸入信息是否正確*/

{

   printf(“您輸入的性別不對!\n”);

   printf(“\n請選擇:按1返回主頁面. 按任意鍵退出:”);

   fflush(stdin);

   scanf(“%c”,ch);

     fflush(stdin);

   if(ch==’1′){system(“cls”);main();}

   else exit(0);

}

if(strlen(sh)!=18)/*判斷輸入信息是否正確*/

{   

   printf(“您輸入的身份證號碼不全!\n”);

   printf(“\n請選擇:按1返回主頁面. 按任意鍵退出:”);

     fflush(stdin);

   scanf(“%c”,ch);

   fflush(stdin);

   if(ch==’1′){system(“cls”);main();}

   else exit(0);

}

for(n=0;nstrlen(sh)-1;n++)/*判斷輸入信息是否正確*/

{

   if(sh[n]48||sh[n]57)

   {

    printf(“您輸入的身份證號碼非法!\n”);

    printf(“\n請選擇:按1返回主頁面. 按任意鍵退出:”);

    fflush(stdin);

    scanf(“%c”,ch);

    fflush(stdin);

    if(ch==’1′){system(“cls”);main();}

    else exit(0);

   }

   else

   {

    if(sh[18]!=’x’sh[18]48sh[18]57)

    {

     printf(“您輸入的身份證號碼非法!\n”);

     printf(“\n請選擇:按1返回主頁面. 按任意鍵退出:”);

     fflush(stdin);

       scanf(“%c”,ch);

       fflush(stdin);

       if(ch==’1′){system(“cls”);main();}

       else exit(0);

    }

   }

    printf(“請輸入您的帳號(10位純數字):\n”); 

    fflush(stdin);

    scanf(“%s”,p-id);

    fflush(stdin); 

    while(i strlen(p-id)) 

    { 

        if((p-id[i]  48) || (p-id[i]  57)) 

        { 

            judge1=0; 

        } 

        i++; 

    } 

    while(strlen(p-id)!=10 ||judge1==0)/*判斷帳號的正確性*/ 

    { 

        printf(“您輸入的帳號不正確,必須為10位純數字!”); 

        printf(“請重新輸入(10位純數字):”); 

        fflush(stdin);

        scanf(“%s”,p-id);

        fflush(stdin); 

    } 

    printf(“請輸入您的密碼(6位純數字):\n”); 

    fflush(stdin); 

    scanf(“%s”,p-psw);

    fflush(stdin);

    while(k strlen(p-psw)) 

    { 

        if((p-psw[k]  48) || (p-psw[k]  57)) 

        { 

              judge2=0; 

        } 

         k++; 

     } 

     while(strlen(p-psw)!=6 ||judge2==0)/*判斷密碼形式的正確性*/ 

     { 

         printf(“您輸入不正確!密碼必須為6位純數字!\n”); 

         printf(“請重新輸入密碼(6位純數字):”); 

         fflush(stdin); 

         scanf(“%s”,p-psw);

         fflush(stdin);

     } 

     printf(“請輸入您的首期存款:”);

     fflush(stdin);

     scanf(“%lf”,p-money);

     fflush(stdin);

     while((p-money)100)

     {

          printf(“您必須存入100元以上,請重新輸入:”);

          fflush(stdin);

          scanf(“%lf”,p-money);

          fflush(stdin);

     }

     if (wenjian(p-id,p-psw,p-money))/*存入文件並輸出基本信息*/

     {   

          system(“cls”);

          printf(“註冊成功!”);

          printf(“您的註冊信息如下,請牢記:\n”);

          printf(“名字:”);

          puts(name);

          printf(“性別代碼:%c\n”,sex);

          printf(“身份證號碼:”);

          puts(sh);

          printf(“帳號:”);

          puts(p-id);

          printf(“密碼:”);

          puts(p-psw);

          printf(“您帳戶里的餘額為:%.2lf\n”,p-money);

          printf(“請選擇:按1返回主頁面. 按任意鍵退出:”);

          fflush(stdin);

    scanf(“%c”,ch);

    fflush(stdin);

    if(ch==’1′){system(“cls”);main();}

    else exit(0);

      }

      else/*如有相同帳號,註冊失敗*/

      {

          system(“cls”); 

          printf(“您輸入的帳號已經存在!註冊失敗!\n”);

          printf(“請選擇:按1返回主頁面. 按任意鍵退出:”);

    scanf(“%c”,ch);

       if(ch==’1′){system(“cls”);main();}

    else exit(0);

      } 

gongneng(char Account[10+1],char Password[6+1],double Money)/*登陸成功後的功能界面*/

{

FILE *ps;

struct bank xin[1000];

int k=0,b=0;

char mima[6+1],Chiose,x;

char count[10+1],word[6+1];

double inmoney,outmoney,addmoney;

welcome3();

fflush(stdin);

scanf(“%c”,Chiose);

fflush(stdin);

ps=fopen(cFile,”r”);

if (!ps) 

{

   printf(“不能打開文件!按任意鍵退出!”);

   fflush(stdin);

   scanf(“%c”,x);

   fflush(stdin);

   exit(0); 

}

if(Chiose==’1′)

{

    printf(“輸入您的取款金額:”);

    fflush(stdin);

    scanf(“%lf”,outmoney);

    fflush(stdin);

    while(!feof(ps))

    {

      fscanf(ps, “%s %s %lf”,xin[k].id,xin[k].psw,xin[k].money);

      k++;

    }

    fclose(ps);

    ps=fopen(cFile,”wb”);

    if (!ps) 

    {

   printf(“不能打開文件!按任意鍵退出!”);

   fflush(stdin);

   scanf(“%c”,x);

   fflush(stdin);

   exit(0); 

    }

    

     while(!feof(ps))

    {

       //printf(“%s %s %.2lf\n”,xin[b].id,xin[b].psw,xin[b].money);

       if ((strcmp(Account, xin[b].id)==0)(strcmp(Password, xin[b].psw)==0))

       {

       xin[b].money=xin[b].money-outmoney;

       }

       printf(“%.2lf\n”,xin[b].money);

       fprintf(ps, “%s %s %.2lf\n”, xin[b].id, xin[b].psw, xin[b].money);

       b++;

    } 

}     

}

denglu()/*登陸*/

{

FILE *fp;

char account[10+ 1],password[6 + 1],h;

int m=0;

char real_account[10+ 1];         /* 帳號緩存 */

char real_password[6 + 1];         /* 密碼緩存*/

double real_money_o=0.0;           /*存款緩存*/

printf(“請輸入您的帳號(10位純數字):”);

gets(account);

printf(“請輸入您的密碼(6位純數字):”);

gets(password);

fp = fopen(cFile, “r”);

if (!fp) 

{

   printf(“不能打開文件!按任意鍵退出!”);

   fflush(stdin);

   scanf(“%c”,h);

   fflush(stdin);

   exit(0); 

}

    while (m=2) /*判斷是否輸入錯3次了*/

    {    

while(fscanf(fp, “%s %s %lf”, real_account, real_password,real_money_o) != EOF) /*循環判斷帳號密碼*/

       {

            if ((strcmp(real_account, account)==0)(strcmp(real_password, password)==0)) 

            {     

            system(“cls”);

            printf(“登陸成功!”); 

                 gongneng(real_account,real_password,real_money_o);

                 fclose(fp); 

                 return 0;

            }

        }

    

        rewind(fp); /*重新打開文件,進行新一輪的密碼驗證*/

        printf(“您輸入的帳號不存在或密碼不正確!\n請重新輸入:\n”);

        m++;

        printf(“請輸入您的帳號(10位純數字):”);

        fflush(stdin); 

        gets(account);

        fflush(stdin); 

        printf(“請輸入您的密碼(6位純數字):”);

        fflush(stdin); 

        gets(password); 

        fflush(stdin);

    } 

    fclose(fp);

printf(“您輸入帳號密碼不正確已經3次,您被強制退出系統(按任意鍵退出)!”);

    fflush(stdin);

scanf(“%c”,h);

fflush(stdin);

exit(0);

}

int main() 

{   

    char chiose; 

    welcome1();

    scanf(“%c”,chiose); 

    getchar(); 

    if(chiose =’0′ ||chiose=’4′) 

    { 

        while(chiose =’0′ || chiose=’4′) 

        { 

            printf(“您的輸入有誤,請重新輸入:”); 

            scanf(“%c”,chiose);

            getchar(); 

        } 

    } 

    if(chiose==’1′) 

    { 

        system(“cls”); 

        zhuce();/*註冊*/ 

    } 

    if(chiose==’2′) 

    { 

        system(“cls”); 

        denglu();/*登陸*/ 

    } 

    if(chiose==’3′)

    {   

    printf(“謝謝您的使用!”);

    exit(0);

    }

}

C語言設計銀行賬戶模擬程序

能傳附件嗎?不知道怎麼傳。我就貼給你吧。

#includeiostream

#includestring

#includefstream

using namespace std;

class account //atm賬戶類

{

private:

string CardNum,Psw; //卡號、密碼

float Balance;

public:

friend class ATM; //atm為友元

/*void get_cardnum();

void get_psw();

void get_balance();*/

account(){}//———————here

account(string num,string passwd,float balance); //構造函數

void Write();

};

class ATM //atm機類

{

private:

int times;

account *ac;

public:

ATM(); void load( account *act ); //裝入賬戶信息

void welcome(); //初始歡迎信息

bool check_passwd( string pwd ); //驗證當前賬戶信息的密碼

void change_psw(); //修改密碼

void get_money(); //取錢

float check_balance(); //查賬

void tran(); //轉賬

void exit(); //退卡

void function_show(); //顯示功能菜單

void lock(); //鎖定賬戶

};

/*

* account::account( string num, string passwd, float balance )

* account類構造函數

* 用途: 使用給定的賬號密碼等信息初始化一個account對象

* 參數: string num 賬號

* string passwd 密碼

* float balance

*/

account::account( string num, string passwd, float balance )

{

CardNum = num;

Psw = passwd;

Balance = balance;

}

//atm類構造函數

/*account::get_cardnum()

{

return CardNum;

}

account::get_psw()

{

return Psw;

}

account::get_balance()

{

return Balance;

}*/

void account::Write()

{

ofstream outfile(“atm.txt”,ios::binary);//—————–here

outfile.write((char *)(this),sizeof(account));//————-here

outfile.close();

}

ATM::ATM()

{

}

/*

* void ATM::load( account *act )

* ATM類裝入賬戶信息函數

* 用途: 載入指定的account對象,模擬atm插卡過程

* 參數: account *act 要載入的account對象指針

*/

void ATM::load( account *act )

{

ac = act;

}

/*

* void ATM::welcome()

* ATM類顯示初始歡迎信息函數

* 用途: 顯示歡迎信息,提示密碼輸入並驗證

* 參數: 無

*

*/

void ATM::welcome()

{

times = 0; //記錄密碼輸入錯誤次數

cout “Welcome to use the China Bank ATM!” endl;

string pwd; //這一個語句應該上移的,一般來說數據的定義和初始化一塊寫在開頭,下面才是各種操作的語句

while( times 3 )

{

cout “Please enter the password: ” endl;

cin pwd;

if( !check_passwd( pwd ) )

{

cout “The password you entered is wrong, please enter again” endl;

times++;

}

else

{

function_show();

break;

}

}

if( times = 3 )

lock(); //輸入密碼錯誤次數超過(等於)3次,鎖定賬戶

}

bool ATM::check_passwd( string pwd )

{

if( pwd == ac-Psw )

return true;

else

return false;

}

void ATM::function_show()

{

int n;

cout “(1) Change Password” endl;

cout “(2) Get Money” endl;

cout “(3) Check Balance” endl;

cout “(4) Transfer accounts” endl;

cout “(5) Exit” endl;

cin n;

while(n != 1 n != 2 n != 3 n != 4 n != 5) //這樣就可以完全限制用戶的輸入

{

cout “Please enter the right number” endl;

cin n;

}

switch( n )

{

case 1:

change_psw();

break;

case 2:

get_money();

break;

case 3:

cout check_balance() endl;

break;

case 4:

tran();

break;

case 5:

exit();

break;

}

}

void ATM::lock()

{

cout “Sorry! Your card has been confiscated!” endl;

exit();

}

void ATM::change_psw()

{

string old_psw, new_psw1, new_psw2;

int t = 0 ;

while( t 3 )

{

cout “Please enter the old password: “;

cin old_psw;

if( !check_passwd( old_psw ) )

{

cout “The password you enter is wrong, please enter again” endl;

t++;

}

else

{

cout “Please enter the new password: “;

cin new_psw1;

cout “Please enter the new password again: “;

cin new_psw2;

if( new_psw1 == new_psw2 )

{

ac – Psw = new_psw2;

cout “You have change your password successfully!” endl;

break;

}

else

cout “Sorry, entered passwords do not match! ” endl;

}

}

//}//———————-here

if( t = 3 )

{

cout “Sorry, you have inputed the wrong password for three times and more! ” endl;

}

}

void ATM::get_money()

{

float money;

cout “Please enter the amount of money you want to get: ” endl;

cin money;

while( money ac – Balance)

{

cout “Your balance is not enough, please enter again” endl;

cin money;

}

ac – Balance = ac – Balance – money;

}

float ATM::check_balance()

{

return ac – Balance;

}

void ATM::tran()

{

account a[5];

string cn;

float m;

cout”please enter the cardnum of the account you want to transfer money to”endl;

cincn;

ifstream infile(“atm.txt”,ios::binary);

infile.seekg(0,ios::beg);

for(int i=0;i5;i++)

{

infile.read((char *)(a[i]),sizeof(a[i]));

}

for(int j=0;j5;j++)

{

if(cn==a[i].CardNum)

{

cout”please enter the amount of money”endl;

cinm;

while(mac-Balance)

{

cout”there is no enough money in your account,please enter again”endl;

cinm;

}

ac-Balance=ac-Balance-m;

a[i].Balance=a[i].Balance+m;

ofstream outfile(“atm.txt”,ios::binary);

outfile.seekp(i*sizeof(a[0]),ios::beg);

outfile.write((char *) a[i],sizeof(a[i]));

}

}

if(j=5)

{

cout”the account doesn’t exit”endl;

}

}

void ATM::exit()

{

cout “Please take your card!” endl;

}

int main()

{

account a[5]={account(“10001″,”1111”,5000.0f),account(“10002″,”2222”,10000.0f),account(“10003″,”3333”,15000.0f),

account(“10004″,”4444”,20000.0f),account(“10005″,”5555”,25000.0f)};

account temp( “10001”, “1111”, 5000.0f );

ATM atm;

atm.load( temp );

atm.welcome();

return 0;

}

編寫一個C語言程序模擬銀行ATM機的賬戶管理功能,系統主要實現以下功能

按照你的願意把空都填好了,VC++ 6.0下編譯能通過,有警告信息,運行基本上能用,不過個人認為這個系統有很大的不足,比如輸入賬號的時候沒有輸出反饋信息,以及沒有對誤操作的處理等等。需要的話可以幫你改改!

#include stdio.h

#include conio.h

#include stdlib.h

#include string.h

#define AN 9 //表示賬號8位

#define PN 7 //表示密碼6位

#define ASN 3 //表示系統中共有3個賬戶信息

struct Account

{

char accountnumber[AN]; //表示賬號信息

char password[PN]; //表示賬戶的密碼信息

double balance; //表示賬戶的餘額

};

struct Account ats[ASN]={{“00000001″,”123456”,100},{“00000002″,”123456”,200},{“00000003″,”123456”,300}};

//ats數組用於存儲系統中三個賬戶的信息

int isCorrect(char *an,char *psd)

{

int i;

for(i=0;iASN;i++)

if(strcmp(ats[i].accountnumber,an)==0 strcmp(psd,ats[i].password)==0)

return 1;

return 0;

}

double getBalance(char *an)

{

int i;

for(i=0;iASN;i++)

if(strcmp(an,ats[i].accountnumber)==0)

return ats[i].balance;

}

void deposit(char *an,int amount)

{

int i;

for(i=0;iASN;i++)

if(strcmp(an,ats[i].accountnumber)==0)

ats[i].balance+=amount;

}

int withdraw(char *an,int amount)

{

int i;

for(i=0;iASN;i++)

if(strcmp(an,ats[i].accountnumber)==0)

return ats[i].balance-=amount;

}

void main()

{

char AccountNumber[AN]={‘\0’};

char psd[PN]={‘\0’};

int i,errorcount=0;

while(1)

{

printf(“\n請輸入8位賬號:”);

for(i=0;i8;i++)

AccountNumber[i]=getch();

printf(“\n請輸入6為密碼:”);

for(i=0;i6;i++)

{

psd[i]=getch();

putchar(‘*’);

}

if(isCorrect(AccountNumber,psd)==1)

{

int tag,amount;

while(1)

{

printf(“\n歡迎登錄銀行賬戶管理系統,請選擇您要的服務:1、查詢餘額;2、存款操作;3、取款操作;4、退出系統\n”);

scanf(“%d”,tag);

switch(tag)

{

case 1:

printf(“您現在的餘額為%f元\n”,getBalance(AccountNumber));

break;

case 2:

printf(“請輸入您的存款金額:”);

scanf(“%d”,amount);

deposit(AccountNumber,amount);

printf(“存款成功!您的當前餘額為:%f元\n”,getBalance(AccountNumber));

break;

case 3:

printf(“請輸入您的取款金額:”);

scanf(“%d”,amount);

if(amount=getBalance(AccountNumber))

printf(“取款成功!您的當前餘額為:%f元\n”,withdraw(AccountNumber,amount));

else

printf(“取款失敗!\n”);

break;

case 4:

break;

}

if(tag==4)

break;

}

}

else

{

errorcount++;

if(errorcount==3)

{

printf(“您已經連續三次輸入錯誤,系統將自動關閉\n”);

break;

}

}

}

}

c語言銀行程序

#includemath.h

#includestdio.h

main(){

int a,c,d,e;

float b=10000;

int f;

int num=1;

printf(“\t\t\t CHNIA BANK ATM\nplease input your secret code:\n”);

scanf(“%d”,a);

if(a==num){

printf(” welcome you to use your count,you have %.2f RMB!\n”,b);

printf(” how much money do you want? please input the numbers: “);

scanf(“%d”,e);

printf(“\n”);

c=b-e;

printf(” you till have : %d ,please choose exit or choose function ! \n”,c);

scanf(“%c”,d);

printf(“\n”);

}

else if(a!=num){

printf(“your secret code is wrong,please input the correct secret code!\n”);

}

printf(“\t\t \tHELLO,WELCOME TO USE ATM\nplease choose you want function\n”);

printf(“\n\n”);

printf(“\t\t———————————–\n”);

printf(“\t\t|\t\t|\t\t |\n”);

printf(“\t\t| 1. check\t| 2. withdraw money\t |\n”);

printf(“\t\t|\t\t|\t\t |\n”);

printf(“\t\t———————————–\n”);

printf(“\t\t|\t\t|\t\t |\n”);

printf(“\t\t| 3. transfer account\t| 4. midify secret code|\n”);

printf(“\t\t|\t\t|\t\t |\n”);

printf(“\t\t———————————–\n”);

printf(“\t\t|\t\t\t\t |\n”);

printf(“\t\t|\t 0. exit \t\t |\n”);

printf(“\t\t|\t\t\t\t |\n”);

printf(“\t\t———————————–\n”);

printf(“please choose function:\n “);

scanf(“%d”,f);

switch(f)

{ case 0:printf(“exit”);break;

case 1:printf(“check”);break;

case 2:printf(“withdraw money”);break;

case 3:printf(“transfer account”);break;

case 4:printf(“midify secret code”);break;

default :printf(“it’s wrong,please choose in 0~4!”);

}

getch();

}

有關銀行貸款還貸的c語言程序

你的錯誤實在太多了。看代碼王的程序簡潔易懂

#includestdio.h

#includemath.h

int main()

{

double z,k,x,monthPay,allMoney,temp=0;

int n,i;

printf(“輸入借款總額、貸款年限、年利率: “);

//貸款總和最好不要用int型的,int的最大值是32767,那你豈不是超了

scanf(“%lf%d%lf”,z,n,k);

//計算n年後要還的總的錢數 pow(x,y)是在頭文件math.h中的函數計算x^y

allMoney = z*pow((1+k/12),12*n);

//式子∑x(1+k/12)^i (i=0,1,2,..,n*12-1)將x提出到前面計算 temp=∑(1+k/12)^i

for(i=0; i12*n; i++)

temp += pow((1+k/12),i);

//根據等式z(1+k/12)^(12*n) = ∑x(1+k/12)^i (i=0,1,2,..,n*12-1) 得x=allMoney/temp;

x = allMoney/temp;

printf(“每月應還款:%lf”, x);

}

c語言 銀行貸款的月利率 簡單代碼

#include stdio.h

#includemath.h

main()

{

 double money,capital;

 double rate[4]={0.009,0.01,0.0111,0.012};

 int n;

 printf(“請輸入本金和期限(年)\n”);

 scanf(“%lf%d”,capital,n);

 if(n3)

  money=capital*pow((1+rate[3]),12*n);

 else

  money=capital*pow((1+rate[n-1]),12*n);

 printf(“%d年後本金和利息合計為:%.2lf\n”,n,money); 

}

原創文章,作者:JFEE,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/139032.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
JFEE的頭像JFEE
上一篇 2024-10-04 00:21
下一篇 2024-10-04 00:22

相關推薦

  • 銀行資金管理系統總結

    銀行資金管理系統是銀行日常業務運營的核心支撐系統,主要負責處理銀行的資金流動、結算、清算等業務。本文將從功能特點、技術架構、安全性以及未來發展趨勢等多個方面對銀行資金管理系統進行詳…

    編程 2025-04-29
  • Python周杰倫代碼用法介紹

    本文將從多個方面對Python周杰倫代碼進行詳細的闡述。 一、代碼介紹 from urllib.request import urlopen from bs4 import Bea…

    編程 2025-04-29
  • Python字元串寬度不限制怎麼打代碼

    本文將為大家詳細介紹Python字元串寬度不限制時如何打代碼的幾個方面。 一、保持代碼風格的統一 在Python字元串寬度不限制的情況下,我們可以寫出很長很長的一行代碼。但是,為了…

    編程 2025-04-29
  • Python基礎代碼用法介紹

    本文將從多個方面對Python基礎代碼進行解析和詳細闡述,力求讓讀者深刻理解Python基礎代碼。通過本文的學習,相信大家對Python的學習和應用會更加輕鬆和高效。 一、變數和數…

    編程 2025-04-29
  • AES加密解密演算法的C語言實現

    AES(Advanced Encryption Standard)是一種對稱加密演算法,可用於對數據進行加密和解密。在本篇文章中,我們將介紹C語言中如何實現AES演算法,並對實現過程進…

    編程 2025-04-29
  • 倉庫管理系統代碼設計Python

    這篇文章將詳細探討如何設計一個基於Python的倉庫管理系統。 一、基本需求 在著手設計之前,我們首先需要確定倉庫管理系統的基本需求。 我們可以將需求分為以下幾個方面: 1、庫存管…

    編程 2025-04-29
  • 學習Python對學習C語言有幫助嗎?

    Python和C語言是兩種非常受歡迎的編程語言,在程序開發中都扮演著非常重要的角色。那麼,學習Python對學習C語言有幫助嗎?答案是肯定的。在本文中,我們將從多個角度探討Pyth…

    編程 2025-04-29
  • Python滿天星代碼:讓編程變得更加簡單

    本文將從多個方面詳細闡述Python滿天星代碼,為大家介紹它的優點以及如何在編程中使用。無論是剛剛接觸編程還是資深程序員,都能從中獲得一定的收穫。 一、簡介 Python滿天星代碼…

    編程 2025-04-29
  • 寫代碼新手教程

    本文將從語言選擇、學習方法、編碼規範以及常見問題解答等多個方面,為編程新手提供實用、簡明的教程。 一、語言選擇 作為編程新手,選擇一門編程語言是很關鍵的一步。以下是幾個有代表性的編…

    編程 2025-04-29
  • Python實現簡易心形代碼

    在這個文章中,我們將會介紹如何用Python語言編寫一個非常簡單的代碼來生成一個心形圖案。我們將會從安裝Python開始介紹,逐步深入了解如何實現這一任務。 一、安裝Python …

    編程 2025-04-29

發表回復

登錄後才能評論