What Will I Learn?
Create a Payment App
Requirements
Dev C++ 5.11
Difficulty
- Intermediate
Tutorial Contents
Theory
The store is a place used for business for buying and selling goods. In the store a lot of shopping materials that can be purchased in accordance with the needs.
At this point I will try to create an app for the store. This application will be used on the cashier. Usefulness of this application to determine the purchase price of an item in accordance with the order.
Every price of goods already in the input will be displayed the price. Regardless of the amount everything will be automatically listed on the end result.
Okay now we will try to make the application.
Now will make the project for the price list of goods that correspond with the data input.
Here I use C Language in Programming.
Follow the following program code.
int main(void){
int totalOil, totalBread, totalfragrance, totalSampoo, totalPaper, TotalCleanser, totalSoap, TotalMarkers, totalSnack, TotalBeans, Price, Pay, Rest;
char j;
printf("\nWELCOME TO CUTHAMZA SHOP\n");
printf("\n");
printf("------------------------------------\n");
printf("\nGoods Purchase List:\n");
printf("\n1. Cooking oil : "); scanf("%d", &totalOil);
printf("2. Bread : "); scanf("%d", &totalBread);
printf("3. Fragrances : "); scanf("%d", &totalfragrance);
printf("4. Sampoo : "); scanf("%d", &totalSampoo);
printf("5. Wrapping paper : "); scanf("%d", &totalPaper);
printf("6. Cleaners : "); scanf("%d", &TotalCleanser);
printf("7. Soap : "); scanf("%d", &totalSoap);
printf("8. Marker : "); scanf("%d", &TotalMarkers);
printf("9. Snacks : "); scanf("%d", &totalSnack);
printf("10.Beans : "); scanf("%d", &TotalBeans);
if (totalOil>=0 && totalBread>=0 && totalfragrance>=0 && totalSampoo>=0 && totalPaper>=0 && TotalCleanser>=0 && totalSoap>=0 && TotalMarkers>=0 && totalSnack>=0 && TotalBeans>=0){ Price=(9500*totalOil)+(8700*totalBread)+(500*totalfragrance)+(7500*totalSampoo)+(200*totalPaper)+(12000*TotalCleanser)+(3500*totalSoap)+(6000*TotalMarkers)+(500*totalSnack)+(4500*TotalBeans);
Pay:
printf("\n\nTotal Payment Is : $.%d",Price);
printf("\nPayment : $."); scanf("%d", &Pay);
if (Pay>=Price && Pay>=0){
printf("REST : $.%d",Rest=Pay-Price);
printf("\n\nTHANK YOU FOR YOUR TRUST!\n\n");
} else {
printf("\nSorry, Your Money Less %d for this transaction\n\n",Rest=-(Pay-Price));
ask:
printf("Please Press 'Y' to repost, or 'C' to cancel\n");
scanf("%s",&j);
if(j=='y'||j=='Y'){
goto Pay;
}else if(j=='c'||j=='C'){
printf("\n\nPlease Press 'Y' to repost, or 'C' to cancel\n\n");
}else{
printf("\n\nSorry, the input you entered is incorrect, please repeat it\n");
goto ask;
}
}
} else {
printf("\nSorry, your item amount is wrong. Please check back.\n\n");
}
return 0;
}code>
Result Works
Here the application is run
For cooking option all contents 2
For a choice of bread in the contents of 5
For the choice of fragrances in the contents of 6
For Sampoo option in content 2
For wrapping paper option in content 7
For cleaner option in content 4
For soap option in content 5
For Marker option in content 5
For Snack option in content 2
For Beans option in content 8
After all entered I enter.
When the application is run, told to enter the number of goods as they have taken. After that automatically there is a price that must be paid.
Looks like the picture below.
Here the application is run
For cooking option all contents 5
For a choice of bread in the contents of 7
For the choice of fragrances in the contents of 8
For Sampoo option in content 5
For wrapping paper option in content 8
For cleaner option in content 9
For soap option in content 2
For Marker option in content 4
For Snack option in content 5
For Beans option in content 6
When the application is run, told to enter the number of goods as they have taken. After that automatically there is a price that must be paid. But when the price entered does not match then there will be a notice to add payment
Looks like the picture below.
Here the application is run
For cooking option all contents 5
For a choice of bread in the contents of 7
For the choice of fragrances in the contents of 8
For Sampoo option in content 5
For wrapping paper option in content 8
For cleaner option in content 9
For soap option in content 2
For Marker option in content 4
For Snack option in content 5
For Beans option in content 6
To reset the payment error then selected y.
It will automatically be told to enter the price again sebernarnya
Finish
Thanks You
Posted on Utopian.io - Rewarding Open Source Contributors