Use this table to convert digits to barcode representation and vice-versa; each digit is represented in 5 characters; so 1 will be represented as 00011; as 0 is represented as half bar (:) and 1 is a full bar (1) ; 1 will be represented as :::|| ; similarly 9 is 10100 and will be represented as |:|:: Write a program that asks the user for a ZIP code and prints the bar code. Use : for half bars, | for full bars. For example, 95014 becomes ||:|:::|:|:||::::::||:|::|:::||| Your program should also be able to carry out the opposite conversion: Translate bars into their ZIP code, reporting any errors in the input format or a mismatch of the digits. java
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Use this table to convert digits to barcode representation and vice-versa; each digit is represented in 5 characters; so 1 will be represented as 00011; as 0 is represented as half bar (:) and 1 is a full bar (1) ; 1 will be represented as :::|| ; similarly 9 is 10100 and will be represented as |:|::
Write a program that asks the user for a ZIP code and prints the bar code. Use : for half bars, | for full bars. For example, 95014 becomes
||:|:::|:|:||::::::||:|::|:::|||
Your program should also be able to carry out the opposite conversion: Translate bars into their ZIP code, reporting any errors in the input format or a mismatch of the digits.
java
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 7 images