int main(void) { int nMenuChoice; Menu_f(); scanf("%d",&nMenuChoic); switch(nMenuChoice) { case 1; SolveForX_f(); break; case 2; subMain_f(); break; case 3; MmToM_f(); break case 4; InchesToFeet_f(); break; case 5; CelsiusToFahrenheit_f(); break case 6; SqRoot_f(); break; case 7; Quadformula_(); break; case 8; return 0; default; prinf("please choose from one of the choices above\n"); break; } return 0; void Menu_f() { printf("\n\t\t Math Homework Helper Version 1.0"); printf("\n 1. Solve For The X Value"); printf("\n 2. Simple Calculation"); printf("\n 3. Covert Millimeter to Meter"); printf("\n 4. Covert Feet To Inches"); printf("\n 5. Covert Celsius To fahrenhiet"); printf("\n 6. Find the square root of a number"); printf("\n 7. QUADRATIC FORMULA"); printf("\n 8. Exit"); printf("\n Choice;"); } void subMain_f() { char chChoice; system("cls"); printf("==============MENU=============\n"); printf("1: Add two numbers\n"); printf("2: Subtract two numbers\n"); printf("3: Divide two numbers\n"); printf("4: Multiply two numbers\n"); printf("5: Back MainMenu\n"); printf("Choice;"); scanf("%c",&chChoice); printf("===============================\n"); switch(chChoice); { case '1': Calcadd_f(); break; case '2': CalcSub_f(); break; case '3'; CalcDiv_f(); break; case '4'; CalcMult_f(); break; case '5'; return; default: printf("please choose from one of the choice zbove\n"); break; } } void CalcAdd_f() { printf("The Add Function\n"); printf("First number:"); scanf("%d",&nNumber1); printf("second number:") scanf("%d",&nNumber2); nResult=nNumber1+nNumber2; printf("%d+%d=%d\n",nNumber1,nNumber2,nResult); printf("press any key to continue\n"); getchar(); getchar(); SubMain_f(); } void CalcSub_f() /*减法*/ { printf("The Subtract Function\n"); printf("First number:"); scanf("%d",&nNumber1); printf("second number:"); scanf("%d",&nNumber2); nResult=nNumber1-nNumber2; printf(%d+%d=%d\n",nNumber1,nNumber2,nResult); printf("Press any key to continue\n"); getchar(); getchar(); SubMain_f(); } void CalcDiv_f()/*除法*/ { printf("The Divide Function\n"); printf("First number:"); scanf("%d",&nNumber1); printf("Secon number:"); scanf(%d",&nNumber2); nResult=nNumber1/nNumber2; printf(%d/%d=%d\n",nNumber1,nNumber2,nResult); printf("Press any key to continue\n"); getchar(); getchar(); SubMain_f(); } void CalcMult_f() { printf("The Multiply Function\n"); printf("First number:"); scanf("%d",&nNumber1); printf("Second number:"); scanf("%d",&nNumber2); nResult=nNumber1*nNumber2; printf("%d*%d=%d\n",nNumber1,nNumber2,nResult); printf("press any key to xontinue\n"); getchar(); getchar(); SubMain_f(); } void SqRoot_f() /*平方根*/ { printf("The Square Root Function\n"); printf("First number:"); scanf("&d", &nNumber1); nResult=sqrt(nNumber1); printf("The square root of%d is %d\n",nNumber,nResult); printf("Press any key to continue\n"); getchar(); Menu_(); }
void SolveForX_f() /*求解线性方程*/ { int nCoef,nWholeNumber,nEqual.nX; printf("\nThis will run you through solving for x in the since that the"); printf("\nProgram reads like y=2x+3"); printf("\nOnly put in one number at a time then push enter"); printf("\mMore instructions will come after you put that number in and push enter\n\n"); printf("y= "); scanf("%d",&nCoef); printf("%dx + ".nCoef); scanf("%d",&nWholeNumber); printf("%dx + %d=",nCoef,nWholeNumber); scanf("%d",&nEqual); for(;;) { nX=rand()%100; if(((nCoef * nX) + nWholeNumber)==nEfqual) { printf("\nWe found out that x is equal to %d\n\n",nX); system("PAUSE"); return; } } }
void MmToM_f() { double dlMeter; double dlMillmeter; printf("Enter the value in'Millimeters':"); scanf("%1f",&dlMillimeter); if(dlMilimeter<1000) { printf("Way to low buddy,Number MUST be over 1000!!!\n"); MmToM_f(); } dlMeter = (dlMillimeter / 1000); printf("\nThe answer to your question is;%1f meters\n\n"'dlMeter); return; } void InchesToFeet_f() { float flFeet; float flInch; printf("Enter the number of feet to get the length in inches:"); scanf("%f"'&flInch); flFeet=12*flInch; printf("\n\nOh that is %f feet\n\n".flFeet); system("PAUSE"); return; }
void Celsius ToFahrenheit_f() { int nFahrenheit; int nFactor; int nCelsius; printf("Enter the temperature in Celsius;"); scanf("%d",&nCelsius); nFactor=212-32; nFahrenheit = nFactor*nCelsius/100+32; printf("Fahrenheit value is;%d\n",nFahrenheit); }
void Quadformula_f() /*求解一元二次方程*/ { int nCoefa,nCoefb,nCoefc; float flHalfDone; float flTopA; float flTopB; float flWholeA; float flWholeB; printf("\nWhat is the value of a;"); scanf("%d"'&nCoefa); printf("\nWhat is the value of b:"); scanf("%d", &nCoefc); printf("\nWhat is the value of c;"); scanf("%d",&nCoefc); if(nCoefb<0) { nCefb+=(nCoefb * nCoefb); } else { nCoefb-=(nCoefb*nCoefb); } flHalfDone = sqrt(((nCiefb * nCoefb)-(4*nCoefa * nCoefc))); flTopA=nCoefb+flHalfDone; flTopB=nCoefb-flHalfDone; flWholeA=flTopA/(2*nCoefa); flWholeB=flTopB/(2*nCoefa); printf("X's Are%f,%f\n",flWholeA,flWholeB); return; }