Hey I'm working on this program and the last thing I need to do is in case 3, adding how many investments would be made and how many donations would have been made. How do I do that?
Code:
int main(void)
{
int initial_balance=0, choice=0, donation=0, invest=0, fund=0, balance=0, total_donation, total_invest;
printf("Welcome!\n");
printf("\nWhat is the inital balance of the fund?\n");
scanf("%d", &initial_balance);
fund = initial_balance;
printf("What would you like to do?\n");
printf("\t1 - Make a donation\n");
printf("\t2 - Make an investment\n");
printf("\t3 - Print balance of fund\n");
printf("\t4 - Quit\n");
scanf("%d", &choice);
while(choice != 4)
{
switch(choice) {
case 1:
printf("How much would you like to donate?\n");
scanf("%d", &donation);
break;
case 2:
printf("How much would you like to invest?\n");
scanf("%d", &invest);
if (invest > donation)
printf("You cannot make an investment larger than the funds.\n");
fund = invest - initial_balance;
break;
case 3:
balance=initial_balance+donation-invest;
printf("\nThe current balance of the fund is $%.2d.\n", balance);
total_donation = donation;
total_invest = invest;
printf("There have been %.l donations and %.l investments.\n", total_donation,total_invest);
break;
default:
printf("You made an invalid selection.\n");
break;
}//end switch
printf("What would you like to do?\n");
printf("\t1 - Make a donation\n");
printf("\t2 - Make an investment\n");
printf("\t3 - Print balance of fund\n");
printf("\t4 - Quit\n");
scanf("%d", &choice);
}//end while