Question

Can someone tell me what I am doing wrong? Its a cootie lab for C++. My...

Can someone tell me what I am doing wrong? Its a cootie lab for C++. My compiler wont let it run but it succeeds. I dont know why it wont work, can someone help?

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

int roll, body, head, antennae, wings, stinger, legs, eyes;

int diceRoll()

{

  

int randnum = (rand() % 7);

int r = randnum + 1;

return r;

}

int addbody (int body)

{

if (body < 1)

{

body++;

}

return body;

}

int addhead ( int body, int head)

{

if (head < 1 && body == 1)

{

head++;

}

return head;

}

int addantennae (int body, int head, int antennae)

{

if (antennae < 2 && head == 1 && body == 1)

{

antennae++;

}

return antennae;

}

int addwings (int body, int head, int wings)

{

if (wings < 2 && head == 1 && body == 1)

{

wings++;

}

return wings;

}

int addstinger (int body, int head, int stinger)

{

if (stinger < 1 && head == 1 && body == 1)

{

stinger++;

}

return stinger;

}

int addlegs (int body, int head, int legs)

{

if (legs < 4 && head == 1 && body == 1)

{

legs++;

}

return legs;

}

int addeyes (int body, int head, int eyes)

{

if (eyes < 6 && head == 1 && body == 1)

{

eyes++;

}

return eyes;

}

void applyroll (int roll)

{

if (roll == 1)

{

body = addbody(body);

}

else if (roll == 2)

{

head = addhead(body, head);

}

else if (roll == 3)

{

antennae = addantennae(body, head, antennae);

}

else if (roll == 4)

{

wings = addwings(body, head, wings);

}

else if (roll == 5)

{

stinger = addstinger(body, head, stinger);

}

else if (roll == 6)

{

legs = addlegs(body, head, legs);

}

else if (roll == 7)

{

eyes = addeyes(body, head, eyes);

}

}

void printcootie (int body, int head, int antennae, int wings, int stinger, int legs, int eyes)

{

cout << "You cootie has ";

if (body == 0)

{

cout << "no body, ";

}

if (body == 1)

{

cout << "a body, ";

}

if (head == 0)

{

cout << "no head, ";

}

if (head == 1)

{

cout << "a head, ";

}

if (antennae == 0)

{

cout << "no antennae, ";

}

if (antennae == 1)

{

cout << "one antennae, ";

}

if (antennae == 2)

{

cout << "two antennae, ";

}

if (wings == 0)

{

cout << "no wings, ";

}

if (wings == 1)

{

cout << "1 wing, ";

}

if (wings == 2)

{

cout << "2 wings, ";

}

if (stinger == 0)

{

cout << "no stinger, ";

}

if (stinger == 1)

{

cout << "a stinger, ";

}

if (legs == 0)

{

cout << "no legs, ";

}

if (legs == 1)

{

cout << "1 leg, ";

}

if (legs == 2)

{

cout << "2 legs, ";

}

if (legs == 3)

{

cout << "3 legs, ";

}

if (legs == 4)

{

cout << "4 legs, ";

}

if (eyes == 0)

{

cout << "no eyes.";

}

if (eyes == 1)

{

cout << "1 eye.";

}

if (eyes == 2)

{

cout << "2 eyes.";

}

if (eyes == 3)

{

cout << "3 eyes.";

}

if (eyes == 4)

{

cout << "4 eyes.";

}

if (eyes == 5)

{

cout << "5 eyes.";

}

if (eyes == 6)

{

cout << "6 eyes.";

}

}

int cootiecomplete()

{

if (body == 1 && head == 1 && antennae == 2 && wings == 2 && stinger == 1 && legs == 4 && eyes == 6)

{

return 1;

}

else

{

return 0;

}

}

int main()

