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
Roman55 [17]
2 years ago
8

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.
Computers and Technology
1 answer:
Dahasolnce [82]2 years ago
8 0

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.

You might be interested in
What is the on board storage C:
sasho [114]
On-board? im assuming so. an on-board storage is where people keep luggage/items on a ship.

hopefully i could help ;)
7 0
3 years ago
Adam is so good at playing arcade games that he will win at every game he plays. One fine day as he was walking on the street, h
klio [65]

Answer:

what the answer chaoices

Explanation:

brainlest me please

3 0
2 years ago
Which one of these is the most commonly used hardware interface for attaching peripherals to a microcomputer?
Tanzania [10]
Hey there!

The most commonly used hardware interface for attaching peripherals to a microcomputer is the universal series bus, or USB, port. Many computers have at least 2 to 4 USB ports that allow for multiple devices to be plugged in at once. In terms of wired devices as opposed to wireless, this is the main way that a mouse, a keyboard, a smartphone (for charging and syncing information), and many other devices are connected to computers. 

Hope this helped you out! :-)
4 0
2 years ago
Pick a web browser (a leading one or perhaps a lesser-known one that you use) and examine the Privacy and Security features and
Veseljchak [2.6K]

Solution :

<u>Chrome web browser</u>

The Chrome web browser uses a range of privacy and security settings for its customers. They include several security indicators as well as malware protection. Chrome uses the sandboxing technology, which prevents the harmful viruses and Trojans from reaching the computers.

Chrome provides a safe browsing by giving us an alert whenever we try to browse some harmful web sites.  It also warns you if we use a username and password combination which has been compromised in any data leak.

Chrome also serves to protect the individuals :

It provides a features of Ad blocking.

When we want to browse safely without being recognized or without storing any credentials, Chrome provides an Incognito mode.

Many businesses can be done on the internet using Chrome platform that is safe and authenticate to gather and collect data and information.

3 0
2 years ago
Which types of customizing can you do with the Cell Style galleries? Check all that apply.
guapka [62]

Change the font size

Change the font color

Change the background color

Adjust percentage of background shade

Add a hyperlink

Explanation:

All of these have todo with style

8 0
3 years ago
Read 2 more answers
Other questions:
  • About ___% of children score within one standard deviation above or below the national average in intelligence.
    5·1 answer
  • "Unicorn designs Inc., a software company, requires its employees to wear a specific color every day of the week. The colors for
    8·2 answers
  • Which partitioning method must you use for a 4-tb hard drive?
    13·1 answer
  • _________ are represented using diamonds linked withparticipant ETs
    6·1 answer
  • Liz's meeting is scheduled to end at 9:30. It is 9:20 and team
    9·1 answer
  • Why is the len ( ) function useful when using a loop to iterate through a stack?
    6·1 answer
  • The flynn effect best illustrates that the process of intelligence testing requires up-to-date ________
    14·1 answer
  • Explain the working principle of computer with suitable diagram​
    15·1 answer
  • How does your ability to correctly count change affect the impression the customer has of you?
    8·1 answer
  • processing C. have only one function, e.g. control traffic lights in a town, games machines 7 To create a formula, you first: A.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!