Questions
17.1 Lab Lesson 10 (Part 1 of 2) Part of lab lesson 10 There are two...

17.1 Lab Lesson 10 (Part 1 of 2)

Part of lab lesson 10

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

Bonus points for lab lesson 10

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 16 (Gaddis Chapter 7). These have to be completed by the due date for lab lesson 10. For example, if you complete 89% of the activities you will get 8 points (there is no rounding).

Lab lesson 10 part 1 is worth 50 points

For part 1 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 10 (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.

The filename for your source file must be lesson10part1.cpp.

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 program must make use of two parallel arrays. Each array is of type char or unsigned char. The size of each array is 30.
  • Your program must properly check for end of file.
  • Your program must properly open and close all files.
  • You are required to have your main function and two additional functions. One of the two additional functions will be a read function and the other will be a display function.

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

General overview

In part 1 you will be creating a quiz grading program. You will compare the student's answers with the correct answers, and determine if the student passed the quiz or not.

The program will make use of two parallel arrays.

Each array must be able to support up to 30 characters (so you have two arrays of char or unsigned char values, each one with 30 elements).

Your program will need to read in the student answer input file name from cin. It will also need to read in the correct answer file name from cin. You should use the >> operator to read from cin and not get or getline. Using get or getline will be more difficult and will require that you filter out white-space characters in your program.

The contents of the student input file should be read into one char array. The file will contain up to 30 characters, each character on a separate line of the file. The first line in the input file will contain the students answer to the first question, the second line will contain the student's answer to the 2nd question, and so on for up to 30 questions. The answers are A, B, C or D (all upper case).

The answer file will be read in as well, one answer per line for up to 30 answers. The first line of text is the answer for question 1, then second line is the answer for question 2, and so on.

You need to keep track of the number of student answers and the correct answers. If the number of student answers and correct answers is not the same you need to output an error message (see below).

As always, close the input files when you are done with them.

Your program needs to determine the number of questions that the student missed and then display the following:

  • A list of questions missed by the student, showing the question number (1 through up to 30), the correct answer, and the incorrect answer.
  • The total number of questions missed by the student
  • The percentage of the questions answered correctly.
  • If the percentage of questions answered correctly is 70% or more indicate that the student passed, otherwise state that the student failed the quiz.

You need to have at least the following three functions, including main.

Read function

One function needs to be passed a char or unsigned char array of size 30, it also needs to be passed an input file name. The return from the function should be an int value.

If the number of input values is > 30 return 30. Otherwise return the number of values read in. If the file does not exist return -1.

Work/Display function

The work/display function will be passed the two arrays, the number of student answers and correct answers read in, and should calculate and display the results from the program.

The function needs to do the following:

  • A list of questions missed by the student, showing the question number (1 through up to 30), the correct answer, and the incorrect answer.
  • The total number of questions missed by the student
  • The percentage of the questions answered correctly.
  • If the percentage of questions answered correctly is 70% or more indicate that the student passed, otherwise state that the student failed the quiz.

The main function

The main will prompt for the student answers file name and call the read function.

If the read function fails the program should output an error message and quit.

If the first read works the main should prompt for an read in the correct answers file name and call the read function a second time.

If the read fails an error message should be displayed and main should quit.

If the number of student answers is not the same as the number of correct answers an error message should be displayed and main should quit.

If the number of student answers and correct answers are the same but are both 0 display an error message and quit.

If your program gets this far call the work/display function.

As always you cannot use any global variables in your program.

See the sample runs for examples of the prompts, error messages, and results output.

See the sample runs for the output requirements.

Sample run 1 (valid data)

Contents of cin:

student.txt
answers.txt

Contents of student.txt:

A
B
C
D
A
B
C
D
A
B
C
D
A
B
C
D
A
B
C
D

Contents of answers.txt:

A
A
A
A
B
B
B
B
C
C
C
C
D
D
D
D
A
B
C
D

Here is the output to cout:

Enter student answers file name
Enter correct answer file name
Question 2 has incorrect answer 'B', the correct answer is 'A'
Question 3 has incorrect answer 'C', the correct answer is 'A'
Question 4 has incorrect answer 'D', the correct answer is 'A'
Question 5 has incorrect answer 'A', the correct answer is 'B'
Question 7 has incorrect answer 'C', the correct answer is 'B'
Question 8 has incorrect answer 'D', the correct answer is 'B'
Question 9 has incorrect answer 'A', the correct answer is 'C'
Question 10 has incorrect answer 'B', the correct answer is 'C'
Question 12 has incorrect answer 'D', the correct answer is 'C'
Question 13 has incorrect answer 'A', the correct answer is 'D'
Question 14 has incorrect answer 'B', the correct answer is 'D'
Question 15 has incorrect answer 'C', the correct answer is 'D'
12 questions were missed out of 20
The student grade is 40.0%.
The student failed

Sample run 2 (invalid student file)

Contents of cin:

invalidfile.txt
answers.txt

Here is the output to cout:

Enter student answers file name
File "invalidfile.txt" could not be opened

Sample run 3 (invalid answer file)

Contents of cin:

student.txt
invalidfile.txt

Here is the output to cout:

Enter student answers file name
Enter correct answer file name
File "invalidfile.txt" could not be opened

Sample run 4 (questions and answers are not the same)

Contents of cin:

student.txt
answer2.txt

Here is the output to cout:

Enter student answers file name
Enter correct answer file name
The student answers file has 20 entries and the correct answers file has 21 entries
Grading cannot be done if they are not the same

Note that the error message is on two lines. You must output two lines for the error messages.

Sample run 5 (the number of questions and answers is 0)

Contents of cin:

student.txt
answer2.txt

Here is the output to cout:

Enter student answers file name
Enter correct answer file name
The number of student answers and correct answers are both 0
No grade can be calculated

Note that the error message is on two lines. You must output two lines for the error messages.

Sample run 6 (all answers valid)

Assume the student input file and the answers file both have 15 values and the answers file has all correct answers. The output to cout would be:

Enter student answers file name
Enter correct answer file name
0 questions were missed out of 15
The student grade is 100.0%
The student passed

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 14 tests. Each test will have a new set of input data. You must match, exactly, the expected output.

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).

