[SOLVED] CSE1PES : PROGRAMMING FOR ENGINEERS AND SCIENTIST

$25

File Name: CSE1PES_:_PROGRAMMING_FOR_ENGINEERS_AND_SCIENTIST.zip
File Size: 461.58 KB

5/5 - (1 vote)

CSE1PES : PROGRAMMING FOR ENGINEERS AND SCIENTIST
LAB 9, WEEK 11
TOOLS
Unix server through Putty
Notepad ++
LMS
SUBMISSION
Version: 4
Last updated: 12/05/2019
for compiling and testing
for writing solutions
for submission
All tasks and questions need to be submitted using LMS before the end of the lab
Lab developed by Matthew Felicetti 2016, updated 2017(MF), updated 2018(MF), updated 2019(MF)

TASK 1.
This lab will introduce you to testing using a macro for including debugging information. This will allow you to find errors in your logic and calculations.
The problem the program solves is described in the steps.
STEPS
1. Read the following program description:
a. Asks the user for the input files filename, collects filename from user and stores appropriately. (Assume
max characters for file name is 100)
b. Opens the input file specified for reading. The file will contain the number of students in the first line. (ref to
example). On the following lines, each contains a student number (7 characters long) (Assume max 100 characters), a mark out of 100 for a first assignment, a mark out of 100 for a second assignment and a mark out of 100 for a third assignment.
c. Loop through each of these students and check for the following to determine if the information is invalid:
If the student number is not 7 characters, If assignment 1 mark is greater than 100, If assignment 1 mark is less than 0,
If assignment 2 mark is greater than 100, If assignment 2 mark is less than 0,
If assignment 3 mark is greater than 100, If assignment 3 mark is less than 0,
d. If one or more of the conditions are true then print out Invalid student information. This should only be printed once per student.
e. If the information is valid for a given student, you need to calculate the percentage of each mark for the total grade. The first assignment is worth 10%, the second is worth 40% and the third is worth 50%. (If invalid go back to the start for the next student)
f. Then calculate the total percentage. Then store the resulting letter grade, given that if the total is greater or equal to 80% then the letter grade is A, 70% is B, 60% is C, 50% is D and less than 50% is F.
g. Then print this information out to the screen using the following format:
2. Draw the flow diagram of above to design your program. (Marked)
Common symbols can be found here: https://lms.latrobe.edu.au/mod/resource/view.php?id=3249487
THE IMPORTANCE OF DESIGN
PROBLEM

EXAMPLE TEXT FILE
EXAMPLE OUTPUT
RUBRIC
0 marks
1 mark
2 marks
3 marks
Flow diagram completely incorrect
Flow diagram does not follows standards provided but is partially correct
Flow diagram follows standards provided and is partially correct
Flow diagram follows standards provided and is completely correct

TASK 2.
This lab will introduce you to testing using a macro for including testing information. This will allow you to find if your program works for a large amount of test cases.
STEPS
1. Write the program that you have designed based on your flow diagram
2. Download all of the testing and input files from LMS.
3. Create the macro TEST.
4. Create two variables appropriately, in an appropriate location in the code, named passed and failed and initialize
both to 0.
5. Then at the start of the program before asking for the input file, test if the TEST macro is defined, if so:
a. Ask the user to enter the name of test file, collect the filename from user and store appropriately. (Assume max characters for file name is 100)
b. Open the test file specified for reading
THE IMPORTANCE OF TESTING
PROBLEM
6. Where
a. Read the current line of text in the test file using fgets function and store appropriately (You can assume
ever you print Invalid student information
in your code, after this test if the TEST macro is defined, if so:
that it will not read more than 60 characters)
b. Compare the string read with Invalid student information (strcmp) and if equal increment pass variable
else increment fail variable.
ever you print the information on the valid students to the screen in your code, after this test if the TEST
7. Where
macro is defined, if so:
a. Read the current line of text in the test file using fgets function and store appropriately (You can assume that it will not read more than 60 characters)
b. Use sprintf to make a copy of what is to be printed to the screen. Use this reference to understand how this function works : http://www.cplusplus.com/reference/cstdio/sprintf/ (You can assume that the text will not be more than 60 characters)
c. Compare the string read with the copy of what is to be printed (strcpy) and increment pass variable else increment fail variable.
8. After the input file has been fully read
a. Test if the TEST macro is defined, if so:
i. Print to the screen the number of failed cases and passed cases 9. End the program appropriately.
Note: As we are limiting the invalid cases in task 1, the input file will only have invalid values in regards to these conditions.
Use the pairs input1.txt and testing1.txt, input2.txt and testing2.txt, to test your code.

EXAMPLE OUTPUT
With TEST defined
EXAMPLE TEXT FILES
input1.txt
testing1.txt
RUBRIC
0 marks
1 mark
2 marks
3 marks
Does not compile regardless of how much is complete
Program attempted
Program implemented but does not pass test cases
Program implemented and passes all test cases

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CSE1PES : PROGRAMMING FOR ENGINEERS AND SCIENTIST
$25