Retail products are identified by their Universal Product Codes (UPCs). The most commonform of a UPC has 12 decimal digits: The first digit identifies the product category, the nextfive digits identify the manufacturer, the following five identify the particular product, andthe last digit is acheck digit. The check digit is determined in the following way:
• Beginning with the first digit multiply every second digit by 3.
• Sum all the multiplied digits and the rest of the digits except the last digit.
• If the (10 - sum % 10) is equal to the last digit, then the product code is valid.
• Otherwise it is not a valid UPC.The expression is:sum= 3.x1+x2+ 3.x3+x4+ 3.x5+x6+ 3.x7+x8+ 3.x9+x10+ 3.x11where the x’s are the first 11 digits of the code.
If you choose to add the last digit also in the second step and if the sum is a multiple of 10,then the UPC is valid. Either way, you still need to perform the modular division to checkwhether the given number is a valid code.In this problem, you need to use either a string or long long integer type for the product codebecause it is 12 digits long. If you use string, you can convert one character substring of thestring in to a single digit integer from left to right using the function stoi(str.substr(i,1)).This way you do not need to get last digit of the number and then divide the number by 10.
in c++
problem 3
Translate the following pseudocode for randomly permuting the characters in a string into a C++ program. Read a word. repeat word.length() times Pick a random position i in the word, but not the last position. Pick a random position j > i in the word. swap the letters at positions j and i. Print the word. Please work on this problem after we learn to generate random numbers in the class which is on Wednesday the latest. These problems only deal with simple loop while, for and do loops. You will get a second set of problems next week on nested loops.

Answers

Answer 1

Answer:

#include <iostream>

#include <cmath>

using namespace std;

int main(){

   string upc;

   char last;

   cout<< "Enter UPC number: ";

   cin >> upc;

   if (upc.size() == 12){

       last = upc[-1];

   } else{

       return 0;

   }

   cout<< last;

   char myArr[upc.length()];

   for (int i = 0 ; i < upc.substr(0,11).length(); ++i){

       if (upc[i]%2 != 0){

           myArr[i] = upc[i] * 3;

       }

       else{

           myArr[i] = upc[i];

       }

   }

   int sum = 0;

   for (int x = 0; x < sizeof(myArr); ++x){

       sum += (int)myArr[x] - '0';

   }

   if (sum% 10 == last){

       cout<<"UPC number is valid";

   }

   else{

       cout<<"Invalid UPC number.";

   }

}

Explanation:

The UPC number in the c++ source code input must be 12 digits long for the rest of the code to execute.  The code checks the validity of the number by comparing the reminder of the sum division with the last digit in the UPC number.


Related Questions

One of the systems analysts on the project team thought that he did a good job of designing the company’s tech support webpage, but his supervisor isn’t so sure. His supervisor is concerned that the design is very similar to a page used by the company’s major competitor, and she asked him whether he had used any HTML code from that site in his design. Although the analyst didn’t copy any of the code, he did examine it in his web browser to see how they handled some design issues. The supervisor asked the analyst to investigate webpage copyright issues and report back to her. In his research, the analyst learned that outright copying would be a copyright violation, but merely viewing other sites to get design ideas would be permissible. What is not so clear is the gray area in the middle. The analyst asked you, as a friend, for your opinion on this question: Even if no actual copying is involved, are there ethical constraints on how far you should go in using the creative work of others? How would you answer?

Answers

Explanation:

Although the system analyst only viewed the HTML code as a major competitor not outrightly copying their code, however, since there are relatively few legal frameworks on this matter, it important to note some ethical issues or constraints that may arise:

Copying the design pattern of the competitors' webpage may result in legal fillings by the competitors which may claim the other company stole its intellectual designs without permission.Such actions may result in other competitors carrying out the same strategy on the company.

Which of the following are reasons why it is important to write readable code?
Choose all that apply.

Readable code is easier to maintain.

Readable code is easier to modify.

Readable code is fun to write.

