Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Help with my program 2

+1 vote
asked Nov 15, 2020 by Vicent Cotaina Bertó (390 points)
retagged Nov 15, 2020 by Vicent Cotaina Bertó
I need to make that when user introduces a number with ',' or '.' the number converts into decimal number. I have to do it with switch structure. For now I have the following code:

int main()
    int p=0,n=0,k=0,signo=1;
    float positivos[p] = {},negativos[n] = {};
    float valor, SumaPositivos=0, SumaNegativos=0,prueba=0;
    char caracter;
    std::cout.setf(std::ios::showpos); //ios está en el espacio de nombres std y por eso hay que ponerle std antes.
    cout << "Introduce your banking movement: " ;
    while (valor!=0)
            case '-':
            case ',':
            case '.':
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':
                prueba=prueba*10+signo*(float (caracter-'0'));
            case '\n':
                    positivos[p] = prueba;
                    std::cout << prueba << "\n";
                else if(prueba<0){
                    negativos[n] = prueba;
                    std::cout << prueba << "\n";
                else if(prueba==0){
                cout << "Invalid character, introduce numbers.";
                caracter=' ';

1 Answer

0 votes
answered Nov 16, 2020 by Peter Minarik (88,520 points)
To me, this seems to be a duplicate  of http://question.onlinegdb.com/8595/help-with-my-program
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.