C++ :: Rock Paper Scissors Game - How To Add Play Again Option
Apr 1, 2014
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() {
[Code] ....
View 1 Replies
ADVERTISEMENT
Aug 11, 2014
today I've been working on a rock, paper and scissors game. It compiles OK, except:
It doesn't use a random number from 1 -3, or goes out of scope.2. It doesn't COUT and it doesn't flush the buffer.3.
My code is as follows:
#include <windows.h>
#include <iostream>
#include <cstdlib>
#include <ctime>
std::string randomPC(int &);
void PCSelect(int &);
[code]....
View 2 Replies
View Related
May 14, 2014
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);
[Code] .....
View 1 Replies
View Related
Oct 10, 2013
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>
[Code]....
View 10 Replies
View Related
Dec 2, 2013
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.
#include <iostream>
#include <string>
#include <cmath>
[Code]....
View 1 Replies
View Related
Nov 16, 2014
I have a Blackjack game that allows users to create a login account and it keeps track of their bet amount, and total bank,etc. How can I connect the program on 2 or more computers so that people can play together?
(A) How would I code it? (B) Can I just connect a USB or HDMI and use the appropriate code? (C) Do they need to be executables instead of just running out of Visual Studio? (D) Can this maybe done over Wi-fi? (E) Or is this something more complicated like over a VPN?
View 2 Replies
View Related
Dec 14, 2014
"Write a program to play a numbers guessing game. The user thinks of a number between 1 and 100 and your program asks questions to figure out what the number is (e.g., "Is the number you are thinking of less than 50?"). Your program should be able to identify the number after asking no more than seven questions. Hint: Use < and <= opeartors and the if-else construct."
What I've managed so far, but what I have seems to be lacking
Code:
#include "../../std_lib_facilities.h"
int half(int guess);
int going_up(int i);
int main()
[Code] ....
View 4 Replies
View Related
Sep 11, 2013
OK, so the program is working minus the play again loop. I even tried a goto statement for it but no luck. Basically what its doing is after the game runs its course it asks if you would like to play again? If you hit Y it starts over but if you it N it starts over. I want it to out put thank you for playing and close after user hits a button.
// C// Guess My Number
// The classic number guessing game
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
[Code] ....
View 1 Replies
View Related
Jan 23, 2014
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;
[Code] ...
View 5 Replies
View Related
Sep 20, 2014
I want to print a report half sheet in A4 size..
I tried to change paper size in coding and in properties also but no use..so what is the correct code to change as custom size of report.
View 1 Replies
View Related
May 27, 2013
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.
View 3 Replies
View Related
Sep 9, 2012
I'm getting Unhandled exception when try to run option 3.
This my code below.
Code:
#include <iostream>
#include <string>
using namespace std;
struct Vet {
string name;
int numOfAnimals;
string phoneNum;
[code]....
View 8 Replies
View Related
Jul 30, 2013
I've been having problems with my loop that asks if the user wishes to continue or not. The required input should either be 'y' or 'Y', or 'n' or 'N'. Anything else should be counted as invalid, and repeat the prompt for input. The first few times I ran my program, the compiler does not read it as a loop. The next few times just won't work properly.
Here is the prompt:
Code:
void question() {
char option;
printf("
Do you want to continue? {Y|N) ");
scanf("%c", &option);
[Code] ......
As it is, it immediately runs the else option, but otherwise runs just fine. I suspect it could be because I have not specified a size for the option variable, but I try doing that, and the prompt relegates everything to the else.
(And also, here's the rest of the code. Basically, it just assigns a value to the letters of the word (a/A = 1, b/B = 2, etc.), adds these values, and determines if a word is prime or not based on the sum.)
Code:
#include <stdio.h>
#include <string.h>
#define size 30
int main() {
char letter, word[size], lower, upper, option;
int i, value, ans = 0, a, choice = 1;
[Code] .....
View 4 Replies
View Related
Feb 13, 2014
I have a menu for a project that takes a string input and does whatever option you specify. It works perfectly EXCEPT when it goes through the while-loop (while you didn't say quit the menu reloads). It will spew out all the text in the menu like a bulimic teenager. Then it reloads properly and asks you for an input like nothing happened. While this is not a fatal error (code still functions)...
Code:
#include <stdio.h>
#include <math.h>
#include <string.h>
double aa=0, ab=0, ac=0, sa=0, sb=0, sc=0;
char a1[13], o1[]="AAS
[Code] .....
View 2 Replies
View Related
Jan 14, 2014
i need one more option which it can display all the items i have entered in alphabetic order in my program..this is my coding......
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define capacity 1000
void cal_item(struct item[capacity]);
void input(struct item[capacity]);
}
[code]....
View 1 Replies
View Related
Nov 21, 2014
Remove the break statements from each of the cases. What is the effect on the execution of the program?
Add an additional switch statement that allows for a Passing option for a grade of D or better. Use the sample run given below to model your output.
Sample Run: What grade did you earn in Programming I ? A YOU PASSED! an A - excellent work!
Rewrite the program LastFirst_lab44.cpp using if and else if statements rather than a switch statement. Did you use a trailing else in your new version? If so, what did it correspond to in the original program with the switch statement?
// This program illustrates the use of the Switch statement.
// The break statement causes all subsequent expressions to be executed as well, also known as "falling through".
// The trailing else statement acts just like the default section if none of the options from before work it gets "defaulted" to it.
#include <iostream>
using namespace std;
int main() {
char grade;
cout << "What grade did you earn in Programming I ?" << endl;
[code]....
how do you add an additional switch statement? i tried multiple times and i'm not sure if i don't understand braces enough but it didnt seem doable. also, I'm not sure what the teacher wants me to submit.
View 1 Replies
View Related
May 6, 2014
I need to do a code that gave me Original string, uppercase string, lowercase string, reverse string (if letter is upper then convert to lower, and if lower then convert it to upper) and uppercase first (first character of each word in uppercase).
I need to do it in functions but i dont know hot to use strings. The program should provide the option to save the outputs in a file.
View 4 Replies
View Related
Apr 4, 2013
Code: Obj<TCHAR>* obj = dynamic_cast<Obj<TCHAR>* >(I->objects[0]);
Which is resulting in this error
Code: A dynamic cast is present, but the correct RTTI option is not specified.
View 3 Replies
View Related
Jul 21, 2014
How do I play a simple mp3 through my mic. I plan on using this to just play annoying sounds through skype and games(on windows 7 btw).
View 6 Replies
View Related
Mar 11, 2013
I am running ubuntu and have tried adding -1GL to the end of my gcc compiling commands but the error says "unrecognized commandline option: 1GL". do i have to install any packages to get this to work?
Its supposed to be an l not a 1.
View 1 Replies
View Related
Sep 17, 2014
Basically i have a 'HomeWindow' with a button 'OptionWindow'. My idea is that the 'OptionWindow' button will open up the 'OptionWindow'. Which will give the user three options 'Option1', 'Option2' and 'Option3'. If they pick 'Option1' then in the 'HomeWindow' in a stackpanel i want it to display 'UserControl1'. Where as if they pick 'Option2' then in the 'HomeWindow' in a stackpanel i want it to display 'UserControl2'.
If you need some of my code that i have already then let me know what you need as i have a lot of it so can't paste it all in one go. But the new thing i need is the way of making the user-controls in the 'HomeWindow' change depending on what is selected in the 'OptionWindow'.
View 14 Replies
View Related
Mar 6, 2014
I understand how to play a .wav file in a program, but I am attempting to "package" the .wav file with the project so that it can be played by another person, on a different machine (namely, my professor). The way I have come to understand this is that if you use the following line of code:
PlaySound(TEXT("C:WindowsMedia
otify.wav"), NULL, SND_FILENAME);
The sound file would not play if it is not in the same location on the other computer. Am I correct? Assuming that I am, I have added the file that I wish to play as a resource in my project, but I can't figure out how to make it play. Looking at MSDN (and other resources) I found the following snippet:
#define MAKEINTRESOURCE
PlaySound(
MAKEINTRESOURCE(L"notify.wav"),
GetModuleHandle(NULL),
SND_RESOURCE);
I get no errors when I build the program, but no sound plays when I run it. I have tried for hours now to figure this out (which is usually enough time for me to sort through the problem) but I have met with no success. This leads me to believe I am either completely off in my assumptions, or I am making a silly mistake.
View 6 Replies
View Related
Feb 2, 2015
Suppose you want to develop a program to play lottery. The program randomly generates a Lottery of a three-digit number( any number from 100 to 999), prompts the user to enter a three-digit number, and determines whether the user wins according to the following rule:
1. If the user matches the lottery in exact order , the awards is $100,000.
2. If the user input matches the lottery digits, the awards is $50,000.
3. If two digit in the user input matches a digit in the lottery, the awards is $30,000.
4. If one digit in the user input matches a digit in the lottery,
the awards is $10,000.
Sample:
The winning number is 865.
Your ticket is 865 then 100000
Your tickect is 686, or 568,.. all digits are right but not in order
You get 50000
Your ticket is 860, or 186 .. then 30000
Your ticket is 800, 706, 600.. just one digit much you get
10000
Else
0
Im using if/else statements. Which syntax would I use to figure out the limit between 100-99?
View 1 Replies
View Related
Jul 16, 2013
How can I play sound when the program ends? I am using Windows 7.
View 15 Replies
View Related
Jul 7, 2013
I got this code from a wiki that taught me how to make C code that plays audio, and with a few changes I was able to get it to take a command-line argument as the music file name. Here it is
Code:
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
int main(int argc, char *argv[])
[Code] ....
The only problem is, even though I guess it needs to create a window to work with SDL, is there any way you could hide it or something so the user can't see it? I don't really want to see it ( I'm planning on running it from Batch files or C applications as an easy way to play an audio file once ), because if I did, I might as well just use a default audio player instead.
View 3 Replies
View Related
Jul 2, 2014
How can i play a mp3 file in the background?How can i rule the volume of the mp3 file?why does delay(0.25) doesnt work in this code?
Code:
FILE *datei;
char line[ANZAHL][LAENGE];
int i ;
datei = fopen ("song.txt", "r");
if (datei != NULL){
for(i = 0; i < ANZAHL;i++) {
delay(0.25);
fgets(line,LAENGE,datei);
printf ("%s
[code]....
View 2 Replies
View Related