Writing readable code saves time in the long run.

Answers

Answer:

Readable code is easier to maintain.

Writing readable code saves time in the long run.

Readable code is easier to modify.

Readable code is fun to write.

Explanation:

Readability of a code means that how easy it is to read the code even if any person other than programmer reads the code. Different techniques like line breaks and indentation are used to make the code readable. the program follows an indentation pattern so it is easy and fun to write.

Hence,

it can be concluded that the true statements are:

Readable code is easier to maintain.

Writing readable code saves time in the long run.

Readable code is easier to modify.

Readable code is fun to write.

Answer:

for short answer it is a,b and D

Explanation:

What is the purpose of the Microsoft® PowerPoint® application? to design publications such as newsletters and brochures to create documents such as business letters and resumés to develop presentations for business meetings to design a company employee database

Answers

Answer:

The first one

Explanation:

The main purpose of MS PowerPoint is to enable the user to create dynamic, informational slides through the use of text, graphics, and animation.

The purpose of PowerPoint is to act as a visual aid as a presenter goes along presenting their option, ideas, sales pitch, etc. Make sure to not make your slides too wordy and concentrate on adding only basic bullet points.

Answer:

to develop presentations for business meetings

Explanation:

Any of the other options will be used in Word, Excel and Publisher.

But Power Point is mainly for presentations and not newsletters and other.

Why would a programmer use a flow chart? (Edge2020 Coding Critical Thinking Questions)

Answers

Answer:

As a visual representation of data flow, flowcharts are useful in writing a program or algorithm and explaining it to others or collaborating with them on it. You can use a flowchart to spell out the logic behind a program before ever starting to code the automated process.

Explanation:

Answer: I answered yo can give the other guy brainliest yw

Explanation:

When was the information last updated

Answers

Wait what? I don’t understand

What is the main advantage of using a WYSIWYG("what you see is what you get")editor when constructing a website
A.only one programming language is required
B.websites may have more professional construction
C.knowledge of HTML is not required
D.Website templates are not necessary

Answers

Answer:

c

12121212121212121212121212121221212121212121212

What are some areas in Computer Science that make use of multivariate statistical testing or MCM methods? Explain why they are used.

Answers

Explanation:

Computational modeling is one of the areas of Computer Science that uses mathematical systems to perform multivariate statistical tests to solve highly complex problems in multidisciplinary areas, such as medicine, engineering, science, etc.

An example of the use of multivariate statistical tests is social development research in social science, which uses multiple variables to find more hypotheses and greater coverage between variables.

Multivariate statistical tests have the benefit of making research more effective and providing a more systematic and real view of the study.

In the program below, which two variables have the same scope?

def rhyme(word):
leftCharacter = word[0]
if leftCharacter != 'd':
return 'd' + word[1:]
else:
return 'f' + word[1:]
def poem():
print("Enter Q to quit.")
userWord = input("Enter a word: ")
while userWord != 'Q' and userWord != 'q':
rhymeWord = rhyme(userWord)
print(rhymeWord)
userWord = input("Enter a word: ")
# the main part of your program that calls the function
poem()
userWord and ____
Fill in the blank Answer options: poem, word, rhymeWord

Answers

Answer:

rhymeWord

Explanation:

correct answer edge 2020

# the main part of your program that calls the function poem() userWord and rhymeWord. Hence, option C is correct.

What is rhymeWord?

Rhyming words all have the same last consonant. Simply put, it is the repetition of similar sounds. When two words have similar sounds, usually those that follow the final stressed syllable of each word, the words are said to rhyme. Cat-hat, rotten-forgotten, and heard-bird are some examples of words that rhyme; they all have similar sounds after the final stressed syllable.

If the last sounds of two or more words are the same or similar, then the words will rhyme. Some words that rhyme are goat, boat, moat, float, and coat. To determine whether two words rhyme, use your ears to listen while you speak the words. If two words have a similar or matching sound, they rhyme.

Thus, option C is correct.

For more information about rhymeWord, click here:

