1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Leya [2.2K]
3 years ago
13

The Universal Product Code (UPC) on most grocery items contains a zero that is printedto the left of the bar code and 10 digits

that are printed in two groups of five each belowthe code. The first five digits represent a manufacturer and the second five digits representa specific product. To the right of the bar code, a check digit is printed. Write aprogram that allows the user to enter the five-digit manufacturer code, the five-digitproduct code, and the check digit. Display the result of a Boolean comparison (0 or 1)that shows whether the check digit is correct according to the following algorithm.(Hint: Use a combination of modulus, multiplication, and subtraction to separate thedigits in the entered code.)a. Sum the second and fourth numbers in the manufacturer code.b. Sum the first, third, and fifth numbers in the product code.c. Sum the results of step a and step b, and multiply the total by 3.d. Sum the first, third, and fifth numbers in the manufacturer code.e. Sum the second and fourth digits in the product code.f. Sum the results of steps d and e and add to the result from step c.g. Take the remainder when the result of step f is divided by 10.h. Subtract the result of step g from 10. Compare this result to the check digit entered by theuser. If the result and check digit are equal (if the Boolean value of the comparison is 1),then the UPC is a valid one.Your solution should prompt the user for the UPC numbers.Your solution should report to the user if the UPC code in valid or not.The user should be able to enter multiple tests.The program must be programmed in a simple c++ without the use of arraysThe Algorithm:In the UPC-A system, the check digit is calculated as follows:1. Add the digits in the odd-numbered positions (first, third, fifth, etc.) together and multiply by three.2. Add the digits in the even-numbered positions (second, fourth, sixth, etc.) to the result.3. Find the result modulo 10 (i.e. the remainder when divided by 10.. 10 goes into 58 5 times with 8 leftover).4. If the result is not zero, subtract the result from ten.For example, in a UPC-A barcode "05150024163x" where x is the unknown check digit, x can be calculated byadding the odd-numbered digits (0 + 1 + 0 + 0 + 2 + 1 + 3 = 7),multiplying by three (7 × 3 = 21),adding the even-numbered digits (21 + (5 + 5 + 0 + 4 + 6) = 41),calculating modulo ten (41 mod 10 = 1),subtracting from ten (10 − 1 = 9).The check digit is thus 9.Do you have a number to test? (y or n): y Enter the very first number of the UPC. 0 Enter the very last number of the UPC. 9 Enter your Manufacturer number (the first set of 5 digits) 51500 Enter your Product number (the second set of 5 digits) 24163 UPC code 051500241639 is valid. Do you have a number to test? (y or n): y Enter the very first number of the UPC. 8 Enter the very last number of the UPC. 9 Enter your Manufacturer number (the first set of 5 digits) 76045 Enter your Product number (the second set of 5 digits) 00414 UPC code 876045004149 is valid. Do you have a number to test? (y or n) y Enter the very first number of the UPC. 8 Enter the very last number of the UPC. 9 Enter your Manufacturer number (the first set of 5 digits) 76055 Enter your Product number (the second set of 5 digits) 00414 Invalid UPC code. Do you have a number to test? Cy or n): n Type any key and then hit to quit the program.
Engineering
1 answer:
AleksandrR [38]3 years ago
5 0

Answer:

Check the explanation

Explanation:

#include <iostream>

#include <string>

using namespace std;

int main()

{

int last;

string first, manuCode, prodCode;

string ans = "y";

bool done = false;

while(!done)

{

cout << "Do you have a number to test? y or n : ";

cin >> ans;

if(ans != "y" && ans != "Y")

done = true;

else

{

cout << "Enter the first number of the UPC: ";

cin >> first;

cout << "Ebter the last number of the UPC: ";

cin >> last;

cout << "Etner the Manufacterer number (first set of 5 digits): ";

cin >> manuCode;

cout << "Enter the Product number (second set of 5 digits): ";

cin >>prodCode;

 

int sodd = 0, seven = 0;

string s = first + manuCode + prodCode;

int rem, check;

 

for(int i = 1; i <= s.length(); i++)

{

if(i % 2 == 1) // odd

sodd += s[i-1] - '0'; //subtract '0' to get numeric value from ascii character

else

seven += s[i-1] - '0';

}

 

rem = (3 * sodd + seven) % 10;

check = 10 - rem;

 

s += to_string(last);

 

if(check == last)

cout << "UPC code " << s << " is valid." << endl<< endl;

else

cout << "Invalid UPC code" << endl << endl;

}

}

}

output

-=====

Do you have a number to test? y or n :y

Enter the first number of the UPC: 0

Ebter the last number of the UPC: 9

Etner the Manufacterer number (first set of 5 digits): 51500

Enter the Product number (second set of 5 digits): 24163

UPC code 051500241639 is valid.

Do you have a number to test? y or n : y

Enter the first number of the UPC: 8

Ebter the last number of the UPC: 9

Etner the Manufacterer number (first set of 5 digits): 76045

