Question

Write a program that coverts a zip code to a bar code.

The bar codes use large and small bars. We will use : as a small bar and | as a large bar.

Each digit has its own bar pattern.

  • 1 is :::||
  • 2 is ::|:|
  • 3 is ::||:
  • 4 is :|::|
  • 5 is :|:|:
  • 6 is :||::
  • 7 is |:::|
  • 8 is |::|:
  • 9 is |:|::
  • 0 is ||:::

The barcode also includes a check digit. The final digit added to the bar code verifies the previous numbers are correct.

To Determine the checksum:

  • Add all the digits together
  • Determine what needs to be added to make the total a multiple of 10

The bar code also always starts and ends with a large bar. This is used by the scanner to align the letter.

Drexel's Zip Code is 19104

The check digit is 5. The sum of the digits is 1+9+1+0+4 = 15. To make 15 a multiple of 10, we need to add 5.

The bar code will be |:::|||:|:::::||||::::|::|:|:|:|

The majority of work in this problem is done by digit. It makes sense to store the zip code as a string, not as an integer.

Write the function checksum(zip) that takes the zip code as a string and returns the check digit as a string.

Write a function barcode(zip) that takes a zip code as a string and returns the bar code.

Develop a main program that repeatedly asks the user for zip codes and converts them to bar codes. The program will run until the user enters "exit". Remember to use if name=="main": so that ZyBooks can test your functions.

This code is for python
Welcome to Bar Code Generator
Enter Zip Code (exit to quit):
19104
Bar Code:
Enter Zip Code (exit to quit):
19128
Bar Code:
Enter Zip Code (exit to quit):
07004
Bar Code:
Enter Zip Code (exit to quit):
exit
Thanks using me.
Expand
Transcribed Image Text

Welcome to Bar Code Generator Enter Zip Code (exit to quit): 19104 Bar Code: Enter Zip Code (exit to quit): 19128 Bar Code: Enter Zip Code (exit to quit): 07004 Bar Code: Enter Zip Code (exit to quit): exit Thanks using me.

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: How do you convert 172.16.20.55 to binary format?

A: 172.16.20.55 represents IP address in decimal format. In order to convert it into binary format we n...

Q: Prove that the following languages are not regular: (b) L = {anblak : k ≠ n + l}. (c) L = {anblak : ...

A: In the given question, multiple parts are there and we will solve only first three parts as no parti...

Q: 5-1) (Count positive and negative numbers and compute the average of numbers) Write a program that r...

A: Java program to count posive and negative numbers and computing the total and average of numbers is ...

Q: What language is accepted by the npda M = ({q0, q1, q2}, {a, b}, {a, b, z}} q0, z, {q2}). δ(q0,a,z)=...

