// 2.cpp : Sample Program with a menu
//Write a program that will use a menu
#include "stdafx.h"
#include<stdio.h>
#define Pi 3.14159
int main(void)
{
int digit1;
int choice;
int a, b, c; //user input for choice 3 & 4
int a1, a2;// User input for Choice 1
int divi;
int divisor;
/*Menu*/
printf("***** MENU *****\n");
printf(" 1 - Greater Than, Less Than, Or Equal?\n");
printf("\t In this selection, you will enter two integers. \n");
printf("\t The program will return'Greater Than' if the first\n");
printf("\t integer entered is less than the second,'Less than'\n");
printf("\t if the first integer is greater than the second, or\n");
printf("\t'Equal' if the two integers entered are equal\n");
printf(" 2 - Evenly Divisible\n");
printf("\t In this slection, you will enter two integers. \n");
printf("\t The program will test if the the first integer\n");
printf("\t is evenly divisible by the second. The program\n");
printf("\t will then return its result and display\n");
printf("\t the quotient rounded to the nearest thousandth\n");
printf(" 3 - Calculations with 2 integers\n");
printf(" 4 - Calculations with 3 integers\n");
printf(" 5 - Calculations with circles\n");
printf(" 6 - Quit\n");
printf("Please enter your choice: ");
scanf("%i",&choice);
printf("\n\n");
switch(choice)
{
case 1: //Greater than, less than, or equal
printf("Please Enter two integers: \n");
scanf("%i %i", &a1, &a2);
if (a1<a2)
printf("Greater Than\n");
else if (a1>a2)
printf("Less Than\n");
else if (a1=a2)
printf("Equal\n");
break;
case 2: //Equally Divisible
I need help with this part of the code. Getting 0.000 for the quotient.Why? What about these cases is making it not receive the integers? I tried to localize the integers with the curly brackets. What am I doing wrong?
printf("Please Enter two integers: \n");
{
int divi;
int divisor;
scanf("%i %i", &divi, &divisor);
float modQuotient = divi%divisor;
if (modQuotient!=0)
{
printf("%i is not evenly divisible by %i\n", divi, divisor);
printf("The quotient is %.3f\n", divi/divisor);
}
else
{
printf("%i is evenly divisible by %i\n", divi, divisor);
printf("The quotient is %.3f\n", divi/divisor);
}
}
break;
/*case 3: /*Calculations with 2 integers*/
case 4: /*Calculations with 3 integers*/
printf(" You have selected to do some calculations with 2
integers\n");
printf("Please enter your 3 integers: ");
scanf("%i%i%i",&a, &b, &c);
printf("The average of %i, %i and %i is %g\n\n",a, b, c, (a+b+c)/3.0);
break;
case 5: /*Calculations with circles*/
float radius;
printf("Please enter the radius of a circle: ");
scanf ("%g", &radius);
printf("\nThe diameter of a circle with a radius of %g units is %.2f units\n\n",
radius, radius*2);
printf("The circumference is of the circle with a radius of %g
units is %.2f units\n\n", radius, Pi*radius*2);
printf("The area of a circle with a radius of %g units is %.2f
square units\n\n", radius, Pi*radius*radius);
break;
case 6: /*Quit*/
printf("Thank you. Good bye\n\n");
break;
default: /*Invalid Entry*/
printf("Invalid Entry...\n");
break;
}
printf("The program will now end. Have a great day!\n");
return 0;
}