Enter the Product number (second set of 5 digits): 00414

UPC code 876045004149 is valid.

Do you have a number to test? y or n : y

Enter the first number of the UPC: 8

Ebter the last number of the UPC: 9

Etner the Manufacterer number (first set of 5 digits): 76055

Enter the Product number (second set of 5 digits): 00414

Invalid UPC code

Do you have a number to test? y or n : n

You might be interested in
Which Finance jobs can someone pursue with only a high school diploma? Check all that apply.
Zolol [24]

Answer:

Teller, Loan Officer, and Tax Preparer

Explanation:

3 0
4 years ago
Read 2 more answers
At an impaired driver checkpoint, the time required to conduct the impairment test varies (according to an exponential distribut
professor190 [17]

Answer:

Option (d) 2 min/veh

Explanation:

Data provided in the question:

Average time required = 60 seconds

Therefore,

The maximum capacity that can be accommodated on the system, μ = 60 veh/hr

Average Arrival rate, λ = 30 vehicles per hour

Now,

The average time spent by the vehicle is given as

⇒ \frac{1}{\mu(1-\frac{\lambda}{\mu})}

thus,

on substituting the respective values, we get

Average time spent by the vehicle = \frac{1}{60(1-\frac{30}{60})}

or

Average time spent by the vehicle = \frac{1}{60(1-0.5)}

or

Average time spent by the vehicle = \frac{1}{60(0.5)}

or

Average time spent by the vehicle = \frac{1}{30} hr/veh

or

Average time spent by the vehicle = \frac{1}{30}\times60 min/veh

[ 1 hour = 60 minutes]

thus,

Average time spent by the vehicle = 2 min/veh

Hence,

Option (d) 2 min/veh

7 0
4 years ago
Vector A extends from the origin to a point having polar coordinates (7, 70ᵒ ) and vector B extends from the origin to a point h
yaroslaw [1]

Answer:

13.95

Explanation:

Given :

Vector A polar coordinates = ( 7, 70° )

Vector B polar coordinates = ( 4, 130° )

To find A . B we  will

A ( r , ∅ ) = ( 7, 70 )

A = rcos∅ + rsin∅

therefore ; A  = 2.394i + 6.57j

B ( r , ∅ ) = ( 4, 130° )

B = rcos∅ + rsin∅

therefore ;  B = -2.57i + 3.06j

Hence ; A .B

( 2.394 i + 6.57j ) . ( -2.57 + 3.06j ) = 13.95

8 0
3 years ago
An energy system can be approximated to simply show the interactions with its environment including cold air in and warm air out
Elenna [48]

Answer: The energy system related to your question is missing attached below is the energy system.

answer:

a) Work done = Net heat transfer

  Q1 - Q2 + Q + W = 0

b)  rate of work input ( W ) = 6.88 kW

Explanation:

Assuming CPair = 1.005 KJ/Kg/K

<u>Write the First law balance around the system and rate of work input to the system</u>

First law balance ( thermodynamics ) :

Work done = Net heat transfer

Q1 - Q2 + Q + W = 0 ---- ( 1 )

rate of work input into the system

W = Q2 - Q1 - Q -------- ( 2 )

where : Q2 = mCp T  = 1.65 * 1.005 * 293 = 485.86 Kw

             Q2 = mCp T = 1.65 * 1.005 * 308 = 510.74 Kw

              Q = 18 Kw

Insert values into equation 2 above

W = 6.88 Kw

5 0
3 years ago
The atmosphere within a room is at 70 °F dry-bulb temperature, 50 percent degree of saturation, and 14.696 psia pressure. The in
Gre4nikov [31]

Answer:

Given that the temperature of the window is below the dew point it will condensate.

Explanation:

A psychrometric chart (like the one attached) will give you the information needed. This chart is for 14.696 psia.

On the bottom horizontal axes you have the dry-bulb temperature, in this case 70°F, going up from this point you can reach the 50% relative humidity curve (red point on chart), going horizontally from this point to the 100% relative humidity you get the dew point temperature (the point at which moisture will condensate) (blue point on chart). In this case the dew point is 50°C. Given that the temperature of the window is below the dew point it will condensate.

6 0
3 years ago
Other questions:
  • Drag each tile to the correct box.
    15·1 answer
  • What are the mechanical properties of a geotextile that are of most importance when using it as a separator in an unpaved road s
    12·1 answer
  • Unitate de masura in SI pt F​
    11·1 answer
  • Give three examples of how engineering has made human life better in your opinion.
    13·1 answer
  • Make a sketch of a simple mechanically expanded brake and indicate the forces ​ ​ acting on the leading shoe when the brake is a
    10·1 answer
  • 4 points
    13·1 answer
  • It is ___ for motorcyclists to ride more than two abreast in a lane.
    7·1 answer
  • Hello how are you all bye everyone have a great day ahead​
    8·2 answers
  • Planetary gears require the armature to be offset via a gear housing that holds the starter drive.
    12·2 answers
  • 8th grade safety test
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!