A: The given npda is M = ({q0, q1, q2}, {a, b}, {a, b, z}} q0, z, {q2}) with transition functions asδ(q...

Q: How would I write a C program to find the length of the longest substring of a given string without ...

A: The given program is to find the maximum length of the substring without repeating character. This i...

Q: How can I create a decoder and a multiplexer in a circuit? The decoder has a 3 bit select input and ...

A: A decoder is a circuit which has n inputs and 2n outputs. So if there are 3 inputs to a decoder it w...

Q: Write a program called LoopMinMax that reads in 4 values from the user and prints the lowest and hig...

A: You didn’t mention which language should be used for the given program. Here, I have used JAVA langu...

Q: Knapsack Problem This exercise is due Tuesday, May 14. It has to be turned in on time in order to ge...

A: Instructions for completing the table:Enter 0 where objects and weights are zero.For each row assume...

Q: Write a complete C++ program that does the following: 3. Create a function called findSmallestValue ...

A: To use  functions, first of all  you need to declare the functions and to input the number of rows a...

Q: Used Java 4.23 (Financial application: payroll) Write a program that reads the following information...

A: The program would have the following 4 sections:The declaration and initialization of the variables ...

Q: Suppose that data are stored on 8.54-gbyte single-sided, double-layer dvds that weigh 15 g each. sup...

A: Data stored on DVDs = 8.54 GbyteWe have to calculate data transmission rate in bits per second, so w...

Q: Using Math.max and/or Math.min, write a class MaxOrMin, and make sure touse Math.max and Math.min wh...

A: Java codeimport java.util.Scanner; public class MaxOrMin {public static void main(String[] args){Sca...

Q: Consider the following segment of code:procedure Mvar x: integer;procedure A (c: integer)var a, b: i...

A: Instructions for drawing the runtime stack (at “a:= c-d;”):The stack includes the activation records...

Q: SQL (Oracle) How do I create a unique constraint to find a specific price range? i.e. between 30 - 1...

A: Query to create tabale:Let us assume the table name as "Product". CREATE TABLE PRODUCT(ORDER_ID INT,...

Q: Write a complete C++ program that randomly generates 20 integers between the rangeof 1 to 50 and sto...

A: Solution:Given data,The C++ code to generate the 20 random numbers with the range from “1” to “50”, ...

Q: Assignment: Check the Sample run first, then carefully read the instructions and write aprogram that...

A: Solution:Given data,The java code gets the first name, last name, and secret number to generate the ...

Q: Code should be in C++ Absolute Value Template: Write a function template that accepts an argument an...

A: Since Function Templates are used to handle all possible data types you can say generic data type at...

Q: Assume that a firm has already implemented a KMS system, as a manager, how do you ensure that learni...

A: Protecting knowledge of the organization is a typically an IP protection problem.The ways the organi...

Q: Load “Lock5Data” into your R console. Load “OlympicMarathon” data set in“Lock5Data”. This data set c...

A: First we install the Lock5Data package and then load the package. Then we load the library dplyr to ...

Q: do big data could replace the artistic vision of a creative director? and why?

A: Justification:“Yes”, big data replace the artistic vision of a creative director.

Q: how to write a function in python 3 that take a tuple t = (7,8,4,20,11) and returns a list which inc...

A: Note: The below program has been complied and executed in “repl.it” online complier

Q: Find context-free grammars for the following languages (with n ≥ 0, m ≥ 0, k ≥ 0):  L = {anbmck, k =...

A: Solution:Given language,L = {anbmck, k = n+m}Consider the “G” as grammar production is given below:

Q: Write a complete C++ program that randomly generates 20 integers between the rangeof 1 to 50 and sto...

A: The random number is generated by using rand() function from stdlib.h and in order to generate a new...

Q: What language is accepted by the Turing machine whose transition graph is in the figure below?

A: Turing machine:Turing machine is a model of a hypothetical computing machine which can use a predefi...

Q: Transform the grammar with productions S → baAB, A → bAB|λ, B → BAa |A| λ into Chomsky normal form.

A: A context free grammar is in Chomsky normal form if its productions are in the formA → a or A → BC o...

Q: Write a java program called Sales considering the following directions and the sample run. Practice ...

A: The program has the following steps:Declare the variablesReceive the input from the userCalculate th...

Q: Find a regular grammar that generates the language on Σ = {a, b} consisting of all strings with no m...

A: Regular grammar for the language Σ = {a, b} is as follows:

Q: Visual Basic. Given two variables, isEmpty of type boolean, indicating whether a class roster is emp...

A: We will have two check the below conditions:-1) class roster is not empty2) the class is one or thre...

Q: You are not required to execute the queries. However, your syntax must by accurate.You must give at ...

A: SELECT Movie_Tiltle, Movie_Year, Price_Description, Rental_Fee FROM Movies WHERE Categories = ‘famil...

Q: what is the best test strategy for any ERP system?

A: ERP stands for Enterprise resource planning is a software used for business process management. It a...

Q: Hello, please I need help with the following using Python:   Write flowchart, pseudo-code and progra...

A: Pseudocode:Import module statistics and Declare variables Students and Student_listPrompt for the nu...

Q: Assume the following declarations and initializations (MIN, MAX, num) are made just before each sub-...

A: Answer: Algorithm:The program has the following algorithm:The class name is “Main” and in the main m...

Q: write a program that reads a line of text and then displays the line, but with the first occurrence...

A: Given below program reads the first occurrence of “hate” and displays “love “ in place of “hate”.

Q: Develop the ‘Shape’ application such that: ‘Rectangle’, ‘Ellipse’, and ‘Triangle’ classes inherit f...

A: Program plan:Define a class named “Shape”.Define a default constructor to print constructor invoked ...

Q: how to put a picture to top right corner in HTML

A: HTML stands for Hypertext markup language and is mainly used to format web pages and web sites. Html...

Q: Which filenames would be a subsequent ls command display?$ lsabc abd abe abf abg abh$ rm abc ab*rm: ...

A: To describe which filenames the subsequent ls command display.

Q: Can someone offer an explanation to these few simple questions please?

A: Click to see the answer

Q: Write a recursive function that computes the length of a list. For example, (mylen ‘(1 2 3 4))should...

A: The syntax for given function call (mylen’(1 2 3 4)) is of Lisp programming.For lisp program:Create ...

Q: This question is for Python. Thank you!

A: The algorithm of the file would be as below:Receive the inputs as a series of input commandsConcaten...

Q: 4-20) (Process a string) Write a program that prompts the user to enter a string and displays its le...

A: Program to enter string by the user to displays string length and its first character. as in the giv...

Q: function myCompose(f,g){// TODO: return (f o g);// that is, a function that returns f(g(x)) wh...

A: Click to see the answer

Q: Consider the following procedure: procedure mystery (x, y, z); integer x, y, z;beginz =2; y = z + x;...

A: Call by reference The arguments passed to a function will copy the address of an argument into the f...

Q: I am trying ro create this java program , i have the table in my tatabase . I am using postgresql ii...

A: Program Instructions:Add the postgresql jar file in your project library.Create a database and a tab...

Q: Write a function that takes in three numbers as parameters and prints out the largest of the three. ...

A: Program to write a function that takes in three numbers as parameters and prints out the largest of ...

Q: Show a derivation tree for w = aaabbaaa using the grammar in Example 5.1. EXAMPLE 5.1 The grammar G ...

A: Solution:Given that,w = aaabbaaa

Q: Design a modular program that asks the user to enter the monthly costs for the following expenses in...

A: We are designing the program in C++ programming language. Given below is the program designed to ent...

Q: Hi,  Please,I have a question with Python,I have to create a Loop and terminate BMI calculation flow...

A: The loop of flow chart for BMI is given as:

Q: Programming in C language.

A: Note:The below program has been complied and run in "repl.it" online complier.

Q: how to to assign charather to perform additions (+), subtractions (-), multiplications (*), division...

A: Program plan:Include necessary header files.Declare the “namespace”.Define the “main()” function.Dec...

Q: In PL/SQL, Create a recursive store function called add_numbers to calculate the total of all consec...

A: Program plan:Declare the required variables.The “add_numbers” function returns the value. Otherwise,...