Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Switch case程序在某一点保持循环。搞不懂_C++_C_Assembly - Fatal编程技术网

C++ Switch case程序在某一点保持循环。搞不懂

C++ Switch case程序在某一点保持循环。搞不懂,c++,c,assembly,C++,C,Assembly,我想我已经做了我能做的一切,但当我按options pass 3时,它总是显示为options 3。情况1、2、3按预期工作,但4、5、6、7、8、9、10将自动启动,如情况3所示。那么你认为遗漏了什么呢 #include "stdafx.h" #include <stdlib.h> #include <iostream> #include <sstream> #include <stdio.h> using namespace std; in

我想我已经做了我能做的一切,但当我按options pass 3时,它总是显示为options 3。情况1、2、3按预期工作,但4、5、6、7、8、9、10将自动启动,如情况3所示。那么你认为遗漏了什么呢

#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <stdio.h>
using namespace std;


int pgk, ch1, ch2; // variables for the Menu1 and Menu2
char ch3; // Variable for menu 3


int main()
{
        printf("1, Final Lab\n"); // first option
        printf("2, Exit\n");// second option
        cin >> ch1; // computer is going to scan the option from keyboard
        // Switch change the option depending of the number we put in the keyboard
        switch (ch1)
        {
        case 1:
        {
            goto Menu2; // if the user enters 1, it is going to send to send it to do the operations
        }
        case 2:
        {
            goto End; // if the user enters 2, it is going to end the program.
        }

    Menu2:
        printf(" --------------------------Menu-------------------\n");
        printf("1:Pounds to kilograms\n");
        printf("2:inches to centimeters\n"); 
        printf("3:cups to milliters\n"); 
        printf("4:seconds to minutes \n"); 
        printf("5:Knots to mph\n"); 
        printf("6:tip calculator\n"); 
        printf("7:Grade average\n"); 
        printf("8:target heart rate calculator\n");
        printf("9:discount calculator\n");
        printf("10:end\n"); 
        cin >> ch2; // enter the option the user wants
        switch (ch2) // Options
        {
        case 1: 
        {
            system("cls");
            int pkg;
            printf("Choose to convert pounds to kg or kg to pounds. Press 0 for 1st option and press any other number for 2nd option.\n");
            scanf_s("%f", &pkg);
            _asm
            {
                MOV EBX, pkg;
                CMP pkg, 0;
                JE pounds_kilos;
                JMP kilos_pounds;
            }

        pounds_kilos:
            float nguypounds, nguyconvert1, nguyanswer1;
            nguyconvert1 = 2.204622f;
            printf("Enter the amount of pounds you would like to convert to kilograms\n");
            scanf_s("%f", &nguypounds);

            _asm
            {

                FLD nguypounds;
                FDIV nguyconvert1;
                FST nguyanswer1;
            }
            printf("Your enter number of pounds to kilograms is %f\n", nguyanswer1);
            system("pause");
            goto Menu3;

        kilos_pounds:
            float nguykilos, nguyconvert2, nguyanswer2;
            nguyconvert2 = 2.204622f;
            printf("Enter the amount of kilograms you would like to convert to pounds\n");
            scanf_s("%f", &nguykilos);

            _asm
            {
                FLD nguykilos;
                FMUL nguyconvert2;
                FST nguyanswer2;
            }
            printf("Your enter number of kilograms to pounds is %f\n", nguyanswer2);
            goto Menu3;

        }

        case 2: // if the user enters 2
        {

            system("cls");
            int pkg;
            printf("Choose to convert inches to centimeters or centimeters to inches. Press 0 for 1st option and press any other number for 2nd option.\n");
            scanf_s("%f", &pkg);
            _asm
            {
                MOV EBX, pkg;
                CMP pkg, 0;
                JE inches_centimeters;
                JMP centimeters_inches;
            }

        inches_centimeters:
            float nguyinches, nguyconvert3, nguyanswer3;
            nguyconvert3 = 2.54f;
            printf("Enter the amount of inches you would like to convert to centimeters\n");
            scanf_s("%f", &nguyinches);

            _asm
            {

                FLD nguyinches;
                FMUL nguyconvert3;
                FST nguyanswer3;
            }
            printf("Your enter number of inches to centimeters is %f\n", nguyanswer3);
            goto Menu3;
        }
        centimeters_inches:
            float nguycentimeters, nguyconvert4, nguyanswer4;
            nguyconvert4 = 0.39370079f;
            printf("Enter the amount of centimeters you like to convert to inches\n");
            scanf_s("%f", &nguycentimeters);

            _asm
            {
                FLD nguycentimeters;
                FMUL nguyconvert4;
                FST nguyanswer4;
            }
            printf("Your enter number of centimeters to inches is %f\n", nguyanswer4);

            goto Menu3;

        }
        case 3: // if the user enter 3 
        {
            system("cls");
            int pkg;
            printf("Choose to convert cups to milliters or milliters to cups. Press 0 for 1st option and press any other number for 2nd option.\n");
            scanf_s("%f", &pkg);
            _asm
            {
                MOV EBX, pkg;
                CMP pkg, 0;
                JE cups_milliters;
                JMP milliters_cups;
            }

        cups_milliters:
            float nguycups, nguyconvert5, nguyanswer5;
            nguyconvert5 = 236.58823f;
            printf("Enter the amount of cups you would like to convert to milliters\n");
            scanf_s("%f", &nguycups);

            _asm
            {

                FLD nguycups;
                FMUL nguyconvert5;
                FST nguyanswer5;
            }
            printf("Your enter number of cups to milliters is %f\n", nguyanswer5);
            system("pause");

            goto Menu3;

        milliters_cups:
            float nguymilliters, nguyconvert6, nguyanswer6;
            nguyconvert6 = 236.58823f;
            printf("Enter the amount of milliters you like to convert to cups\n");
            scanf_s("%f", &nguymilliters);

            _asm
            {
                FLD nguymilliters;
                FDIV nguyconvert6;
                FST nguyanswer6;
            }
            printf("Your enter number of milliters to cups is %f\n", nguyanswer6);
            goto Menu3;

        }
        case 4: // if the user enters 4
        {
            system("cls");
            int pkg;
            printf("Choose to convert seconds to minutes or minutes to seconds. Press 0 for 1st option and press any other number for 2nd option.\n");
            scanf_s("%f", &pkg);
            _asm
            {
                MOV EBX, pkg;
                CMP pkg, 0;
                JE sec_min;
                JMP min_sec;
            }
        sec_min:
            float nguyseconds, nguyconvert7, nguyanswer7;
            nguyconvert7 = 60;
            printf("Enter the amount of seconds you would like to convert to minutes\n");
            scanf_s("%f", &nguyseconds);

            _asm
            {

                FLD nguyseconds;
                FDIV nguyconvert7;
                FST nguyanswer7;
            }
            printf("Your enter number of seconds to minutes is %f\n", nguyanswer7);
            goto Menu3;

        min_sec:
            float nguyminutes, nguyconvert8, nguyanswer8;
            nguyconvert8 = 60;
            printf("Enter the amount of minutes you like to convert to seconds\n");
            scanf_s("%f", &nguyminutes);

            _asm
            {
                FLD nguyminutes;
                FMUL nguyconvert8;
                FST nguyanswer8;
            }
            printf("Your enter number of minutes to seconds is %f\n", nguyanswer8);
            system("pause");
            goto Menu3;
        }
        case 5:
        {
            system("cls");
            int pkg;
            printf("Choose to knots to mph or mph to knots. P=ress 0 for 1st option and press any other number for 2nd option.\n");
            scanf_s("%f", &pkg);
            _asm
            {
                MOV EBX, pkg;
                CMP pkg, 0;
                JE knots_mph;
                JMP mph_knots;
            }
        knots_mph:
            float nguyknots, nguyconvert9, nguyanswer9;
            nguyconvert9 = 1.15f;
            printf("Enter the amount of knots you would like to convert to mph\n");
            scanf_s("%f", &nguyknots);

            _asm
            {

                FLD nguyknots;
                FMUL nguyconvert9;
                FST nguyanswer9;
            }
            printf("Your enter number of knots to mph is %f\n", nguyanswer9);
            goto Menu3;

        mph_knots:
            float nguymph, nguyconvert10, nguyanswer10;
            nguyconvert10 = 1.15f;
            printf("Enter the amount of mph you like to convert to knots\n");
            scanf_s("%f", &nguymph);

            _asm
            {
                FLD nguymph;
                FDIV nguyconvert10;
                FST nguyanswer10;
            }
            printf("Your enter number of minutes to seconds is %f\n", nguyanswer10);
            system("pause");
            goto Menu3;

        }
        case 6:
        {
            system("cls");
            float nguybill, nguytip, nguyamount;
            printf("Please enter the total amount of your bill\n");
            scanf_s("%f", &nguybill);
            printf("Now add the percentage you would like to tip. PLEASE ENTER IN PERCENTAGE IN DECIMAL FORM!\n");
            scanf_s("%f", &nguytip);

            _asm
            {
                fld nguybill
                    fld nguytip
                    fmul nguybill
                    fadd st(0), st(1)
                    fst nguyamount
            }
            printf("the the toal amount after tip is %f\n", nguyamount);
            goto Menu3;

        }
        case 7:
        {
            system("cls");
            float nguytest1, nguytest2, nguytest3, nguyave, nguytotave;
            nguyave = 3;
            printf("Please enter the grade of your first test.\n");
            scanf_s("%f", &nguytest1);
            printf("Please enter the grade of your second test.\n");
            scanf_s("%f", &nguytest2);
            printf("Please enter the grade of your thrid test.\n");
            scanf_s("%f", &nguytest3);
            _asm
            {
                fld nguytest1
                    fld nguytest2
                    fld nguytest3
                    fadd st(0), st(1)
                    fadd st(0), st(2)
                    fdiv nguyave
                    fst nguytotave
            }
            printf("Your average grade is %f", nguytotave);
            goto Menu3;
        }
        case 8:
        {
            system("cls");
            float nguyage, nguyageconst, nguymaxhr, nguytarghr, nguymulmax;
            nguyageconst = 220;
            nguymulmax = .70f;
            printf("Please enter the total amount of your age to find your max heart rate and target heart rate\n");
            scanf_s("%f", &nguyage);

            _asm
            {
                fld nguyage
                    fld nguyageconst
                    fsub nguyage
                    fst nguymaxhr
            }

            _asm
            {
                fld nguymaxhr
                    fmul nguymulmax
                    fst nguytarghr
            }
            printf("your max heart rate should be %f beat per minute\n", nguymaxhr);
            printf("and your target heart rate should be %f beats per minute\n", nguytarghr);
            goto Menu3;

        }
        case 9:
        {
            system("cls");
            float nguyogprice, nguydis, nguyoff, nguynamount;
            printf("Please enter the oringal price\n");
            scanf_s("%f", &nguyogprice);
            printf("Now enter the given discout. PLEASE ENTER IN PERCENTAGE IN DECIMAL FORM!\n");
            scanf_s("%f", &nguydis);

            _asm
            {
                fld nguyogprice
                    fld nguydis
                    fmul nguyogprice
                    fst nguyoff
            }

            _asm
            {
                fld nguyoff
                    fld nguyogprice
                    fsub st(0), st(1)
                    fst nguynamount
            }
            printf("The new sale price is %f\n", nguynamount);
            goto Menu3;

        }
        case 10: // if the user enters 5
        {
            goto End; //go to end
        }
        }

    Menu3: // This menu is going to ask if the user wants to continue the program
        printf(" -------------------------Question---------------------\n"); // display message 
        printf("Do you want to continue the program Y/N\n"); // display message
        cin >> ch3; // enter yes or no
        switch (ch3) // conditional 
        {
        case 'y': // if the user enters 'y'
        {
            goto Menu2; // go to menu 2 and continue the program 
        }
        case 'Y': // if the user enters 'Y'
        {
            goto Menu2; // go to menu 2 and continue the program
        }
        case 'n': // if the user enters 'n'
        {
            goto End; // finish the program
        }
        case 'N': // if the user enters 'N'
        {
            goto End; // finish the program
        }


        }

    End: // menu to end the program
        system("pause"); // pause the system
        return 0;// end program

    }   
