Вы находитесь на странице: 1из 9

UNIVERSITI TUN HUSSEIN ONN MALAYSIA CENTRE FOR DIPLOMA STUDIES

COMPUTER PROGRAMMING PROJECT

GROUP MEMBER : 1. 2. 3. 4. 5. WOO JOO ANN SYED ZULKHAIRI SHAFIQ BIN SYED ZULKIFLEE HO CHOON SIN YEOH GUAN JIE MOGANRAJ S/O GOVINDARAJOO AA100867 AA100783 AA101042 AA100934 AA100937

YEAR/SEMESTER : 3 DAI 2 SUBJECT : COMPUTER PROGRAMMING LECTURER : PN RAFIZAH BINTI MOHD HANIFA

Introduction Computer programming is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs. This source code is written in one or more programming languages such as C++, C and Java. The purpose of programming is to create a set of instructions that computers use to perform specific operations or to exhibit desired behaviors. The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic. C is an imperative language which was designed to be compiled using a relatively straightforward compiler. It also acts as a provider of low-level access to memory and can provide language constructs that can map efficiently to machine instructions. It also requires minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language, such as in system programming. C program can be compiled for a very wide variety of computer platforms and operating systems with few changes to its source code. Problem Statement

Develop an application on Fundraiser Application using functions in program.

An organization is hosting a fundraiser to collect donations for a charity. A portion of each donation is used to cover the operating expenses of the fundraising organization, and the rest of the donation goes to the charity. Create an application that allows the organization to keep track of the total amount of money raised. The application should deduct 17% of each donation for operating expenses, while the remaining 83% is given to the charity. The application should display the amount of each donation after the 17% in operating expenses are deducted; it also should display the total amount raised for the charity (that is the total amount donated less all operating costs) for all donations up to that point.

Requirements Specification Input Output Constraints Relevant Formula Amount of donation Balance of donation after expenses deduction Total amount of donation raised for the charity None Balance of donation after expenses deduction

= (1-0.17) x Amount of donation Total amount of donation raised for the charity

= (Balance of donation)+(Previous total amount of donation)

Pseudo Code Main Function : 1. Start 2. Display WELCOME 3. Do 3.1. Display Enter the amount of donation (0 or less to exit): 3.2. Read and enter amount of donation 3.3. If donation > 0 3.3.1. Call function operating_expenses 3.3.2. Call function total_donation_raised 3.4. Else 3.4.1. Display total amount of donation raised 4. While donation > 0 5. Display THANK YOU 6. End dowhile 7. End

Function Expenses Deduction : 1. Start 2. Calculate donation balance after expenses deduction 3. Return donation balance after expenses deduction 4. End Function Total Amount Raised : 1. Start 2. Calculate total amount of donation raised 3. Return total amount of donation raised 4. End

Source Code #include <stdio.h> #include <stdlib.h>

float operating_expenses (float); float total_donation_raised (float, float);

main () { float donation, expenses; float total=0;

printf("\t #

# ####### # # # # # # # #

##### ####### # ## # # # ## # ## ## # ######

# #######\n"); \n"); \n");

printf("\t # # # # printf("\t # # # #

printf("\t # # # ##### # printf("\t # # # # printf("\t # # # # # #

# # # # ##### \n"); ## ## ## ## \n"); \n"); # ####### \n");

printf("\t ## ## ####### ####### ##### ####### # do {

printf("\n\nEnter the amount of donation (0 or less to exit):"); scanf("%f", &donation);

if (donation>0) {

expenses = operating_expenses (donation); printf("\nAfter Expenses:RM%.2f\n", expenses); total = total_donation_raised (expenses, total); printf("Total Raised:RM%.2f\n", total);}

else { printf("\nTotal Raised:RM%.2f\n\n\n\n", total); }} while (donation>0);

printf("\t ####### # printf("\t printf("\t printf("\t printf("\t printf("\t printf("\t # # # # # # # #

## ## #

# ####### # ## ## # # ## ## ##

# \n");

# # # ##

# # # ## # # # # # #

# \n"); # \n"); # \n"); # \n");

# # # ## ## # # # # # ###

####### # # # #

# ####### # # # # # ## ## ## ## ## # # ## #

# \n"); \n");

####### #####

system ("pause"); return 0; }

float operating_expenses (float ex) { float expenses;

expenses = ex * (1-0.17);

return expenses; }

float total_donation_raised (float w, float e) { float total=0.00;

total = w + e; return total; }

Sample Of Output

Conclusion We can conclude that we successfully design a program for a fundraiser application according to the task required. The program were able to successfully calculate the A program for the fundraiser application was successfully created to serve its objective of tabulating amount of donation after operational expenses deduction and the total fund raised. The tabulated values were also printed for easy reference to users. The solution was found through step by step manner accordingly. In the created program, the program will prompt user to key in the donation amount. The input is then used for calculation. The first calculation is found the donation amount after deduction. A function call is used in the statement to momentarily transfer the program control over to function definition named Deduction. A function was defined in the program which is the function Deduction where its main purpose is to tabulate the amount of deduction made to cover operational expenses. The tabulated amount of deduction is then returned to the main function along with the program control. The returned value is then used in the calculation of donation after deduction and displayed to user. The following calculation is executed within the main function itself which is to find the total fund raised. The total fund raised is tabulated and displayed to user. The program will continuously prompt user to key in the donation amount and tabulate the donation amount after deduction and total fund raised accordingly until the user key in number 0 or less to indicate termination of input. When user key in the number 0 or less for termination, the latest total fund raised will be displayed for users reference.

Вам также может понравиться