{

char coot1;

char coot;

do

{

body = 0, head = 0, antennae = 0, wings = 0, stinger = 0, legs = 0, eyes = 0;

  

do

{

roll = diceRoll();

applyroll(roll);

printcootie(body, head, antennae, wings, stinger, legs, eyes);

}

while (!cootiecomplete());

cout << "\n Play agian? (y or n)";

cin >> coot;

}

while (coot1 == 'y' || coot1 == 'Y');

getchar();

return 0;

}

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Can someone tell me what I am doing wrong? Its a cootie lab for C++. My...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • can someone help me fix my jeopardy dice game I am having a hard time figuring...

    can someone help me fix my jeopardy dice game I am having a hard time figuring out what i am doing wrong #include #include using namespace std; //this function makes a number between 1 and 6 come out just like a dice int rollDie() { return (rand() % 6+1); } //this function asks the user with a printed statement if they want to roll the dice and gives instructions for yes and no (y/n) void askYoNs(){ cout<<"Do you want to...

  • can someone help me fix my jeopardy game #include<iostream> #include<stdlib.h> using namespace std; int rollDie() {...

    can someone help me fix my jeopardy game #include<iostream> #include<stdlib.h> using namespace std; int rollDie() { return (rand() % 6+1); } void askYoNs(){ cout<<"Do you want to roll a dice (Y/N)?:"<<endl; } void printScores(int turnTotal,int humanTotal,int compTotal){ int player; int human; if(player==human){ cout<<"Your turn total is "<<turnTotal<<endl; } else{ cout<<"computer turn total is "<<turnTotal<<endl; } cout<<"computer: "<<compTotal<<endl; cout<<"human: "<<humanTotal<<endl; cout<<endl; } int human; int changePlayer(int player){ if(player==human) return 1; return human; } int process(int& turnTotal,int roll,int curr_player,int& humanTotal,int& computerTotal){ if(roll==2...

  • Can someone help with this C++ code. I am trying to compile and I keep running...

    Can someone help with this C++ code. I am trying to compile and I keep running into these 4 errors. #include <iostream> #include <cassert> #include <string> using namespace std; typedef int fsm_state; typedef char fsm_input; bool is_final_state(fsm_state state) { return (state == 3) ? true : false; } fsm_state get_start_state(void) { return 0; } fsm_state move(fsm_state state, fsm_input input) { // our alphabet includes only 'a' and 'b' if (input != 'a' && input != 'b') assert(0); switch (state) {...

  • can someone please double check my code here are the requirements please help me fulfill the...

    can someone please double check my code here are the requirements please help me fulfill the requirements Using the material in the textbook (NumberList) as a sample, design your own dynamic linked list class (using pointers) to hold a series of capital letters. The class should have the following member functions: append, insert (at a specific position, return -1 if that position doesn't exist), delete (at a specific position, return -1 if that position doesn't exist), print, reverse (which rearranges...

  • Hello, I am working on my final and I am stuck right near the end of...

    Hello, I am working on my final and I am stuck right near the end of the the program. I am making a Tic-Tac-Toe game and I can't seem to figure out how to make the program ask if you would like to play again, and keep the same names for the players that just played, keep track of the player that wins, and display the number of wins said player has, after accepting to keep playing. I am wanting...

  • Can you tell me what is wrong and fix this code. Thanks #include <iostream> #include <string>...

    Can you tell me what is wrong and fix this code. Thanks #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; //function void displaymenu1(); int main ( int argc, char** argv ) { string filename; string character; string enter; int menu1=4; char repeat; // = 'Y' / 'N'; string fname; string fName; string lname; string Lname; string number; string Number; string ch; string Displayall; string line; string search; string found;    string document[1000][6];    ifstream infile; char s[1000];...

  • c++, I am having trouble getting my program to compile, any help would be appreciated. #include...

    c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...

  • Hello, I am working on a project for my C++ class, I have the vast majority...

    Hello, I am working on a project for my C++ class, I have the vast majority of the code figured out but am running into a few issues. Mainly updating each * to an X. The problem is as follows:(Airplane Seating Assignment) Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with six seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business...

  • This question is about C++! Honestly, I'm not sure what I am doing right or wrong....

    This question is about C++! Honestly, I'm not sure what I am doing right or wrong. Using just functions, nothing else, I am trying to create a program that uses nothing but functions to take in two fractions, add these fractions, divide these fractions, and then display the simplified fraction all from within a menu. I would very much appreciate any leads, aid, or description on what I've done right and wrong. Thanks! #include <iostream> using namespace std; //Description: Function...

  • ////****what am i doing wrong? im trying to have this program with constructors convert inches to...

    ////****what am i doing wrong? im trying to have this program with constructors convert inches to feet too I don't know what im doing wrong. (the program is suppose to take to sets of numbers feet and inches and compare them to see if they are equal , greater, less than, or not equal using operator overload #include <stdio.h> #include <string.h> #include <iostream> #include <iomanip> #include <cmath> using namespace std; //class declaration class FeetInches { private:    int feet;   ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT