Question
Please write a c++ code with proper use of variable constants for my pseudo code. I am take a class that is teaching me flow
Please write a c++ code with proper use of variable constants for my pseudo code. I am take a class that is teaching me flow charts and pseudocode and I would like to see the actual code so that I can start preparing myself for next semesters classes. Here is the pseudo code:
// main module
Module main()
// Local variables
Declare OutputFile scoresFile
Declare Integer readScore
Declare String readPlayer = X
// open output file
Open scoresFile golf.dat
// write names and scores to file
While readPlayer != Z
Display Enter player name (Z to terminate):
Input readPlayer
If readPlayer != Z
Display Enter score:
Input readScore
Write scoresFile readPlayer readScore
End If
End While
// close the file
Close scoresFile
Declare InputFile scoresFile
// open input file
Open scoresFile golf.dat
// read and display all players in the file
While NOT eof(scoresFile)
Read scoresFile readPlayer readScore
Display Player , readPlayer, , score ,readScore
End While
// close the file
Close scoresFile
End Module
Output should look likes this:
Read each player's name and golf score from the keyboard and store them in a file.
Enter a player's name: Arnold Palmer Enter the player's score 74 Do you want to enter another record? Enter y for yes or anything else for no: y ... Store the data as comma separated records. For example: Arnold Palmer,74 Tiger Woods,69 Sam Snead,89 Micky Mouse,113 NOTE: On a windows machine, the file may be read with notepad. Other operating systems will have similar text editors to check the result.
6-2 Read data from a file
Quick and dirty table without a header
Player Name: Arnold Palmer Score: 74 Player Name: Tiger Woods Score: 69 Player Name: Sam Snead Score: 89 Player Name: Micky Mouse Score: 113
Step 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