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

边栏推荐
- Hidden implementation and decoupling, knowing Pimpl mode
- Four methods for judging JS data types and user-defined methods
- Section 5 - Operator details
- Clause 47: please use traits classes to represent type information
- 135. distribute candy
- System file interface open
- Reductive elimination
- RTSP streaming using easydarwin+ffmpeg
- C language learning log 11.7
- File descriptorfile description
猜你喜欢

Simple sr: Best Buddy Gans for highly detailed image super resolution Paper Analysis

Section 2 - branch and loop statements

Explain the opencv function cv:: add() in detail, and attach sample code and running results of various cases

System file interface open

Simple greedy strategy

Embedded hardware - read schematic

Enhanced for loop

QT client development -- driver loading problem of connecting to MySQL database

Keil uses j-link to burn the code, and an error occurs: Flash download failed - one of the "Cortex-M3" solutions

Explain the role of key attribute in V-for
随机推荐
All blog navigation
Spice story
QT signal is automatically associated with the slot
Common skills in embedded programming
1.2 differences caused by keywords
LeetCode第297场周赛(20220612)
C language learning log 10.8
Article 49: understanding the behavior of new handler
Ruoyi cloud startup tutorial (hand-held graphics)
Flex布局自适应失效的问题
lookup
Section 7 - structures
QT using layout manager is invalid or abnormal
Reductive elimination
Shell variable learning notes
Advanced C - Section 2 - pointers
Mysql8.0.13 installation tutorial (with pictures)
17.6 unique_ Lock details
Clause 33: decltype is used for auto & type formal parameters, with std:: forward
使用EasyDarwin+FFmpeg实现rtsp推流