当前位置:网站首页>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();
}

边栏推荐
- C language learning log 10.11
- Reductive elimination
- QT using layout manager is invalid or abnormal
- Article 49: understanding the behavior of new handler
- C language learning log 12.5
- Force deduction 121 questions
- lookup
- Solution to sudden font change in word document editing
- Case - the list set stores student objects and traverses them in three ways
- Section 3 - functions
猜你喜欢

Kaggle time series tutorial

System file interface open

Advanced C - Section 2 - pointers

Ruoyi cloud startup tutorial (hand-held graphics)

Solution to sudden font change in word document editing

使用EasyDarwin+FFmpeg实现rtsp推流

Reductive elimination

Bm1z002fj-evk-001 startup evaluation

QT brushes and brushes

Draw a hammer
随机推荐
What is the saturate operation in opencv
【转载】C语言内存和字符操作函数大全
PostgreSQL Guide: Insider exploration (Chapter 7 heap tuples and index only scanning) - Notes
C language learning log 1.16
【多线程编程】Future接口获取线程执行结果数据
C language learning log 2.19
Explain the role of key attribute in V-for
COAP protocol libcoap API
Regular expressions in QT
Advanced C language - Section 1 - data storage
Sort (internal sort) + external sort
【线程/多线程】线程的执行顺序
Search DFS and BFS
How to lay copper in AD (aluminum designer)
Advanced C - Section 3 - character functions and string functions
C language learning log 12.5
2021tami/ image processing: exploiting deep generative priority for versatile image restoration and manipulation
Brick story
Std:: map insert details
Dup2 use