https://brainly.com/question/2398244

#SPJ2

how microsoft excel helps students?

Answers

Answer:

FASLE

Explanation:

Clyde Clerk is reviewing his firm’s expense reimbursement policies with the new salesperson, Trav Farr. "Our reimbursement policies depend on the situation. You see, first we determine if it is a local trip. If it is, we only pay mileage of 18.5 cents a mile. If the trip was a one-day trip, we pay mileage and then check the times of departure and return. To be reimbursed for breakfast, you must leave by 7:00 a.m., lunch by 11:00 a.m., and have dinner by 5:00 p.m. To receive reimbursement for breakfast, you must return later than 10:00 a.m., lunch later than 2:00 p.m., and have dinner by 7:00 p.m. On a trip lasting more than one day, we allow hotel, taxi, and airfare, as well as meal allowances. The same times apply for meal expenses." Write structured English for Clyde’s narrative of the reimbursement policies. Draw a decision tree.

Answers

Answer:

The answer is described in the image.

Explanation:

The firm is responsible for all expenses made by it's employees, so for a local trip, the cost of gas relative to the mileage covered during the journey is paid for ( 18 cents per mileage).

If it is not a local trip, then it is a one-day trip, so the firm pays for the mileage and the cost of the meals not taken in the company, which depends on the departure and return/arrival time. If the departure and return time is 7am to 10am, the employee is paid for breakfast, if the departure and return is 11am to 2pm then the employee is paid for lunch, and for dinner, 5pm to 7pm.

Define a function pyramid_volume with parameters base_length, base_width, and pyramid_height, that returns the volume of a pyramid with a rectangular base.

Answers

Answer:

Define a function pyramid_volume with parameters base_length, base_width, and pyramid_height, that returns the volume of a pyramid with a rectangular base.

Explanation:

thats all you said

In python 3.8:

def pyramid_volume(base_length, base_width, pyramid_height):

   return round((base_length*base_width*pyramid_height)/3,2)

print(pyramid_volume(1,1,2))

I used the round function to round the volume to 2 decimal places. You can change this if you need more or less precision. I hope this helps!

How can we tell the computer what to put on the web page, and how to organize it?​

Answers

Answer:

[tex]\boxed {\boxed {\sf Code}}[/tex]

Explanation:

Humans communicate with computers through code.

For web pages, HTML (HyperText Markup Language) is used.

A person writes the code to tell a computer what to display and how to structure the displayed information. You can create webpages with any information, add pictures, links, headings, paragraphs, change fonts, and more, all through the use of code.

ASAP PLZ!!!. Which command group is used to apply effects and modify color schemes of SmartArt graphics?

Reset Graphics

SmartArt Styles

Graphic Layouts

Create Graphics

NVM!! The answer is B. SmartArt Styles

Answers

Answer:

I think I am wrong but I assume it is C. Graphic Layout Sorry if I am wrong but if I am not please reward me brainlist.

The answer is B. Smart Art styles because your adding a styles to SmartArt

We wish to produce a graphic that is pleasing and easily readable. Suppose we
make the background color pink. What color text font should we use to make
the text most readable? Justify your answer.Assume that the color Pink is obtained by mixing equal amounts of Red and White. Use the RGB color model and assume that the amount of each primary color in the model is described in the interval [0 255]. Describe the color of the text font you would choose using these conventions.

Answers

Answer:

light color

Explanation:

When we will mix equal amounts or equal quantities of the color red and the color white, we will get the color reddish pink. It is popularly called as the SOFT RED and the color code of this color is RGB (255, 128, 128).

Since, red color + white color = 0.5 RGB(255, 0, 0) + 0.5RGB(255, 255, 255)

                                                 = RGB (255, 128, 128)

According to me, the color white will best suit as the text color that can be used for a background having RGB(255, 128, 128). Because the color looks more red and not that pink, so it wise to use a light tone color for the natural reading purpose. Hence, it will not give strain to the eyes.

Which statement is true? A. Pseudocode uses shapes such as rectangles and diamonds to plan a program. B. You only use comments for pseudo code. C. A flowchart uses comments that can be kept as a permanent part of a program. D. A comment line begins with # Please hurry also you can only choose one answer so idk which one thank you

Answers

Answer:

D) A comment line begins with #

Explanation:

Comments are used in programming to explain what a line or block of code is doing.

It helps the programmer easily remember what their code was about when they come back to it having left it for a while.

Also comments help other programmers understand code written by one programmer.

A comment or an in-line comment usually begins with #. That way the computer skips it and doesn't regard it as a line of code.

Answer: D. A comment line begins with #.

Explanation:

In the text, it stated, "The easiest way to add a comment is to start the line with the pound sign (#)."

(Comments are notes that allow you to write anything without affecting the code itself. Comments can be utilized to indicate when and how you later changed a program, and provide a description of the changes.)

I hope this helped!

Good luck <3

Assume a branch instruction bne $t1, $t2, Label is located in 0x00001840 in the instruction memory. The 16-bits branch address is 0x000C, If the branch is taken, what will be the new Program Counter (PC) value?

a. 0x00001844
b. 0x00001850
c. 0x00001870
d. 0x00001874

Answers

Answer:

a. 0x00001844

Explanation:

When the branch is takes the new program counter value is increased by 1. The value of existing memory is labelled with number sets and then next instruction is accepted in sequence. The new value is the increase in the current labelled value.

Consider a distributed denial of service (DDOS) attack, Assume the attacker has compromised a number of broadband connected computers to use as zombie systems. If the ISP provides a maximum uplink data rate of 512 Kbps in ADSL, what is the maximum number of 512-byte ICMP echo request (ping) packets a single zombie computer can send per second? How many such zombie systems would the attacker need to flood a target server in an organization that has
a. A Fast Ethernet.
b. A Gigabit Ethernet.

Answers

Answer:

A ) 200 Zombie systems

B ) 200 Zombie systems

Explanation:

maximum uplink data rate : 512 kbps = 512 * 1000 * 8  = 4096000 bits/sec

Determine the number of 512 byte  ICMP echo packets = 512 * 8 = 4096 bits

hence the maximum number of 512-byte ICMP echo request (ping) packets a single zombie computer can send per second = 400 packets/sec

i.e. for 512kbps = 400 packets/sec

Determine the number of Zombie systems that the attacker will need to flood a target server

A) For a fast ethernet

A fast ethernet = 100 mbps

The number of Zombie systems needed = 1 zombie system * 200

and 1 zombie system = 512 kbps

therefore for a Fast ethernet the number of zombies systems needed = 200

B) For A Gigabit Ethernet

same as a fast ethernet system i.e. = 200

Assume that d is a double variable. Write an if statement that assigns d to the int variable i if the value in d is not larger than the maximum value for an int.

Answers

Answer:

That's because the value has reached the size limit of the int data type. ... you should use long rather than int , because long can store much larger numbers than int . If ... In other words, a float or double variable can't accurately represent 0.1 . ... If you're using Java to measure the size of your house, you'd need an electron ...

Explanation:

When you pass a double variable to a method, the method receives ______.a) a copy of the memory addressb) the reference of the variablec) the length of the variabled) a copy of the variablee) the binary memory address

Answers

Answer:

The answer is "Option d".

Explanation:

In this question the choice d, that is "a copy of the variable" is correct because the method takes a reference value or a copy of the variable in its parameter, the example of this question can be defined as follows:

void me2(double x)//defining a method me2 with a double parameter

{

//method body

 }

double x = 35.655;//defining a double variable x

me2(x);//calling a method with passing the copy of th e variable

A user creates a GPO. What do you need to do for that user to manage his or her GPO that he or she created?

Answers

Answer: Nothing should be done.

Explanation:

Group Policy helps in the provision of a centralized management of operating systems, and applications. It should be noted that a group policy object (GPO) is simply referred to as the configurations involving the group policy.

Nothing should be done to manage the GPO created. When the permission to create a GPO has been given to someone, it means that they can also manage the GPO therefore, nothing needs to be done anymore.

What feature allows you to access previous copies of a document on OneDrive?

File storage
Recover file
Stored work
Version history

Answers

Version history feature

OneDrive's Version history feature allows you to view older versions of an Office Online document. If you find a version you want, you can then restore it, moving it to the top of the list as the latest version of the file.

Answer:

Version history

Explanation:

PLEASE HELPP
Why do you think it is important to write your high school plan in middle school? Explain your answer in 3-4 well written sentences.

Answers

Answer:

Es muy importante que escriba su plan para la escuela secundaria antes de llegar a la escuela secundaria. Te da algo a lo que admirar cuando llegas a la escuela secundaria. Cuando lo complete, sabrá que hizo algo bien. Entonces puede establecer sus metas cada vez más altas, dándole la oportunidad de una buena vida.

how to create diagram that demonstrates the step
by step procedures in performing a mail merge.

Answers

Answer:

hope it helps

1-Creating a Main Document and the Template.

2-Creating a Data Source.

3-Defining the Merge Fields in the main document.

4-Merging the Data with the main document.

5-Saving/Exporting

Question #2 Dropdown What are the missing words in the program? divide(numA, numB): numA / numb​

Answers

Answer:

def

return

Explanation:

I hope this helps!

If process P0 is switched to process P1, state for P0 will be saved into ____, and state from ___ will be reloaded.

Answers

Answer:

1. PCB0

2. PCB1

Explanation:

Given that PCB is often referred to as Process Control Block, is a form of data structure that is applicable and utilized by the computer operating systems to store all the information concerning a process.

This process is carried out in a way that when Process P0 is initialized, the operating system established a related process that takes the computer processing unit from Process P0 and allocates it to Process P1, the Operating System, in turn, will save P0's PCB, and then reload P1's PCB.

Hence, If process P0 is switched to process P1, the state for P0 will be saved into "PCB0" and the state from "PCB1" will be reloaded.

I have no idea, any help is appreciated.

Answers

Answer:

A

Explanation:

How do I explain it.... well the analogy shows the circle in the middle of the parallelogram, then the next shows the circle bigger than the parallelogram and the parallelogram with lines in it.

So you do the same to the triangle with a square and there you go!

Answer:

A - the first one is correct.

Explanation:

Hope this Helps!

:D

A ____ is a a set of presentation rules that control how text should look. It is applied to an XML file to change the collection of text with schema tags into a presentable document that shows data in a way that is pleasant and easily understood.

Answers

Answer: language

Explanation:

Find the minimum, maximum, and average grade of final exams in sections taught by Todd Smythe.

Answers

Answer:

A sample of the statement is written below

SELECT MIN(GRADE), MAX(GRADE), AVG(GRAD), FROM TABLE 2 WHERE TEACHER = "TODD SMYTHE"

Explanation:

To find the Minimum, maximum and average grade of final exams in the sections taught by Todd Smythe. we will write a statement

Using the select to get the required data using the functions ; MIN , MAX , AVG and the WHERE clause for the condition

A sample of the statement is written below

SELECT MIN(GRADE), MAX(GRADE), AVG(GRAD), FROM TABLE 2 WHERE TEACHER = "TODD SMYTHE"

Using the programming language of your choice, implement the Binary Search algorithm for a target value = 9 on the Array A: [9, 11, 70, 25, 20, 0, 36, 24]. What is the primary condition to implement a Binary Search Algorithm? Explain the growth rate of the algorithm

Answers

Answer:

myArray  = [9, 11, 70, 25, 20, 0, 36, 24]

myvalue = 20

