Question: Write a C++ program that asks for both a file and name of a student. Then: If you cannot open the file, display File does
Write a C++ program that asks for both a file and name of a student. Then: If you cannot open the file, display File does not exist. and stop the program. If the student is not in the file, display No student with that name. If the student is in the file, show their grade. You may assume the format of the file is the same as the given example grades.txt. You cannot make any assumptions on the number of students in the file. You can assume each students name in the file is unique.
Example 1 (user input is bold):
What file?
iDontExist.txt
Whose name?
Jacob
File does not exist.
Example 2 (user input is underlined):
What file?
grades.txt
Whose name?
Jacob
No student with that name.
Example 3 (user input is underlined):
What file?
grades.txt
Whose name?
Anisha
Grade:
C
grades.txt is below:
James : 67.34 : D+ : Senior Maximilian : 93.23 : A : Junior Gal : 85.94 : B : Sophomore Fox : 23.10 : F : Senior Baldo : 99.99 : A : Freshman Emyr : 94.33 : A : Senior Grigorii : 75.29 : C : Junior Ibb : 88.41 : B+ : Freshman Gerardo : 71.93 : C- : Freshman Sonam : 84.11 : B : Freshman Fabiana : 91.49 : A- : Junior Shams : 83.83 : B : Senior Filip : 13.45 : F : Sophomore Anisha : 74.12 : C : Senior Kilian : 63.41 : D : Sophomore Tamatoa : 95.00 : A : Junior Gurmeet : 74.20 : C : Sophomore Aminda : 83.13 : B : Senior Lubomir : 81.30 : B- : Freshman Miguela : 74.20 : C : Senior Bernard : 89.58 : B+ : Junior
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
