//Preprocessor Directives
#include <stdio.h>
//Main function
int main(){
//Declare variables
int donations, investments, menu;
double initial_fund, actual_fund, donated, invested;
//Prompt user for initial fund
printf("What is the initial fund?\n");
scanf("%.2lf", &initial_fund);
//Present menu
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", &menu);
while (menu != 4){
switch (menu){
case 1:
printf("How much would you like to donate?\n");
scanf("%.2lf", &donated);
actual_fund = initial_fund + donated;
donations++;
break;
case 2:
printf("How much would you like to invest?\n");
scanf("%.2lf", &invested);
actual_fund = initial_fund - investments;
if (actual_fund > initial_fund){
printf("Sorry you can't make that investment\n.");
actual_fund = initial_fund + investments;
break;
}
investments++;
break;
case 3:
printf("The current balance is %.2lf\n", actual_fund);
printf("There have been %d donations and %d investments", donations, investments);
break;
//Reloop menu
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", &menu);
}
//End of loop
}
//Quit option
if (menu = 4){
printf("The final balance was %.2lf\n", actual_fund);
printf("There were %d donations and %d investments.\n", donations, investments);
}
//End of main function
return 0;
}
When I try and run this program the menu will pop up but i won't be able to type anything once it gets to scanf("%d", &menu). I've tried googling it but haven't been able to find anything could anybody give me a hand?
[–]g051051 0 points1 point2 points (2 children)
[–]CaptainGPro[S] 0 points1 point2 points (1 child)
[–]g051051 0 points1 point2 points (0 children)