Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 1st, 2007, 11:58 PM   #1
Z3nathur
Newbie
 
Z3nathur's Avatar
 
Join Date: Jul 2007
Posts: 17
Rep Power: 0 Z3nathur is on a distinguished road
Question Error reading cout function on line 19

Ok so i fixed a few of the problems and now it runs almost as it should but since i was using a while loop i wasn't doing all too well lol. i put in a do while loop in the hopes that i would be able to run it through and have it break the loop when the third if statement(line 45) was chosen but for some reason i can't even get the compiler to output the cout statement on line 19. do i need to do something other than compile?

. Is there a more effective and less lag-inducing replacement for system("PAUSE")? i'm having trouble finding something at the moment although i figure that there must be some simple code that solves the problem through anoth means other than forcing the system to intervene.

#include <iostream>

using namespace std;

int main()
{
    float age = 0;
    float human_age;
    int state;
    int choice; 
    char nothing;
    state = 1;
    do 
    {
           cout << "Welcome to Z3nathur's first conversion tool" << endl;
           cout << "Choose one of the options listed below and press enter to continue" << endl;
           cout << "1) Dog years -> Human Years" << endl;
           cout << "2) Human years -> Dog years" << endl;
           cout << "3) Close the program" << endl;
           
           cin >> choice;
           system("cls");
           
        if (state == 1, choice == 1)
        {
                  cout << "How old is your dog in dog years?" << endl;
                  cin >> age;
                  human_age = age/7;
                  cout << "Your dog is " << age << " years old in dog years and " << human_age << " years old in human years" << endl;
                  system("PAUSE");
                  system("cls");
                  
        }
    
        if (state == 1, choice == 2)
        {
                  cout << "How old is your dog in human years?" << endl;
                  cin >> human_age;
                  age = human_age*7;
                  cout << "Your dog is " << age << " years old in dog years and " << human_age << " years old in human years" << endl;
                  system("PAUSE");
                  system("cls");
        }
        
        if (state == 1, choice == 3)
        {
                  state++;
        }
        
        
    }while( state == 1);
   
    cout << "Press any key to close the program";
    cin >> nothing;
    return 0;
}
__________________
Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
Isaac Asimov
US science fiction novelist & scholar (1920 - 1992)
Z3nathur is offline   Reply With Quote
Old Aug 2nd, 2007, 12:10 AM   #2
Z3nathur
Newbie
 
Z3nathur's Avatar
 
Join Date: Jul 2007
Posts: 17
Rep Power: 0 Z3nathur is on a distinguished road
ok i tried just starting a new project and copy-pasting my code into another console cpp and it solved the cout problem. which is discouraging because it means that the problem wasn't me. I still am stuck on getting the program to close though
__________________
Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
Isaac Asimov
US science fiction novelist & scholar (1920 - 1992)
Z3nathur is offline   Reply With Quote
Old Aug 2nd, 2007, 12:14 AM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You have a number of issues. For instance,
if (state == 1, choice == 1)
I'm a little reluctant to pursue these, because you are not paying attention to the previous responses and the advice you have been given.

I have told you how to (portably) pause the program at the end. I have counseled you about checking your input for success. Not checking the input is the sign of an uninformed noob, or a schlock. You have, however, been previously informed.

If you choose not to accept the help that is offered, then why should anyone respond? Just curious.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 2nd, 2007, 12:22 AM   #4
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,472
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
|| && ?!?!
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Aug 2nd, 2007, 12:54 AM   #5
Z3nathur
Newbie
 
Z3nathur's Avatar
 
Join Date: Jul 2007
Posts: 17
Rep Power: 0 Z3nathur is on a distinguished road
ok i'm going to take a few days and just learn different operators etc because it's obvious that i'm diving in too deep to start off without looking at all the variables (dawei you should get that d-ent). It isn't that i didnt listen to your advice on the compound operator, i also read Dark's comparison note on one of my posts and i think i misunderstood what he meant. I'll be back once i have a working first program of my own doing or have a question about syntax
__________________
Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
Isaac Asimov
US science fiction novelist & scholar (1920 - 1992)
Z3nathur is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ackerman's function - crash upon launch codylee270 C++ 6 Oct 19th, 2006 3:14 AM
libraries matko C 1 Jan 22nd, 2006 3:12 PM
Help in QBASIC (I think it's similar to VB) phoenix987 Visual Basic 3 May 9th, 2005 1:33 PM
Help with a QBASIC program phoenix987 Other Programming Languages 4 May 5th, 2005 1:27 PM
Installing IPB 2.03 bh4575 Other Web Development Languages 0 Apr 23rd, 2005 3:36 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:45 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC