0% found this document useful (0 votes)
16 views3 pages

Chatgpt

This C program simulates basic banking operations including withdrawal, deposit, balance checking, and a simple calculator. Users can choose an option to perform their desired operation, and the program handles input and output accordingly. The program includes error handling for invalid amounts and choices.

Uploaded by

musauelijah522
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Chatgpt

This C program simulates basic banking operations including withdrawal, deposit, balance checking, and a simple calculator. Users can choose an option to perform their desired operation, and the program handles input and output accordingly. The program includes error handling for invalid amounts and choices.

Uploaded by

musauelijah522
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <stdio.

h>
int main()
{
//welcome text
printf("Welcome to casperian bank\n");
printf("Choose the options below");
printf("\n(1)Withdrawal");
printf("\n(2)Deposit");
printf("\n(3)Check balance");
printf("\n(4)Open calculator");
printf("\nOption---> ");

//variables
int balance = 9000;
int newbalance;
int option;
int amount;

//user entry
scanf("%d",&option);

//execution

switch(option)
{

case 1:
printf("\nWithdrawal initated....");
printf("\nEnter amount to withdraw---> ");
scanf("%d",&amount);
if (amount > balance)
{
printf("\nNot enough balance to withdraw %d us dollars",amount);
}
else if (amount <=0)
{
printf("\nCannot withdraw specified amount");
printf("\Error:AmtWith<1 withdrawal terminated");
}
else
{
printf("\nWithdrawal of %d us dollars has been made
successfully",amount);
newbalance = balance - amount;
printf("\nYour new balance is %d us dollars",newbalance);
printf("\nThanks for banking with us");
}
break;

case 2:
printf("\nDeposit has been initiated successfully");
printf("\nEnter amount to be deposited--> ");
scanf("%d",&amount);
if(amount<=0)
{
printf("\nCannot deposit specified amount");
printf("\nError:Amtdep<1 deposit terminated:::");
}
else
{
printf("\nDeposit of %d us dollars has been made successfully",amount);
newbalance = amount + balance;
printf("\nYour new balance is %d us dollars",newbalance);
printf("\nThanks for banking with us");
}

break;

case 3:
printf("\nYour Account Balance");
printf("\nAccount Balance: %d",balance);
printf("\nThanks for banking with us");

break;

case 4:
//user operator entry
printf("\nValue calculator");

printf("\nChoose operator(*) (/) (+) (-): ");


char operator;
scanf("%c",&operator);

//user number entry


int num1;
int num2;

printf("\nEnter operator---> ");


scanf("%d",&num1);
printf("\nEnter second number---> ");
scanf("%d",&num2);
int result;

switch (operator)
{
case '*':
result = num1 * num2;
printf("Result:%d",result);
break;
case '-':
result = num1 - num2;
printf("Result:%d",result);
break;
case '/':
result = num1 / num2;
printf("Result:%d",result);
break;
case '+':
result = num1 + num2;
printf("Result:%d",result);
break;
default:
printf("\nInvalid operator");
}
break;

default:
printf("\ninvalid choice");

return 0;
}

You might also like