Question
I’m working on a C++ program that determines the winner of a type of game by comparing the two teams total scores. There are a few combindations of scores that are invalid. At the top of my code I declare a Boolean called “isInvalid” and set it to false.
For each invalid score combindation I have an if statement that makes sure to print “invalid result” if that combindation is entered in and I follow that if statement with setting “isInvalid” = True (one of these if statements is the first picture below), now if all entered scores ARE valid then I want it to print who the winner is by first checking if the game is valid (isInvalid = false) and then checking who has the higher score using if statements ( this part is in the 2nd picture). Can you tell me if I have everything formated correctly? If i type in a valid score, it doesn’t print the winner so I think something is wrong with the last part... thanks!!



if (tl s1&& t2 s 1) cout < Invalid seeker score; isInvalid -true;
media%2Fc7a%2Fc7a5dc14-dced-4a94-9a17-34
0 0
Add a comment Improve this question Transcribed image text
Answer #1

you made wrong in last two function,

You wrote IsInvalid=false, which means assignemnt, means you are assigning false to vaiable Isinvalue, but actuall you wanted to compare them so that should be: IsInvalid==false.

so correcte code:

if(isInvalid==false && t1_total>t2_total)

{

cout<<"Team 1 won the game";

}

if(isInvalid==false && t2_total>t1_total)

{

cout<<"Team 2 won the game";

}

please give thumbs up, thanks

Add a comment
Know the answer?
Add Answer to:
I’m working on a C++ program that determines the winner of a type of game by...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that will provide a user with a grade range if they enter...

    Write a C++ program that will provide a user with a grade range if they enter a letter grade. Your program should contain one function. Your function will accept one argument of type char and will not return anything (the return type will be void), but rather print statements to the console. Your main function will contain code to prompt the user to enter a letter grade. It will pass the letter grade entered by the user to your function....

  • Objective: To write a program to allow a game of Tic Tac Toe to be played,...

    Objective: To write a program to allow a game of Tic Tac Toe to be played, and to determine when the game is over Complete the TicTacToe program below. It will allow for a full game of Tic Tac Toe between two players, and it will tell you who won or if the game is over with no winner. Details: The TicTacToe board is stored in a 3x3 multidimensional list of characters containing spaces at the start of the game...

  • i have created a program for a game of rock, paper, scissors but i must make...

    i have created a program for a game of rock, paper, scissors but i must make it run more than once in some kind of loop. i want to add a function named runGame that will control the flow of a single game. The main function will be used to determine which game mode to initiate or exit program in Player vs. Computer, the user will be asked to enter their name and specify the number of rounds for this...

  • c language This assignment is to write a program to score the paper-rock-scissors game AGAIN. Each...

    c language This assignment is to write a program to score the paper-rock-scissors game AGAIN. Each of two players enters either P, R, or S. The program then announces the winner as well as the basis for determining the winner: “Paper covers rock”, “Rock breaks scissors”, “Scissors cut paper”, or “Draw, nobody wins”. The primary differences between this and previous two versions are described as below: (1) You MUST use a function to get the input value for the player’s...

  • 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...

  • C or C++ Project Overview Wild, Wild, West! Dice Game The Wild, Wild, West! is an...

    C or C++ Project Overview Wild, Wild, West! Dice Game The Wild, Wild, West! is an elimination dice game. It can be played by any number of players, but it is ideal to have three or more players. Wild, Wild, West! Requires the use of two dice. At the start of the game, each player receives a paper that will track the number of lives that player has. Each player starts the game with 6 lives. In the first round,...

  • write a program in C that determines the change to be dispensed from a vending machine....

    write a program in C that determines the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents and a dollar, in a 5-cent increments(25,30,35.....,90,95,or 100), and the machine accepts only a single dollar bill to pay for the item. for example a possible dialogue with the user might be "Enter price of item (from 25 cents to a dollar, in 5-cent increments):45 you boughtan item for 45 cents and gave me...

  • I need help solving this in c++ using visual Studio. For this assignment, you will be filling in missing pieces of code within a program, follow the comments in the code. These comments will describe...

    I need help solving this in c++ using visual Studio. For this assignment, you will be filling in missing pieces of code within a program, follow the comments in the code. These comments will describe the missing portion. As you write in your code, be sure to use appropriate comments to describe your work. After you have finished, test the code by compiling it and running the program, then turn in your finished source code. // TicTacToe.cpp: Follow along with...

  • I’m trying to check my answers to see if I have the correct answers. Can you...

    I’m trying to check my answers to see if I have the correct answers. Can you help me with the following questions? Thank you. Express the following argument as a categorical syllogism (in standard form), and then tell me if it is valid or invalid. If you draw the correct Venn diagram for it I will give you an extra 5 points (10 points in all). If you get the syllogism right you get 5 points. Only cats are curious....

  • Assignment 2 – The two player game of Poaka The game of Poaka is a dice...

    Assignment 2 – The two player game of Poaka The game of Poaka is a dice game played by two players. Each player takes turns at rolling the dice. At each turn, the player repeatedly rolls a dice until either the player rolls a 1 (in which case the player scores 0 for their turn) or the player chooses to end their turn (in which case the player scores the total of all their dice rolls). At any time during...

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