c语言编写计算器程序,请大虾们帮帮忙,急!急!我要写论文不会呀!就要交了!!!

1)完善计算器程序,改为可对实数操作
(2)可以做多个操作数的基本四则运算
(3)让计算机出题,用户做出结果,判断正误并打分
(4)要求程序可以循环运行
(5)求一元二次方程时增加浮点数与虚数解
(6)增加求公倍数、公约数、数组的均值方差总和的功能
最新回答
冷月如霜

2024-09-14 18:19:16

这也是我,是我补充的提问,下面的是原程序,就是要要求将上面的6点要求加上去
请大虾们多多帮忙了,小弟在此非常感谢了!!
# include <stdlib.h>
# include <stdio.h>
# include <math.h>

void Submain_f();
void SolveForx_();
void MmToM_f();
void InchesToFeet_f();
void CelsiusToFahrenheit_f();
void Quadformula_f();
void SqRoot_f();
void CalcAdd_f();
void CalcSub_f();
void CalcDiv_f();
void CalcMult_f();
void Menu_f();

int nNumber1,nNumber2,nResult;

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;
}