のためにバランスを設定するやあみんな、私はATMのプログラムを構築しています、と私はOKマイC ATM
すべてを持っている私はそれがプルアップメニューを持っているオプションを選択することができますし、それは私がすることはできません。しかし、関数を実行します私の人生
残高を設定して 変更されるまでそれを得るようにしてください これはポストテストループなので、2つのオプション(デポジット、引き出し)のいずれかで変更されたら保存する必要があります出口が選択されるまで、そして私が残高を更新するために必要となるたびに継続します。
誰かが驚くべきことを助けることができるなら、ここに私のCコードがあります。
#include <stdio.h>
#include <stdlib.h>
// Function Declarations
int getChoice();
double withdraw (int Choice, int Balance);
double deposit (int Choice, int Balance);
int VBalance (int Choice, int Balance);
double process (int Choice, int Balance);
int main (void)
{
// Local Declarations
int Choice;
int Balance;
// Statements
do
{
Balance = 2500.00;
Choice = getChoice();
process (Choice, Balance);
}
while (Choice != 0);
return 0;
} // Main
/*============================process=*/
double process (int Choice, int Balance)
{
// Declarations
// Statements
switch(Choice)
{
case 1: withdraw (Choice, Balance);
break;
case 2: deposit (Choice, Balance);
break;
case 3: VBalance (Choice, Balance);
break;
case 0: exit;
break;
deafult: printf("Sorry Option Not Offered");
} // switch
return 0;
}
/*============================getChoice=*/
int getChoice (void)
{
// Local Declarations
char Choice;
// Statements
printf("\n\n**********************************");
printf("\n MENU ");
printf("\n\t1.Withdrawl Money ");
printf("\n\t2.Deposit Money ");
printf("\n\t3.View Balance ");
printf("\n\t0.Exit ");
printf("\n**********************************");
printf("\nPlease Type Your Choice Using 0-3");
printf("\nThen Hit Enter: ");
scanf("%d", &Choice);
return Choice;
} //getchoice
/*============================withdraw=*/
double withdraw (int Choice, int Balance)
{
// Local Declarations
double amount;
// Statements
printf("Funds:%d", &Balance);
printf("\nPlease Enter How Much You Would Like To Withdraw: ");
scanf("%f", &amount);
Balance = Balance - amount;
return Balance;
} //withdraw
/*============================Deposit=*/
double deposit (int Choice, int Balance)
{
// Local Declarations
double amount;
// Statements
printf("Funds:%d", &Balance);
printf("\nPlease Enter How Much You Would Like To Deposit: ");
scanf("%f", &amount);
Balance = Balance + amount;
return Balance;
} //Deposit
/*============================VBalance=*/
int VBalance (int Choice, int Balance)
{
// Statements
printf("\nYour Current Funds:%d", &Balance);
printf("\nThank Your For Viewing");
return 0;
}
なぜC#タグですか? – Pikoh
これは、デバッガの使い方を学ぶのに最適な時間です。デバッガを使用すると、変数とその値を監視しながら、コードを1行ずつ進めることができます。 –
「バランスが取れて、変更されるまでそれを維持する」と、この惑星の誰にでも意味がありますか? –