Part of lab lesson 7 There are two parts to

 

Part of lab lesson 7

There are two parts to lab lesson 7. The entire lab will be worth 100 points.

Bonus points for lab lesson 7

There are also 10 bonus points. To earn the bonus points you have to complete the Participation Activities and Challenge Activities for zyBooks/zyLabs unit 10 (Gaddis Chapter 5). These have to be completed by the due date for lab lesson 7. For example, if you complete 89% of the activities you will get 8 points (there is no rounding).

Lab lesson 7 part 2 is worth 50 points

For part 2 you will have 40 points if you enter the program and successfully run the program tests. An additional 10 points will be based on the style and formatting of your C++ code.

Style points

The 10 points for coding style will be based on the following guidelines:

  • Comments at the start of your programming with a brief description of the purpose of the program.
  • Comments throughout your program
  • Proper formatting of your code (follow the guidelines in the Gaddis text book, or those used by your CS 1336 professor)
  • If you have any variables they must have meaningful names.

Development in your IDE

For lab lesson 7 (both parts) you will be developing your solutions using an Integrated Development Environment (IDE) such as Visual Studio, Code::Blocks or Eclipse. You should use whatever IDE you are using for your CS 1336 class. Once you have created and tested your solutions you will be uploading the files to zyBooks/zyLabs. Your uploaded file must match the name specified in the directions for the lab lesson. You will be using an IDE and uploading the appropriate files for this and all future lab lessons.

For this and all future labs the name of the source files must be:

lessonXpartY.cpp

Where X is the lab lesson number (7 for lab lesson 7) and Y is the part number (1 for part 1, 2 for part 2).

You will need to develop and test the program in your IDE. Once you are satisfied that it is correct you will need to upload the source file to zyBooks/zyLabs, and submit it for the Submit mode tests. If your program does not pass all of the tests you need to go back to the IDE, and update your program to fix the problems you have with the tests. You must then upload the program from the IDE to zyBooks/zylabs again. You can then run the tests again in Submit mode.

When running your program in Submit mode it is very important that you look at the output from all of the tests. You should then try and fix all of the problems in your IDE and then upload the updated code to zyBooks/zyLabs.

C++ requirements

  • The numbers need to be read in as type double. The calculations need to be done using type double as well.
  • You must properly handle end of file conditions.
  • You must properly open and close any files.

Failure to follow the C++ requirements could reduce the points received from passing the tests.

General overview

In this program you will be reading numbers from a file. You will validate the numbers and calculate the average of all of the valid numbers.

Your program will read in a file with numbers. The numbers will be of type double.

The numbers should be in the range from 0 to 105 (inclusive). You need to count all of the numbers between 0 and 105. You also need to calculate the average of these numbers. The average will be written out with four digits to the right of the decimal point.

If a number is not valid (that is, it is less than 0 or greater than 105) you need to count it (as a count of invalid values) and you need to write out the number to a file called “invalid-values.txt”. Values written to file invalid-values.txt should be in fixed format with five digits to the right of the decimal point.

As you did in lab lesson 7 part 1 you need to read in the input file name using cin. The prompt for the input file name is:

Enter input file name

You need to properly handle end of file conditions. See lab lesson 7 part 1 for details on reading files. Also see Demo of file input and output of data in this unit.

The output from your program will be written to cout. The output must contain the file being processed, the total number of values read in from the file, the number of invalid values read in, the number of valid values read in.

The last thing you need to output is either the average of the valid values or an error message. The average must have four digits of precision to the right of the decimal point and must be in fixed format. If there is not valid average you should output the message:

An average cannot be calculated

In what case would you display this message?

If the input file cannot be opened, you will need to output a message. Assume the input file name is badinput.txt and it cannot be opened. You will display the following error message to cout

File "badinput.txt" could not be opened 

Here is an example of a working program:

Assume the file name read in from cin is:

input.txt

and that input.txt contains:

-12
0
98.5
100
105.5
93.5
88
75
-3
111
89
-12

Your program would output the following:

Enter input file name
Reading from file "numbers.txt"
Total values: 12
Invalid values: 5
Valid values: 7
Average of valid values: 77.7143

The contents written out to file invalid-values.txt are:

-12.00000
105.50000
-3.00000
111.00000
-12.00000

You are reading from an input file and you are writing to an output file. Make sure you close both files after you are finished using them. You must do this in your program, you cannot just let the operating system close the files for you.

For tests where there is output written to an output file the contents of the output file will determine if you passed that test or not. For cases where you have written out to cout the tests will check the output sent to cout. In some cases output will be written to a file and to cout. When this is the case the test will be run twice with the same input. Once to test cout and once to test the contents of the output file. An example of this would be tests 2 and 3. Both use the same input file. Test 2 check the output written to cout and test 3 checks the output written to the file invalid-values.txt.

Failure to follow the requirements for lab lessons can result in deductions to your points, even if you pass the validation tests. Logic errors, where you are not actually implementing the correct behavior, can result in reductions even if the test cases happen to return valid answers. This will be true for this and all future lab lessons.

Expected output

There are eight tests. Some tests are parts 1 and 2 of one test. Test 1 uses an input file that contains only valid values. Test 2 tests an input file that does not exist. Test 3 and 4 each have two parts. The first part tests the output to cout and the second part tests the contents of the output file invalid-values.txt. The final two tests have just one part.

