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

NUR 3165 CIF Nurse Workplace Safety Discussion Nursing Assignment Help

Unit 9 Discussion Forum Discussion Forum (suggested level of effort: 1 hour) The purpose of a discussion forum is for students to engage one another over topics related to the course material.  An initial post by each student “sets the table” for follow-on responses by other students.  In a graduate-level

Evaluate factors that influence quality, safe, patient-centered care.

Premium Paper Help is a professional writing service that provides original papers. Our products include academic papers of varying complexity and other personalized services, along with research materials for assistance purposes only. All the materials from our website should be used with proper references.

Provide examples of (1) a deductive valid argument and (2)

Provide examples of (1) a deductive valid argument and (2) a deductive invalid argument that are based on something in your everyday life. So, you only need to come up with a total of twoexamples, by choosing one valid form and one invalid form (see handout for forms).  Be sure to identify which two

FNU Community Health Nursing Discussion Nursing Assignment Help

Population affected by disabilities. Rural and migrant health. Read chapter 21 and 23 of the class textbook and review the attached PowerPoint presentations.  Once done, answer the following questions. 1.  Define and discuss in your own words the definitions and models for disability. 2.  Discuss the difference between illness and

We need academic writers. We need a serious tutor with

We need academic writers. We need a serious tutor with a group of writers who can do around 20 pages per day and 10 pages per night. We need a tutor who will act as a manager to his or her tutors where we will not get any cases of

Deliverable Length: 3-5 pages (not including cover page and resource

Deliverable Length: 3-5 pages (not including cover page and resource page) u are a consultant hired by a company to evaluate its strategic competitive position in the industry. Choose a company from the following Web site: You will evaluate the company’s strategic competitive position by using Porter’s Five Forces model.

Choose one of the ethical theories covered in this chapter

  Choose one of the ethical theories covered in this chapter (listed below) to define and provide an example of how you would apply the theory to everyday life? normative theory consequentialist theory non-consequentialist theory egoism hedonism utilitarianism libertarianism Be sure to respond to at least one of your classmates’

Claims Processing and Reimbursement Discussion Nursing Assignment Help

In your post, compare the characteristics and claims filing processes of private and public payers. What type of ethical issues could arise with personnel during the claims filing processes? Discussion offers you the opportunity to express your own thoughts, ask questions for clarification, and gain insight from your classmates’ responses

Use the HeartDesease_DataFile.xls file as training data set and create

 Use the HeartDesease_DataFile.xls file as training data set and create a decision tree, and a Naïve Bayes Classifier in R that will predict the following records (AKA test data) for Heart Disease. For the Decision Tree section of this assignment, show your tree in R based on the training data

Scenario Your donut shop has perfected a method for the

  Scenario Your donut shop has perfected a method for the perfect glazed icing by slowly mixing whole milk to confectioner’s sugar while exposed to low heat. Your mixing tank starts with 10 fluid ounces of milk and 10 ounces of sugar. You continue adding sugar at a rate of

A company’s strategic priorities must drive how capital allocations are

 A company’s strategic priorities must drive how capital allocations are made and the size of each unit’s operating budget. Using the NEC Danforth’s library resources search for recent (most recent five years) articles that discusses how a company has revised its pattern of resource allocation and divisional budgets to support

 Assessment Description Academic engagement through active participation in instructional activities related to the course objectives is paramount to you

 Assessment Description Academic engagement through active participation in instructional activities related to the course objectives is paramount to your success in this course and future courses.  Through interaction with your instructor and classmates, you will explore the course material and be provided with the best opportunity for objective and competency

your persuasive speech outline will look similar to your informative

your persuasive speech outline will look similar to your informative speech outline. But there’s an exception. You will include a section dedicated to the opposition.  For instance, there are people who believe differently regarding the topic you select. Your job is to address their concerns and offer a counter-argument. In

Hi, I need help writing my Concept Paper for my nursing integration. My Topic is Nursing Intervention for SKIN INTERIGITY( Pressure ulcer). The instructions are attached with this. please review the i Nursing Assignment Help

Hi, I need help writing my Concept Paper for my nursing integration. My Topic is Nursing Intervention for SKIN INTERIGITY( Pressure ulcer). The instructions are attached with this. please review the instruction and let me know if you will be able to help me out. Thank You!! Expert Solution Preview

Read Chapters 2 & 3  1.Discuss the differences between a leader an

Read Chapters 2 & 3  1.Discuss the differences between a leader and a manager. 2. Which is more important, working for an effective leader or an effective manager? Explain your answer. 3. Observe the nurse manager in a unit to which students have been assigned. What management style is displayed?

Critical EM Roles Countering Terrorism

 What is the most critical (or potentially most valuable) role that an Emergency Manager can perform in countering terrorism? Often, Emergency Managers find their activities centered in the Preparedness and / or Response phases of EM. In those phases, or in other settings, how can EM expertise be best applied

How should Facebook respond to the 2014 research situation? How

  How should Facebook respond to the 2014 research situation? How could an earlier response have helped the company avoid the 2018 controversies and keep the trust of its users? Should the company promise to never again conduct a survey of this sort? Should it go even further and explicitly