当前位置:网站首页>Small project - household income and expenditure software (1)
Small project - household income and expenditure software (1)
2022-06-13 05:05:00 【Jason_ LH1024】
Simple and miscellaneous code :
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
char key=' ';
int loop = 1;
char details[3000]="------------ Current revenue and expenditure details record -----------\n Income and expenditure \t Amount of revenue and expenditure \t Amount of account \t say bright \n";
char note[20]="";// A statement of income or indication
char temp[100]="";// Used to format the income or expenditure each time , Then splice it to details
double money = 0.0;
double balance = 1000.0; // Account balance , Initial value
char choice =' ';// Determine whether to exit y/n
int flag = 0; // Determine whether there are details
do{
printf("\n-------- Family income and expenditure accounting software ----------");
printf("\n 1 Income and expenditure details ");
printf("\n 2 Registered income ");
printf("\n 3 Register expenses ");
printf("\n 4 refund Out ");
printf("\n Please select (1-4):");
scanf("%c",&key);
getchar();// Filter return
switch(key){
case'1':
if(flag){
printf("%s",details);
}else{
printf(" There are currently no details , Please do me a favor !");
}
break;
case'2':
printf("\n The amount of income this time :");
scanf("%lf",&money);
getchar(); // Filter return
balance+=money; // Update amount
printf("\n This income statement :");
scanf("%s",note);
getchar();
sprintf(temp,"\n income \t%.2f\t\t%.2f\t\t\t%s",money,balance,note);// Send this information , Write to temp character
// Joining together to details
strcat(details,temp);
flag = 1;
break;
case'3':
printf("\n The amount of this expenditure is :");
scanf("%lf",&money);
getchar(); // Filter return
if(money>=balance){
printf(" Lack of balance !");
}else {
balance-=money; // Update amount
printf("\n This expenditure statement :");
scanf("%s",note);
getchar();
sprintf(temp,"\n spending \t%.2f\t\t%.2f\t\t\t%s",money,balance,note);// Send this information , Write to temp character
// Joining together to details
strcat(details,temp);
flag = 1;
}
break;
case'4':
printf("\n Are you sure you want to quit ?y/n:");
do{
scanf("%c",&choice);
getchar();
if(choice=='y'||choice=='n'){
break;
}
printf("\n Your input is wrong , Please re-enter y/n:");
} while(1);
if(choice=='y'){
loop = 0;
}
}
}while(loop);
printf(" You have exited the software !");
getchar();
}
边栏推荐
- Simple greedy strategy
- C language learning log 1.2
- COAP protocol libcoap API
- Std:: Map initialization
- Modification and analysis of libcoap source code by Hongmeng device discovery module
- Luogu p1012 guess
- Enhanced for loop
- Explain the role of key attribute in V-for
- C language learning log 10.10
- Time display of the 12th Blue Bridge Cup
猜你喜欢
Section 8 - Practical commissioning techniques
Search DFS and BFS
Configuration used by automatic teaching evaluation script
What is the difference between ROM, ram and flash? SRAM、DRAM、PROM、EPROM、EEPROM
The games that you've tasted
Case - the list set stores student objects and traverses them in three ways
Listiterator list iterator
Section 5 - Operator details
Advanced C - Section 2 - pointers
MySQL8.0.13安装教程(有图)
随机推荐
Std:: Map initialization
Clause 28: understanding reference folding
OpenCV中的saturate操作(饱和操作)究竟是怎么回事
Flex布局自适应失效的问题
Luogu p3654 fisrt step
RT thread console device initialization
Modification and analysis of libcoap source code by Hongmeng device discovery module
CMB's written test -- data analysis
Metartc4.0 integrated ffmpeg compilation
Dynamic and static libraries
Explain the opencv function cv:: add() in detail, and attach sample code and running results of various cases
Sampo Lock
【线程/多线程】线程的执行顺序
C language learning log 11.7
C language learning log 10.5
C language learning log 12.14
Kaggle 时间序列教程
关于匿名内部类
Mind mapping series - Database
CMB written test graphical reasoning