![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2007
Posts: 17
Rep Power: 0
![]() |
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) |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Jul 2007
Posts: 17
Rep Power: 0
![]() |
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) |
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
You have a number of issues. For instance,
if (state == 1, choice == 1) 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 |
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
|| && ?!?!
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jul 2007
Posts: 17
Rep Power: 0
![]() |
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) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ackerman's function - crash upon launch | codylee270 | C++ | 6 | Oct 19th, 2006 2:14 AM |
| libraries | matko | C | 1 | Jan 22nd, 2006 2:12 PM |
| Help in QBASIC (I think it's similar to VB) | phoenix987 | Visual Basic | 3 | May 9th, 2005 12:33 PM |
| Help with a QBASIC program | phoenix987 | Other Programming Languages | 4 | May 5th, 2005 12:27 PM |
| Installing IPB 2.03 | bh4575 | Other Web Development Languages | 0 | Apr 23rd, 2005 2:36 AM |