Error message "Could not find main function"

Now that we are using functions some of the tests are unit tests. In the unit tests the zyBooks environment will call one or more of your functions directly.

To do this it has to find your main function.

Right now zyBooks has a problem with this when your int main() statement has a comment on it.

For example:

If your main looks as follows:

int main() // main function

You will get an error message:

Could not find main function

You need to change your code to:

// main function
int main()

If you do not make this change you will continue to fail the unit tests.

In: Computer Science

The probability that a student graduating from West Texas A&M University has student loans to pay...

The probability that a student graduating from West Texas A&M University has student loans to pay off after graduation is 0.60. If two students are randomly selected from this university, what is the probability (rounded to the nearest two decimal places) that neither of them has student loans to pay off after graduation?

The following table gives the frequency distribution of the number of telephones owned by a sample of 50 households selected from a city.

Number of Telephones Owned   Frequency (f)
0   3
1   20
2   14
3   3
4   10
The relative frequency of the first class, rounded to two decimal places, is:

The temperatures (in degrees Fahrenheit) observed during selected seven days of summer in Los Angeles are:

78 99 68 91 105 75 85

The standard deviation, rounded to two decimal places, of these temperatures is:

The ages of all high school teachers in New York state have a bell-shaped distribution with a mean of 39 years and a standard deviation of 7 years. According to the empirical rule, the percentage of teachers in this state who are 32 to 46 years old is approximately:

The waiting times (in minutes) for 11 customers at a supermarket are:

14 9 15 4 4 7 9 11 14 2 6

The percentile rank for the customer who waited 11 minutes is 64%. Give a brief interpretation of this percentile rank.

In: Statistics and Probability

