Description
NOTE: No Concession for Plagiarism! Must follow C++ style guidelines rules provided to you.
Question#01:
Write a C++ program that will read data from a file. Each line of this input file contains different mathematical expressions. Calculate the expressions and save the results into another file. Ask from user the name of input file with full path, locate it in your computer, open it, read the data, save the results in another file and close them. i.e.
-
Input File (Expressions)
Output File (Answers)
1+4+8+56+23+12+0+66
170
3-5-7-9+0-12+44
14
2*4*8*10*12*14
107520
2+5+6-11+4
6
5+7*8*88-55+0-44
4834
3*8-4/5
24
6+8/4-5
3
9-3+(5%4)+6
13
Question#02:
The English teacher at your University needs help in grading a True/False test. The students’ IDs and test answers are stored in a file. The first entry in the file contains answers to the test in the form:
TFFTFFTTTTFFTFTFTFTT
Every other entry in the file is the student ID, followed by a blank space, followed by the student’s responses. i.e.
ABC54301 TFTFTFTT TFTFTFFTTFT
DEF54301 TTTTTTTTTFTFTFFFFFT
JKL54301 FTFTFTFTFFTFTFTFTFTF
.
.
.
For example, the first entry indicates that the student ID is ABC54301 and the answer to question 1 is true, the answer to question 2 is False, and so on. This student did not answer question 9 that’s why there is a blank space. The exam has 20 questions, and the class has more than 150 students. Each correct answer is awarded two points, each wrong answer gets one point deducted, and no answer gets zero points.
Write a program that processes the test data. Show the output on console and write to the output file also in the following format; the output should be the student’s ID, followed by the answers, followed by the test score, followed by the test grade.
Assume the following grade scale:
90%–100%, A; 80%–89.99%, B; 70%–79.99%, C; 60%–69.99%, D; and 0%–59.99%, F.
Question#03:
-
Sr. No
Planet Population
Gravity
0
Earth:
6928198253
9.81
1
Jenny:
32155648
8.93
2
Tramtor:
89000000000 15.03
3
Trellan:
5214000
9.62
4
Freestone: 3945851000 8.68
5
Taanagoot: 361000004
10.23
You have been given an input file (planet.txt) as above. Write a C++ program that will show the user a manual having three different choices for copying, cutting and modifying the data. i.e.
-
If user enters the character ‘C’ on console then copy all the data from input file and paste it into another file named as “copy.txt”.
-
If user enters the character ‘X’ on console then cut all the data from input file and paste it into another file named as “cut.txt”.
-
If user enters the character ‘E or M’ on console then edit/modify any record in the input file based on user’s choice.
-
If user enters any other character then show this message “Wrong Input, Please Try Again”.
If user entered ‘E or M’ then,
Enter the record number you wish to change: 2
Your selection is: 2 Tramtor: 89000000000 15.03
Enter new name for this planet: Trantor
Enter planetary population: 89521844777
Enter planet’s acceleration of gravity: 10.53
Here are the new contents of the planets.txt file:
-
Sr. No
Planet
Population
Gravity
0
Earth:
6928198253
9.81
1
Jenny:
32155648
8.93
2
Trantor: 89521844777
10.53
3
Trellan: 5214000
9.62
4
Freestone: 3945851000 8.68
5
Taanagoot: 361000004
10.23
Question#04:
Design a struct that stores all the information about an employee. Name of the Struct should be “Employee_Struct” i.e. employee first name, last name, father name, emp_number, blood group, emp_age, factory name, department, phone number, email address, home address, salaries of previous four years (array of type string/double with size=4) .
Write code that declares an array of instances (variables) of this struct in main program and fills up all the input data from a file given below.
-
Write a function “swap” having two parameters of type “Employee_Struct” to swap all the values in struct variables and call it in main program?
-
Update all the salaries (S1-to-S4) of each employee with an increment of 5k respectively and write the updated data in an output file.
-
Sort all employee data in ascending order of age and print it on console.
F_Name L_Name Fther_N |
E_N |
B_G |
Age |
F_N |
DP |
Ph |
|
HA |
s1 |
s2 |
s3 |
s4 |
|
Ahmad Hussain Axel |
10 |
B+ |
26 |
FF |
Testing |
123 |
ABC |
P1 |
20k |
30k |
40k |
50k |
|
Eyal John |
Baren |
101 |
A+ |
28 |
FF |
Networks 234 |
DEF |
P2 |
10k |
20k |
30k |
40k |
|
Moshe Neyr Barry |
01 |
O+ |
29 |
FF |
Security |
345 |
GHI |
P5 |
20k |
30k |
40k |
50k |
|
Bla Casper Axel |
03 |
B- |
35 |
FF |
Design |
456 |
JKL |
P7 |
30k |
40k |
50k |
60k |
|
Hoda Claude Baren |
05 |
B+ |
30 |
FF |
Security |
678 |
MNO |
P3 |
50k |
60k |
70k |
80k |
|
et188 Crew |
Barry |
09 |
A+ |
33 |
FF |
Testing |
789 |
PQR |
P4 |
60k |
70k |
80k |
90k |
Steven Chester Axel |
13 |
A- |
22 |
FF |
Networks |
987 |
STU |
P1 |
30k |
30k |
30k |
30k |
|
Abel Clive |
Baren |
19 |
O+ |
23 |
FF |
Design |
876 |
VWX |
P1 |
50k |
40k |
40k |
45k |
Abraham Basil Barry |
20 |
AB+ |
28 |
FF |
Design |
765 |
XYZ |
P3 |
40k |
50k |
60k |
60k |
|
Good Luck