Question

********C++******** Develop the code to solve the problem statement below. Follow these style guidelines as you...

********C++********

Develop the code to solve the problem statement below. Follow these style guidelines as you develop the code. Use commenting to describe your code, and practice debugging if you run into errors. Submit your final source code.

Problem Statement: Open the rule document for the game you selected for your final project:

  • LCR Rules
  • Farkle Rules
  • Liar's Dice Rules

Use the document to write rules for the user on how to play the game in a text file. Then, using the information from the resource articles, create a program that will read in the text file and display it out to the user.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code in C++:

/*
C++ program to read rules from a text file and print them to the user
We use ifstream from the header file fstream to read from the file
We run a while loop to read line by line till file has not been read completely
*/
#include <iostream>
#include <fstream>
using namespace std;

//Main Function
int main()
{
string st;
ifstream file("rules.txt"); //reading file
cout << "The rules are as follows :" << endl;
if (file.is_open())
{
while(getline(file,st)) //while lines are still there in the file
{
cout << st << ' ';
}
file.close(); //closing file after use
}
else
{
cout << "Cannot open file";
}
return 0;
}

Output :

Add a comment
Know the answer?
Add Answer to:
********C++******** Develop the code to solve the problem statement below. Follow these style guidelines as you...
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
  • I need help figuring out how to code this in C++ in Visual Studio. Problem Statement:...

    I need help figuring out how to code this in C++ in Visual Studio. Problem Statement: Open the rule document for the game LCR Rules Dice Game. Develop the code, use commenting to describe your code and practice debugging if you run into errors. Submit source code. Use the document to write rules for the user on how to play the game in a text file. Then, using the information from the resource articles, create a program that will read...

  • C# Code: Write the code that simulates the gambling game of craps. To play the game,...

    C# Code: Write the code that simulates the gambling game of craps. To play the game, a player rolls a pair of dice (2 die). After the dice come to rest, the sum of the faces of the 2 die is calculated. If the sum is 7 or 11 on the first throw, the player wins and the game is over. If the sum is 2, 3, or 12 on the first throw, the player loses and the game is...

  • Develop a functional flowchart and then write a C++ program to solve the following problem. 1....

    Develop a functional flowchart and then write a C++ program to solve the following problem. 1. Create a text file named c1.txt and write your brand of computer (like Dell, HP, etc) in the file. You will be reading the name of the file from the keyboard as a string, using the string class. Your program will also read the brand of your computer from the keyboard. The process of the file creation (name of the file, mode for opening...

  • please answer correctly and follow the code structure given [JavaFX/ Exception handing and text I/O] 1....

    please answer correctly and follow the code structure given [JavaFX/ Exception handing and text I/O] 1. Write a program for the following. NOTE that some of these steps are not dependent on each other. Using methods is mandatory. Make sure to use methods where it makes sense. a. Ask the user for a series of integers entered from the keyboard. Use a sentinel value such as 999 to end the input process. If the entered values are not integers, throw...

  • this assingent is to  pseudocode, i have instructions and the example my teacher had given me for...

    this assingent is to  pseudocode, i have instructions and the example my teacher had given me for this, could i have some assistance, i need to do this in netbeans IDE and i need to use the scanner method as well and i need to pass both. Overview: This assignment will allow you to use pseudocode to implement the program to see the value in planning first, coding later. While coding is the glamorous part of the job, software development is...

  • Help please, write code in c++. The assignment is about making a hangman game. Instructions: This...

    Help please, write code in c++. The assignment is about making a hangman game. Instructions: This program is part 1 of a larger program. Eventually, it will be a complete Hangman game. For this part, the program will Prompt the user for a game number, Read a specific word from a file, Loop through and display each stage of the hangman character I recommend using a counter while loop and letting the counter be the number of wrong guesses. This...

  • Using C language to solve the problem below: 3. (5 pts) Construct a do-while () loop,...

    Using C language to solve the problem below: 3. (5 pts) Construct a do-while () loop, which continues to display the following menu: 1. Play game 2. Display score 3. Deposit funds 4. Exit and prompt the user for an option, while the option entered by the user is not in the range 1- 4, inclusive. Note: you are constructing an input validation loop. Show all variable declarations.

  • IN JAVASCRIPT 5. Write the pseudo code to solve the following problem (10pts/10pts) You are asked...

    IN JAVASCRIPT 5. Write the pseudo code to solve the following problem (10pts/10pts) You are asked to write a calculator program. Your calculator must perform Addition, Subtraction, Division and Multiplication. The user will enter two numbers and then an operator. If the user enters an operator other than the four mentioned the program will display an error message otherwise it will display the answer. Demonstrate use of an if statement

  • Give a problem statement that requires you to develop a Python program that meets the following...

    Give a problem statement that requires you to develop a Python program that meets the following requirements (2 EC points) The program reads data from a text file and then assigns it to a string variable (2 EC points) The program defines and calls at least one function other than main() (2 EC points) The program uses a multi-way branch (if, followed by a number of elifs, followed by else) (2 EC points) The program uses a loop (for loop...

  • How do i write the pseudocode for this java code? First, write out pseudocode, and then create a program to help you by accomplishing the following tasks: :  Use command line interface to ask the use...

    How do i write the pseudocode for this java code? First, write out pseudocode, and then create a program to help you by accomplishing the following tasks: :  Use command line interface to ask the user to input the following. ○ How many apples are on hand ○ How many apples should be in stock ○ How many oranges are on hand ○ How many oranges should be in stock  Perform an operation to determine how many of...

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
ADVERTISEMENT