So , i had to make an rock paper scissors game . After lot of hard work and struggle ,I completed it but my professor rejected it since I didnot add option where it says "Would you like to play again .Y/N " . The code has too many brackets ! Here is my code
#include <iostream> #include <ctime> #include <cstdlib> using namespace std;
// for displaying the outputs to the user; passing string to functions void user_win() {
what im trying to do is an option to play again. if the user decides to play again then i want the options to execute again and if the user choses not to play again then i want the game to show the scores.
here is what i have so far:
Code:
// Purpose: Play the Rock-Paper-Scissors-Lizard-Spock Game #define _CRT_SECURE_NO_WARNINGS #include <stdio.h>
I made a rock paper scissors game in c++. How to make it better, and what i can do differently
#include <iostream> #include <string> using namespace std;
int checkConvertInput(string signs[], int wins, int draws, int losses); void calculateWinner(int playerSign, string signs[], int &wins, int &draws, int &losses); void endResult(int wins, int draws, int losses);
When i return 0; at the function int userselect (int user, int comp)my output displays twice and when i ask the user to run it again the computers selection of rock, paper or scissors remains the same it doesn't find a new random number. So i made the function userselect return to main(). This works and my output is displayed once, but when i run it it skips my while part of my do while loop completely so it loops the program without asking the user if they wish to run it again.
but when i return main() the computers choice re-randomizes every time so i need to find a way to get the while part of my do while to initialize and the program to not loop without the option of ending it.
I need to finish this program which has to ask for seed, then the user gives 5 friends, and then it will choose who to text randomly and show who did not make the cut.
This all i have, I am stuck and I do not know if it correct.
#include <iostream> #include <string> using namespace std; int main() { string num_friends[5]; int user_input;
Write a program that plays the game of guess the number.the program chooses the number to be guessed by choosing an integer at random in the range 1-1000. The program then types 'i have a number between 1 and 1000,can you guess number? Then the player then types the first guess, the program responds.
I am having trouble getting values of a dictionary to display in a label and radio button text after the dictionary key is randomly selected.
I first created a class called TheoryQuestions and created a new instance of the class for each dictionary entry. Each entry contains strings for Question, RadioButton Text(x4), and Correct Answer.
The random generator is actually selecting a random number as I can display the generated number in a label. The problem is that the dictionary string values held in the dictionary position represented by the random number are not being displayed.
Here is my TheoryQuestion Class
public class TheoryQuestion { bool BeenAsked = false; public string Question { get; set; }
[Code] .....
Its probably some mistake I have made but I just can't see it.
I am trying to write a c program to convert centimeters to inches and then to feet. I have most of the code written but not sure how to debug it. I keep getting "0" as all of my output.
#include <stdio.h> // Main Function int main(void)
I have turbo c++ on windows xp SP2.....whenever i compile my code in turbo c++ i am getting output outside the screen.....but when i used code::block....i get the correct output...fits to screen ...
I need to display 0-15 hex numbers[0X00-0x0F] in decimal value...& I'm getting the output but it's not exactly what it should be,below is my code.. [This not the complete code,but main part where the changes are done]
Actual output i should get is for 1v it should generate 0001,for 2v it should generate 0010 and simultaneously till [15v-1111]... But what i'm getting is exactly different to this for eg for 7v,8v&9v the bits generated are 1101,1011,1011 respectively...
I have been given an assignment to make a code to read some text nd display all the words nd the number of times they appear in another file or as output without displaying the repeating words. I made the code but its not giving any output.
So I built an interpreter for a language I made, but I can't get the streams right. I have an istream pointer and if they don't supply a cmd line arg, it references the adress of cin, which works fine. however, if they do supply a file in the form of cmd line args, i want to make it reference an ifstream. how do i do that?
Im trying to choose a # between 1 and 1000 (can be 1 or 1000), error check it, but keep asking until I get the correct input.
#include<iostream> using namespace std; int main () { int num; bool goodNum; goodNum = false; while (!goodNum)
[code]....
This program analyzes a number, determining whether a number is prime or not, perfect or not, and output a list of all divisors for non-prime and perfect numbers.
Enter a number between 1 and 1000 then hit enter: 9000
I will keep this simple as I have the code written for my testing software program, I just want to add a feature of randomly generating the answer choice output order, I do not want to randomly output the full questions, but instead the choices (answers to the question), for example =
As you can see I would like to output the answers, choices randomly as in answer choice 3 will appear at the top instead of 1. and so on, it doesn't matter if the numbers move with the txt as the numbers beside the questions are txt.
I have recently looked into a self created project where I wanted to compare user input against a list of strings in an external file. That has since been completed to my great satisfaction, however it did throw up some interesting issues in my knowledge and understanding of user input..What is the best way to pick up user input i.e scanf,stdin etc. and when should either be used and can a mixture of types be used, and if so, when and why.
A quick program to take different input methods and display differnt output method (obviously corresponding i.e scanf/printf - fgets/fputs)
My first pothole came when I have setup the method for scanf - fine. Then I setup the method for fgets(test,100,stdin) for example and the fgets method no longer picks up stdin from the user..
My problem is the following : We have a circle paper of radius R. We will cut off a sector of this circle (with length rem_sec), and the remaining (bigger part) will create a cone. Radius of cone base is r.
I need to create a code that prompts the user to enter circle's radius R and the program will calculate the length of removed sector (rem_sec) so that the created cone has the Max Volume.
I wrote the following code, but it doesn't work. It displays both rem_sec and MaxV = 0.
#include <iostream> #include <cmath> #include <iomanip> #include <conio.h> using namespace std; const double PI = 3.1415; int main() { double rem_sec;
I just started on a project on c++ and I was wondering if it is possible to add a select option (where the c++ program requires the user to select an option) . I couldn't find this anywhere.