Revisit Bryden’s sock drawer from earlier in the test (4 Cool socks, 6 Hunk socks, 2...

Revisit Bryden’s sock drawer from earlier in the test (4 Cool socks, 6 Hunk socks, 2 Genius socks). If Mr. Smith draws out two socks, one at a time for Bryden to wear, what is the probability that they do not match?  

In: Statistics and Probability

Consider the following data for two variables, x and y. xi 140 110 130 150 175...

Consider the following data for two variables, x and y.

xi 140 110 130 150 175 160 125
yi 150 100 125 120 135 135 115

a. Compute the standardized residuals for these data.

Observation 1
Observation 2
Observation 3
Observation 4
Observation 5
Observation 6
Observation 7

In: Statistics and Probability

Accidental Death & Dismemberment Insurance covers accidents that results in death or loss of limbs due...

Accidental Death & Dismemberment Insurance covers accidents that results in death or loss of limbs due to accidents. Considering dismemberments only, let a discrete random variable X be the number of limbs lost from a policy holder in a given year.

Suppose that the probability distribution of X is x

0 p(x)=0.80

1 p(x)=0.13

2 p(x)=0.04

3 p(x)=0.02

4 p(x)=0.01

(a) Find the expected number of limbs lost for a randomly selected policy holder in a given year.

(b) suppose the insurance company pays $10,000 for loss of one limb, $20,000 for loss of two limbs, $50,000 for loss of three limbs, and $100,000 for loss of all limbs, how much should the annual premium be if the insurance company wants an average of $50 profit per policy holder? Hint: What is the expected insurance payment for an arbitrary policy holder?

In: Statistics and Probability

Problem 10-15 Island Airlines Inc. needs to replace a short-haul commuter plane on one of its...

Problem 10-15

Island Airlines Inc. needs to replace a short-haul commuter plane on one of its busier routes. Two aircraft are on the market that satisfy the general requirements of the route. One is more expensive than the other but has better fuel efficiency and load-bearing characteristics, which result in better long-term profitability. The useful life of both planes is expected to be about seven years, after which time both are assumed to have no value. Cash flow projections for the two aircraft follow.

Low Cost High Cost
Initial cost $753,400 $971,000
Cash inflows, years 1 through 7 153,000 159,600
  1. Calculate the payback period for each plane and select the best choice. Round your answers to one decimal place.
    Low Cost years
    High Cost years

  2. Calculate the IRR for each plane and select the best option. Use the fact that all the inflows can be represented by an annuity. Round your answers to one decimal place.
    Low Cost %
    High Cost %

    IRR also selects the   cost plane.
  3. Compare the results of parts (a) and (b). Both should select the same option, but does one method result in a clearer choice than the other based on the relative sizes of the two payback periods versus the relative sizes of the two IRRs?
    The input in the box below will not be graded, but may be reviewed and considered by your instructor.

  4. Calculate the NPV and PI of each project assuming a cost of capital of 8%. Use annuity methods. Do not round intermediate calculations. Round PVFA values in intermediate calculations to four decimal places. Round NPV to the nearest dollar, round PI to two decimal places.
    Low Cost High Cost
    NPV $   $  
    PI

    Which plane is selected by NPV?
      cost plane.
    By PI?
      cost plane.
  5. Calculate the NPV and PI of each project, assuming the following costs of capital: 2%, 4%, 6%, 8%, and 10%. Use annuity methods. Do not round intermediate calculations. Round PVFA values in intermediate calculations to four decimal places. Round NPV to the nearest dollar, round PI to two decimal places. Use a minus sign to indicate a negative NPV.
    Low Cost High Cost
    2% NPV $   $  
    PI
    4% NPV $   $  
    PI
    6% NPV $   $  
    PI
    8% NPV $   $  
    PI
    10% NPV $   $  
    PI

    Is the same plane selected by NPV and PI at every level of cost of capital? Investigate the relative attractiveness of the two planes under each method.

In: Finance

Paulson is in charge of a project at the local community center. The center needs to...

Paulson is in charge of a project at the local community center. The center needs to remodel one of the rooms in time for the start of a new program. Delays in the project mean that the center must rent other space at a nearby church at additional cost (and Paulson gets a roasting).
Time and cost data for your project are contained in Table below. Paulson’s interest is in minimizing the cost of the project to the community center.

TABLE
DATA FOR THE COMMUNITY CENTER PROJECT
Activity
Normal Time (days)
Normal Cost($)
Crash Time (days)
Crash Cost ($)
Immediate Predecessor(s)
START
0
0
0
0
-
A
10
50
8
150
START
B
4
40
2
200
START
C
7
70
6
160
B
D
2
20
1
50
A, C
E
3
30
3
30
A, C
F
8
80
5
290
B
G
5
50
4
180
D
H
6
60
3
180
E, F
FINISH
0
0
0
0
G, H

a. Using the normal times for each activity, what is the earliest date Paulson can complete the project?

b. Suppose the variable overhead costs are $50 per day for your project. Also, suppose that the center must pay $40 per day for a temporary room on day 15 or beyond. Find the minimum-cost project schedule (best chance that Paulson is not hauled by Church authorities). What is the minimum cost? (3+7 = 10 Marks)

In: Operations Management

Burnside Marketing Research conducted a study for Barker Foods on several formulations for a new dry...

Burnside Marketing Research conducted a study for Barker Foods on several formulations for a new dry cereal. Three attributes were found to be most influential in determining which cereal had the best taste: ratio of wheat to corn in the cereal flake, type of sweetener (sugar, honey, or artificial), and the presence or absence of flavor bits. Seven children participated in taste tests and provided the following part-worths for the attributes (see section 13.4 ):

Wheat/Corn Sweetener Flavor Bits
Child Low High Sugar Honey Artificial Present Absent
1 15 35 30 40 25 15 9
2 30 20 40 35 35 8 11
3 40 25 20 40 10 7 14
4 35 30 25 20 30 15 18
5 25 40 40 20 35 18 14
6 20 25 20 35 30 16 9
7 30 15 40 25 40 20 11
(a) Suppose the overall utility (sum of part-worths) of the current favorite cereal is 75 for each child. What product design will maximize the number of children in the sample who prefer the new dry cereal. Note that a child will prefer the new dry cereal only if its overall utility is at least 1 part-worth larger then the utility of their current preferred cereal.
Product Design:
Wheat/Corn - Select your answer -LowHighItem 1
Sweetener - Select your answer -SugarHoneyArtificialItem 2
Flavor Bits - Select your answer -PresentAbsentItem 3

Share of Choice
(b) Assume that the overall utility of the current favorite cereal for children 1 to 4 is 70, and the overall utility of the current favorite cereal for children 5 to 7 is 80. What product design will maximize the share of choice for the seven children in the sample?
Product Design:
Wheat/Corn - Select your answer -LowHighItem 5
Sweetener - Select your answer -SugarHoneyArtificialItem 6
Flavor Bits - Select your answer -PresentAbsentItem 7

Share of Choice

In: Accounting

Overview In this assignment you are required to implement binary code comparator using Xilinx that it...

Overview

In this assignment you are required to implement binary code comparator using Xilinx that it is compatible with the MXK Seven Segment Displays. You will draw your digital logic circuit using Xilinx and then simulate it to verify the functionality of your design.

Software Requirements

? Xilinx ISE 10.1 or higher

Specifications

Binary Code Comparator

The binary code comparator is to be implemented and made compatible with the seven 7-segment displays of the board. Represent the first five digits of your student number into binary. If a given decimal digit is odd, then the binary equivalent will be 1, otherwise it will be 0. For example, the student (decimal) number 99805234 will produce 11001. The user is to enter a 5-bit binary sequence one bit at a time. The five bits will be displayed on five of the seven segment displays. If the five entered bits equal to the stored binary code, then ‘E’ is to be displayed on the sixths seven- segment display. However, if the five entered bits do not equal the binary code, then ‘n’ is to bedisplayed. Note that you do not have to display bits as they are received in accumulating manner (as shown in the figure below), rather, you can display all five bits and the comparator outcome (‘E’ or ‘n’) when the fifth bit is received. All six seven-segment displays are to stay on for five seconds, then they will be erased. Once the displays are erased, the circuit will be ready for receiving a new set of five input bits.

- Reset: if pressed, the circuit will return to the initial state and all seven segment displays are to be erased.

- Input (could be received from a dipswitch in your MXK): to specify the binary input (1 or 0).

- Trigger (could be received from a pushbutton in your MXK): to allow the input to be received by the circuit.

- Clock: to alternate between the 7-segment displays (expected to be around 1000 Hz).

There are two sets of outputs, which are:

- d1, d2, ..., d7 (anodes to switch between the seven 7-segment displays)

In: Electrical Engineering

Apple computer is a highly vertically integrated company. The design of products like the iPad is...

Apple computer is a highly vertically integrated company. The design of products like the iPad is done by a division of Apple, while another division runs retail outlets to sell them directly to consumers. Use concepts from class the advantages and disadvantages of Apple being vertically integrated in this fashion.

In: Economics