Pre-lab homework. Read parts 1 and 2 below, then turn in a flowchart for the program described in part 1 below.
Reminder: All pre-lab homework is due at the beginning of the lab period, and late pre-lab homework will earn a grade of 0.
Grades will be entered as
and the user will indicate that he's done by entering
Q. Lower case versions of all of these
must be accepted as well, but you MAY assume that invalid data is never
Example run. User input appears in red
Input letter grade and hours (or Q to quit): A 3Input letter grade and hours (or Q to quit): b 3Input letter grade and hours (or Q to quit): a 1Input letter grade and hours (or Q to quit): C 5Input letter grade and hours (or Q to quit): B 3Input letter grade and hours (or Q to quit): QGPA = 2.93333
Opening files when the user provides the
name is a
string object with the name of the file
you'd like to open, then
opens an input stream to that file, not
(name), like you'd hope. The following
deal is this: the
a C-style string, not a C++
object. When you have a C++
) evaluates to the C-style version of
the same string.
these input files, there is no
to indicate that there are no grades left. Instead, the file just ends. If the
file is not found, you should print an error message and end your program. You
can end your program anywhere with "
1)", which is available when you
library. To make your life easier, you should save these input files in the
directory of your project.
Program run: 1st attempt
Program run: 2nd attempt
C 3D 2C 5f 3b 3 Enter file name: Grades1.txtError! File Grades1.txt not found! Enter file name: grades1.txt file grades1.txt ... ReadingGPA = 1.6785
If you finish the lab assignment early you should try to tackle this problem:
Look at the information in this basic html tutorial. It describes how programs can produce web pages as output. Write a program that reads in the same grade data files as in Part 2 and formats them in html as a nice table. Rules are that the table must have column headings for "grade" and "hours", and grades must be written in capital letters, regardless of whether they are capital or lower-case in the input file.
Output file grades1.html
Browser rendering of grades1.html
Enter input file name: grades1.txt
Enter output file name: grades1.html
For a tougher challenge consider this problem:
Download and save the file named "baby_names.dat". It contains the most popular baby names of 2006 according to the U.S. Social Security Administration. The format of of the file is as follows:
You can see for yourself by right-clicking on the file and opening it with Notepad.
Write a program that:
1. Asks the user for a name.
2. Searches the file for the name.
3. Prints the baby name's rank and total number of babies with that name to the screen.
And Even Furtherer...
For the ultimate challenge consider this problem:
The Social Security Administration does not provide a combined list of boy and girl names. Instead it lists the top 1000 baby names of each sex in two separate files, named "boys.dat" and "girls.dat". The file format is the same as the combined list from the previous problem.
Well if the SSA didn't provide a combined list, how did we get it? We made it! Now you will do the same.
Write a program that merges the two files into a single file, ordering from most popular to least. Note that the most popular girl name is only fourth when to the two list are combined. You will have to make sure that your program inserts the names to the new file in the proper order.
You may have noticed that the two individual files contain a total of 2000 names, but the combined file from the previous problem contains only 1,942 names. What happened to those other names? Well some names (such as Ashton, Bailey, and Jordan) are boy and girl names. Your program will have to combine the two numbers and insert the name in the list at the appropriate position based on its combined popularity.
Write a program that:
1. Opens the two files.
2. Combines the two lists into one list and outputs a file named, "combined_baby_names.csv"
Your output file must have now repeated baby names and be formatted properly: name ,number Don't forget the comma!!!
The ".csv" extension is important. It is comma separated values file that Microsoft Excel recognizes and can read. Confirm that your program executed properly by using Excel to open the file you produced.