def binary_search(mylist, value):

   sorted(mylist)  

   mid = mylist[round(len(mylist) / 2)]

   if value == mid:

       return mylist.index(mid)

   elif value < mid:

       for index, s_one in enumerate(mylist[ : (mylist.index(mid))]):

           if s_one == value:

               return index

   elif value < mid:

       for index, s_two in enumerate(mylist[(mylist.index(mid)) : ]):

           if s_two == value:

               return index

   else:

       return "searched value not in list/array"

result = binary_search( myArray, myvalue)

print(f"Index of the searched value {myvalue} is: {result}")

Explanation:

The programming language used above is python. It is used to implement a binary search in a list and finally returns the index of the searched value.

What is the primary purpose of a slideshow presentation

Answers

Answer:

to help us to complete all of useless project given by school

Answer:

support the presenter's ideas

Explanation:

Other Questions
3. A team of programmers is trying to determine the efficiency of a piece of code. They run the code with inputs of different sizes and also record the number of iterations through the core block of code. The data is recorded in the table below. Given the angle measures of a triangle are 3x + 6 degrees, 4x + 2 degrees and 10x + 2 degrees, determine the 3 angles in this triangle? How would the results be different if the product you were selling were tomatoes or another type of food? How would the results be different if your product were a car or something very expensive to maintain? If you wanted to increase your revenue from sales, would you increase your price or lower it? Looking at the response vehicles (pictured above), explain two options you have in order to abide by the Move Over law, PLEASE ANSWER FAST I WILL GIVE BRAINLY A climber is on a hike. After 2 hours he is at an altitude of 300 feet. After 5 hours, he isat an altitude of 500 feet. What is his average rate of change? Make sure to includeyour units! If you were the manager at a firm which deals with sensitive information of its customers, employees and other stake holders, how would you make sure that information is protected and is altered only by the designated authorized person It's takes two scoops of detergent for every three scoops of fabric softener if there are 28 scoops of detergent remaining, how many scoops of fabric softener will be needed 3. How would a Eugenicist define someone who is Defective"? Solve for n: 0.22n = 6.6. A(n) ________ is a procedure in which blocked heart vessels are opened physically by passing a catheter into the narrowed vessel. There are 4 boys and 9 girls on the track team how many students are on the track team altogether Which atom in the following sets has the larger atomic radius?a. Rn, Ne, Ar, Kr b. Hg, Cs, Po, W c. Mg, P, Al, Ar Write a debate on education is better than money otld7dlyzotzfkztkzk A cable company charges $24.95 a month for basic service and $6.94 a month for each additional channel. If the Kellys monthly bill is $45.80, how many premium channels are they receiving? Which changes occur in females during puberty?A) Acne clears up.B)The hips narrow.C)Underarm hair grows.D)Body hair thickens.I can only pick one, I feel like it could be all of them but A so idk I am not much for cluster diagrams, because they don't help me come up with ideas. I prefer brainstorming, where I take a few minutes, set the timer, and just write ideas until the timer goes off. Being free to jot down any and all ideas really gets my creativity flowing. I will use the story map, though. I think that is a really good idea for planning the details in my story. Create one post that answers the following prompt. How will you generate ideas for a topic? What resources and tools can you use? Answer the questions about the characteristics of the elements in group 2 (the alkaline earth metals).1. What happens when the elements in group 2 react with iodine? a. a salt is formed (MI_2) b. a salt is formed (MI) c. no reaction 2. How do they react with water? a. hydrogen gas is released b. oxygen is released 3. How do they react with oxygen? a. an oxide is formed (M_2 O) b. an oxide is formed (MO) c. no reaction 4. Which reacts the most vigorously? a. Ba b. Mg c. Ca d. Sr e. Ba 5. Which element in the group is the most metallic in character? a. Be b. Mg c. Ca d. Sr e. Ba What is the longest living animal? You and a group of friends take turns planting 2 trees each at a campsite. After the first person plants 2 trees, there are 12 trees at the campsite. A. Write an equation for the nth term of the arithmetic sequence. Let n represent the position in the sequence and let an represent the number of trees. C. After 8 more people plant trees, how many trees are at the campsite?