You will get yellow highlighted text when you run the tests if your output is not what is expected. This can be because you are not getting the correct result. It could also be because your formatting does not match what is required. The checking that zyBooks does is very exacting and you must match it exactly. More information about what the yellow highlighting means can be found in course “How to use zyBooks” – especially section “1.4 zyLab basics”.

Finally, do not include a system("pause"); statement in your program. This will cause your verification steps to fail.

Note: that the system("pause"); command runs the pause command on the computer where the program is running. The pause command is a Windows command. Your program will be run on a server in the cloud. The cloud server may be running a different operating system (such as Linux).

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

For this assignment, you will examine the data collection instruments

For this assignment, you will examine the data collection instruments  used in two peer-reviewed articles on a technology topic and present  the findings. Address all components for each article before moving on  to the next article. Your paper should include the following: A discussion of the purpose of the instrument.

Question: A simulated disaster and comprehensive recovery test may involve

 Question: A simulated disaster and comprehensive recovery test may involve many of an organization’s key personnel for several days: is this a reasonable burden to place on a busy, competitive company? How would you argue against the inevitable tendency to shortcut the procedure? ***Standard for all discussion posts:A substantive post

The hakka fried noodle is a very unique asian noodle

  The hakka fried noodle is a very unique asian noodle recipe. You can learn how to make this special Hakka fried noodle right at home using the recipe that I will share with you in a moment. One of the simple and welcoming meals that you can share with

Calum McLaughlin

Description Client Name ; Calum Goals – To lose body fat but gain muscle mass. Have body weight around 90kg Stage 2: Development Minimum Evidence Requirements Comments Develops a coherent line of thought. — Provides a clear introduction summarising the main points of the project brief ensuring it links and

Week 5 position paper: Border Security

Communication is used to inform, to persuade and to analyze. In this Analytic Writing assignment, this essay will be used to analyze both sides of an issue for a fair and objective presentation. If you want to know which citation style to use with your major, consult The APUS Library

The Assignment In 3 pages, address the following: Explain your

The Assignment In 3 pages, address the following: Explain your state laws for involuntary psychiatric holds for child and adult psychiatric emergencies. Include who can hold a patient and for how long, who can release the emergency hold, and who can pick up the patient after a hold is released.

Loews Hotels: Training for Four-Diamond Service and More Pages 274

  Loews Hotels: Training for Four-Diamond Service and MorePages 274 – 275 (Chapter 7)ContentContent Read the Case Study entitled, “Loews Hotels: Training for Four-Diamond Service and More ” on pages 274-275 (Chapter 7)          several times to get a good understanding of the case…   Write a COVER PAGE, then, write a

Due 12/18/22: What is YOUR assessment of China’s Belt &

Due 12/18/22: What is YOUR assessment of China’s Belt & Road Initiative (i.e. how do you see it impacting the global supply chain and USA’s strategic interest)?  How has the COVID pandemic impacted its development? Must include the following:1) Have you incorporated my feedback to your draft?2) Your response needs

Explain the role of stakeholder in the training program

Writer you have completed section 1, 2 and 3 to this training program. I am posting the remaining sections of the training program. I will also repost sections 1,2 and 3 to refer back to. Below this assignment you will find sections 1,2 and 3 for your viewing. Part IV

2 PART QUESTION: The Tupamaro are considered revolutionary warriors. Who

2 PART QUESTION: The Tupamaro are considered revolutionary warriors. Who are they and where did they come from? What influence did they have over the region in which they resided? Please be sure to support your response with peer reviewed research and proper APA 7th edition in-text and reference citations.

Federal laboratories, universities, or industrial laboratories? Based on the course readings, which institutional setting contributed most significantly to

Federal laboratories, universities, or industrial laboratories? Based on the course readings, which institutional setting contributed most significantly to the development of physics in the 20th century? Explain your rationale with examples. Additionally, did 20th century physicists have more significant achievements on earth or in space (including all institutional settings)? Explain why. Finally,

What do the people of Thebes and the people of the United States have in common?

Bowie State University Department of Fine and Performing Arts Introduction to Theatre (Theatre, Culture & Society) INTRO THEA 105-555. Spring 2019. RESPONSE PAPER 012419 STAGE ONE: Thesis Statement and six quotes from the plays: DUE Sunday, February 17 (10 points) STAGE TWO: Outline: DUE Sunday, February 24 via Blackboard. (20

FIU Medical Application Appraisal Paper Nursing Assignment Help

1. PART 1: The medical application selection for this assignment is contingent upon the month of your birthday. Use the table below to identify the Medical App for this assignment. Your Birth MonthMedical App for Assignment January, FebruaryMDCalc March, April, MayMedscape June, July, AugustThe Chief Complaint September, OctoberPocket Pharmacist(PocketRx)November, DecemberSingleCare

5-1 Final Project Milestone Four: Addressing Policies Continue analyzing the

  5-1 Final Project Milestone Four: Addressing Policies  Continue analyzing the situation your case study’s healthcare organization faces. In this milestone, you will evaluate the impact of policies and policy changes on the healthcare organization’s strategic plan. You will also consider the role the healthcare manager and other organizational stakeholders