#包括“stdafx.h”
#包括
#包括
#包括
#包括
使用名称空间std;
int pgk,ch1,ch2;//Menu1和Menu2的变量
char ch3;//菜单3的变量
int main()
{
printf(“1,最终实验室”;//第一个选项
printf(“2,退出\n”);//第二个选项
cin>>ch1;//计算机将从键盘扫描选项
//开关根据我们在键盘上输入的数字更改选项
开关(ch1)
{
案例1:
{
goto Menu2;//如果用户输入1,它将发送到send以执行操作
}
案例2:
{
goto End;//如果用户输入2,它将结束程序。
}
菜单2:
printf(“-----------------------------菜单-----------------\n”);
printf(“1:磅到千克”);
printf(“2:英寸到厘米\n”);
printf(“3:cups到milliters\n”);
printf(“4:秒到分钟”);
printf(“5:Knots到mph\n”);
printf(“6:提示计算器\n”);
printf(“7:等级平均值\n”);
printf(“8:目标心率计算器\n”);
printf(“9:折扣计算器\n”);
printf(“10:end\n”);
cin>>ch2;//输入用户想要的选项
开关(ch2)//选项
{
案例1:
{
系统(“cls”);
int-pkg;
printf(“选择将磅转换为千克或千克转换为磅。第一个选项按0,第二个选项按任何其他数字。\n”);
scanf_s(“%f”和pkg);
_asm
{
MOV-EBX,pkg;
CMP-pkg,0;
乙脑磅/公斤;
JMP千克/磅;
}
磅/千克:
浮动nguypounds、nguyconvert1、nguyanswer1;
nguyconvert1=2.204622f;
printf(“输入要转换为千克的磅数\n”);
scanf_s(“%f”和nguypounds);
_asm
{
弗莱德·恩圭蓬斯;
FDIV-nguyconvert1;
FST nguyanswer1;
}
printf(“您输入的磅数到千克数为%f\n”,nguyanswer1);
系统(“暂停”);
goto Menu3;
千克/磅:
浮动nguykilos、nguyconvert2、nguyanswer2;
nguyconvert2=2.204622f;
printf(“输入要转换为磅的千克数\n”);
scanf_s(“%f”和nguykilos);
_asm
{
恩圭基洛斯阵线;
FMUL nguyconvert2;
FST nguyanswer2;
}
printf(“您输入的千克到磅的数量是%f\n”,nguyanswer2);
goto Menu3;
}
案例2://如果用户输入2
{
系统(“cls”);
int-pkg;
printf(“选择将英寸转换为厘米或厘米转换为英寸。第一个选项按0,第二个选项按任何其他数字。\n”);
scanf_s(“%f”和pkg);
_asm
{
MOV-EBX,pkg;
CMP-pkg,0;
JE英寸/厘米;
JMP厘米/英寸;
}
英寸/厘米:
浮动nguyinches、nguyconvert3、nguyanswer3;
nguyconvert3=2.54f;
printf(“输入要转换为厘米的英寸数\n”);
scanf_s(“%f”和nguyinches);
_asm
{
弗莱德·恩古因奇斯;
FMUL nguyconvert3;
FST nguyanswer3;
}
printf(“您输入的英寸到厘米的数字是%f\n”,nguyanswer3);
goto Menu3;
}
厘米/英寸:
浮动nguycentimeters、nguyconvert4、nguyanswer4;
nguyconvert4=0.39370079f;
printf(“输入要转换为英寸的厘米数\n”);
扫描单位(“%f”和nguycentimeters);
_asm
{
FLD nguycentimeters;
FMUL nguyconvert4;
FST nguyanswer4;
}
printf(“您输入的厘米到英寸的数字是%f\n”,nguyanswer4);
goto Menu3;
}
案例3://如果用户输入3
{
系统(“cls”);
int-pkg;
printf(“选择将罩杯转换为毫升或将毫升转换为罩杯。按0表示第一个选项,按任何其他数字表示第二个选项。\n”);
scanf_s(“%f”和pkg);
_asm
{
MOV-EBX,pkg;
CMP-pkg,0;
JE罩杯(毫米),;
JMP Milleters_杯;
}
罩杯/毫升:
浮动nguycups、nguyconvert5、nguyanswer5;
nguyconvert5=236.58823f;
printf(“输入要转换为毫米的杯子数量\n”);
scanf_s(“%f”、&nguycups);
_asm
{
弗莱德·恩古普斯;
FMUL nguyconvert5;
FST nguyanswer5;
}
printf(“您输入的杯数到毫升数是%f\n”,nguyanswer5);
系统(“暂停”);
goto Menu3;
毫杯:
流动非政府组织成员,非政府组织成员6,非政府组织成员6;
nguyconvert6=236.58823f;
printf(“输入要转换为杯的毫米数\n”);
scanf_s(“%f”和nguymillers);
_asm
{
外语学习者;
FDIV-nguyconvert6;
FST nguyanswer6;
}
printf(“Yo