Answered step by step
Verified Expert Solution
Question
1 Approved Answer
write a c++ programming , NOTE: your output may differ the outputs given in the values that appear on each line. This is because your
write a c++ programming , NOTE: your output may differ the outputs given in the values that appear on each line. This is because your random number generator may result in a different plausible value being selected. You must ensure that the value in the output file, x, falls within 1 x n. Hint: you will need to use the rand() function. It is a good idea to seed the random number generator. Refer to your textbook or the internet for more information regarding this.
Task 1 (week 1)- Random n sided dice, number generator A dice is an n sided shape with the sides labelled by numbers 1, 2, ..., n. The most common dice used to play various games is the 6 sided dice. You can however have dice that have many more sides. Write a C++ program that outputs different dice rolls for a given number, n, sided dice. Your code must do the following read in a number n from a file named input.txt, which represents the number of sides a dice has, then generate a random number that would be found on the dice and write this to a file named output.txt. The file has a list of unknown length of values for n. You must produce one dice roll for each value of n in the input file. First draw the flow chart and then attempt the code. Example 1 Examples of the input and output files can be seen below in Listings 1 and 2 Listing 1: Example of input.txt Listing 2: Example of output.txt Example 2 A second example of the input and output files can be seen below in Listings 3 and 4 Listing 3: Example of input.txt Page 2 of 4Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started