d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Low Level C++ Help Needed
Add Reply New Topic New Poll
Member
Posts: 5,366
Joined: Aug 31 2008
Gold: 1,047.00
Oct 15 2012 11:22am
/*******
Create a new console application titled “Assignment 5”. This application will be used to simulate the rolling of 2 standard dice (range of 1 – 6 each). The program will start and immediately roll the 2 virtual dice. The console output will display the results of the roll as both a text numeric value (1 for each dice) and a graphic representation of the number displayed on each of the dice. The graphic representation will be created by using cout with ASCII characters across multiple lines. The output should be the first dice followed by the second dice displayed underneath the first. The ASCII graphic should look like the face of a dice.

Once the dice have been displayed the program will ask the user if they want to quit or roll again. Use a ‘q’ to quit and an ‘r’ to roll again. Make sure to support both upper and lower case versions of these characters.

If the user rolls again the program should clear the console display, re-generate 2 new random numbers for the dice and display their values as described above. This process should repeat until the user quits the program.

If the user chooses to quit the program should immediately terminate.

Use a “while loop” that loops until valid input is received from the user.

Any input other than ‘q’ or ‘r’ should be identified as invalid input by outputting 3 beeps and the user should be notified but the program must NOT quit unless it receives an ‘q’ at the appropriate time. The code for this should be inside the while loop.

This application must use a switch statement when displaying the output (e.g. case 1: // output ASCII graphic of dice and the numeric value for number 1

The switch statement must be contained inside a “for loop” that is designed to loop twice, once for each dice. This loop is very useful as you can execute the same switch statement twice!

This application must use a “do while” loop to control the flow of the program. The loop should be controlled by the user input (‘q’ or ‘r’)

As always make sure you include the required header information, comment your code and use descriptive variable names.
********/

I am a beginner and not very good with if statements and loops.
Any help is appreciated.
Feel free to pm me or post here.
Looking to make some C++ friends on here who know what they're doing.
Member
Posts: 24,101
Joined: Nov 8 2007
Gold: 5,561.70
Oct 15 2012 02:04pm
Here's a basic setup, forget do while syntax but this is what should happen.

do while(while some char is either a q or a r)
--roll dice 1 (use a random number generator to generate numbers between 1-6, should be able to google how to code one in C)
--roll dice 2 (use RNG from dice 1)
for(i = 0, i < 2, i++)
Setup cases from 1-6 depending on the number.
---print the statements in ascii
---this will run threw both dice
Make a scanf() function that takes in a char value, if its r or q, roll dice, if not loop should exit(use break)
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Oct 15 2012 06:54pm
why do you keep posting about low level c++. unless you are refering to 'basic' c++ programming because there is no reason to use inline asm or other low level system hooks or functions for these.

i work for fg or if you create your own code and get stuck you can post here or pm me and ill give you some hints on how to fix it.

This post was edited by AbDuCt on Oct 15 2012 06:55pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll