Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a logic error in my C++ code, my task is to code five function where each will be responsible of checking its own

I have a logic error in my C++ code, my task is to code five function where each will be responsible of checking its own parameters.

five functions:

-bool isValidQC(string results) This function returns true if its parameter is a well-formed test result string described above or false otherwise.

-int passQC(string results) If the parameter is a well-formed test result string, this function should return the total number of pass test results from all the batches reported in the string. If the parameter is not valid, return -1 .

-int defectQC(string results) If the parameter is a well-formed test result string, this function should return the total number of defect test results from all the batches reported in the string. If the parameter is not valid, return -1.

-int totalQC(string results) If the parameter is a well-formed test result string, this function should return the total number of tests being reported from all the batches in the string. If the parameter is not a valid, return -1. -int batches(string results) If the parameter is a well-formed QC test result string, this function should return the total number of batches reported in the string. If the parameter is not a valid, return -1.

Suppose that an automated manufacturing tracker records production QC test results in batches in a results string. For example, Q2p1d1 would indicate that a single batch of two QC tests was performed with the results of one pass and one defect. Note that the character Q is used to start a batch of QC test results. The character p is to identify the number of tests that passed the QC test, and the character d indicates the number of defects. More than one batch of QC test results can be reported in a single results string. For example, Q2d1p1Q5p3d2 would indicate two batches of QC test results, one with two test results and one with five test results, with a combined total of four passes and three defects. Precisely, to be a valid QC test results string, - a batch of results must begin with the character Q (case sensitive) - a batch of results must report both pass and defect test results with p and d in either order - no leading zeros are allowed in any numeric value being reported - the total number of QC tests in a batch must equal the number of pass and defect test results. - the total number of QC tests in a batch must be greater than zero (0). - a single result string may include multiple batches of results

when I test 1 batch for example Q5d2p3

all the out puts are correct, out put example:

Enter a possible teststring: Q5d2p3

isValidQC returns true

pass test result(s) returns 3

defectQC(s) returns 2

totalQC(s) returns 5

batches(s) returns 1

But when I test with 2 or more batches:Q5d2p3Q5d2p3

the output is incorrect:

Enter a possible teststring: Q5d2p3Q5d2p3

isValidQC returns true

pass test result(s) returns 3

defectQC(s) returns 6

totalQC(s) returns 15

batches(s) returns 2

CAN SOMEONE FIX THIS ASAP?

HERE'S MY CODE:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions