I have 8 errors I can't find? Help than post the correct code please.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • skarr98
    New Member
    • May 2010
    • 1

    I have 8 errors I can't find? Help than post the correct code please.

    Heres the code:
    :)



    Code:
    #include<iostream>
    
    
    int main{void}
    
    
    {
        system{"TITLE Calculator"};
        system {" COLOR 7"};
        char cChar;
        double dfirstnumber;
        double dsecondnumber;
        char cDoagain;
    
    do 
    {
       system{"CLS"};
       cout << " Please enter your first number"
       <<endl;
       cin >> dfirstnumber;
       cout << "Please enter the operator"
       << "{+,-,*,or /}" <<endl;
       cin >> cChar;
       
       cout << "Please enter the second number"
       <<end1;
       switch {cChar}
       {
       case "+"
            cout << "The answer is"
            << dfirstnumber << "+" <<dsecondnmber
            << "=" << {dfirstnumber + dsecondnumber}
            <<endl;
            break;
               case "-"
            cout << "The answer is"
            << dfirstnumber << "-" <<dsecondnmber
            << "=" << {dfirstnumber - dsecondnumber}
            <<endl;
            break;
               case "*"
            cout << "The answer is"
            << dfirstnumber << "*" <<dsecondnmber
            << "=" << {dfirstnumber * dsecondnumber}
            <<endl;
            break;
               case "X"
            cout << "The answer is"
            << dfirstnumber << "X" <<dsecondnmber
            << "=" << {dfirstnumber * dsecondnumber}
            <<endl;
            break;
               case "x"
            cout << "The answer is"
            << dfirstnumber << "x" <<dsecondnmber
            << "=" << {dfirstnumber * dsecondnumber}
            <<endl;
            break;
               case "/"
               if(dsecondnumber == 0}
               cout << " That is an invalid operation"
               << endl;
               
               }else{
            cout << "The answer is"
            << dfirstnumber << "/" <<dsecondnmber
            << "=" << {dfirstnumber / dsecondnumber}
            <<endl;
            break;
            }
            default: cout << "That is an invalid operation."
            break;
            }
            
            
            Cout << "Would you like to do the program again? (yes or no)"
            << endl;
            cin >> cdoagain;
            }while [cdoagain == "yes" || cdoagain == "Yes"
            
            system{"PAUSE"};
            return 0;
            }
    Last edited by Banfa; May 11 '10, 11:08 PM. Reason: Added [code] ... [/code] tags
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    How do you know you have 8 errors? If you mean you have 8 compiler errors why haven't you posted them?

    Generally if you want a favour, like someone diagnosing your code for you, it is a good idea to provide the maximum amount of information you can.

    In a lot of, but not all, cases you appear to be using { } where you should be using ( ), I would say you have more than 8 errors.

    Comment

    • whodgson
      Contributor
      • Jan 2007
      • 542

      #3
      for example yes and Yes does not cover all the options. What about YES?

      Comment

      • newb16
        Contributor
        • Jul 2008
        • 687

        #4
        Do not use strings ( in double quoes, like "+" ) as a case for switch with a char variable, it should be '+'.

        Comment

        • Dheeraj Joshi
          Recognized Expert Top Contributor
          • Jul 2009
          • 1129

          #5
          Where is
          Code:
          cin >> dsecondnmber;
          in your code?

          Regards
          Dheeraj Joshi

          Comment

          Working...