Encode or decode a color combination

Assignment Help Basic Computer Science
Reference no: EM13165283

In the early days of computer graphics, colors where represented as two numbers. The first number was the foreground color and the second was the background color. These two values, which ranged from 0 to 15 were stored within a single byte; the foreground color being the upper four bits and the background color being the lower four bits.

Write a program that will ask a user if they wish to encode or decode a color combination. For the encoding, the user can only enter values between 0 and 15 for either the foreground or background color, and then the program will display the numerical value obtained when the foreground color is placed in the upper four bits and the background color is placed in the lower four bits.

For decoding, the user will enter a number between 0 and 255 (the maximum value for 8 bits), and the program will print out the numbers for the foreground and background colors.

Reference no: EM13165283

Questions Cloud

Develop an approach that will automatically integrate error : Develop an approach that will automatically integrate error messages and a user help facility. That is, the system would automatically recognize the error type and provide a help window with suggestions for correcting it. Perform a reasonably complet..
Study of prosocial behavior : By-stander behavior is an important topic within the study of prosocial (helping) behavior. Apply the well-known and respected by-stander research of Latane and Darley to this scenario:
F does not logically imply : Given R = (J,K,L ) and the set F of FDs J -> K and L -> K , show that F does NOT logically
Variables should be private and the class functions public : All the class variables should be private and the class functions public. The class functions should be implemented in a file Inventory.cpp which should be linked with the inventory.hpp file.
Encode or decode a color combination : In the early days of computer graphics, colors where represented as two numbers. The first number was the foreground color and the second was the background color. These two values, which ranged from 0 to 15 were stored within a single byte; the fore..
Offer activities to promote diversity : "Many organizations sponsor or offer activities to promote diversity.  What types of activities or trainings do organizations offer to ensure/promote a diverse company.
This program will simulate the game of hearts : This program will simulate the game of Hearts, which is a four-player trick-taking game using any ordinary deck of playing cards. Each player is dealt thirteen cards. Whoever is dealt the Two of Clubs must lead it to the first trick. Each person p..
Harassment prevention training : What are some of the reasons an organization should have harassment prevention training?  Even though our text focuses on sexual harassment, which groups of people, in addition to women, can be targets of harassment? "
Efforts against terrorism more effective : If the United States is NOT making progress, what would have to happen to make the efforts against terrorism more effective?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Determine the date in opening of letter

If /home/jenny/draft and /home/alex/letter are links to same file and following sequence of events occurs, what will be date in opening of letter? Alex gives command vim letter.

  Positive and negative characteristics of hybrid databases

A idea that several of the main database vendors have come up with is a hybrid database that integrates the concepts of both OO and Relational databases.

  Circuit diagram-truth table for half subtractor-full adder

Illustrate the circuit diagram of the following circuit and create truth table for half subtractor and full adder. Full subtractor and Half adder.

  How procedure calls go before registers saved in memory

How deep can the procedure calls go before registers must be saved in memory? (That is, what is the maximum number of "active'' procedure calls that can be made before we need to save any registers in memory?)

  Mips uses word alignment

MIPS uses word alignment, so all words are stored in memory on word boundaries; this means that address bits A[1:0] are always 00. How many and which address bits would be allocated for the set index?

  Website has a duty to be familiar with drug laws

Assume a foreign website sells drugs which are not approved by regulatory agencies for sale to citizens of another country. Do you believe that website has a duty to be familiar with drug laws throughout the world?

  Local telephone calls and long distance telephone calls

Will the distinction between local telephone calls and long distance telephone calls ever disappear? What may cause this to happen?

  Freedom of expression in cyberspace-information society

Write down a 3 pages summary about "Freedom of expression in Cyberspace & Information Society " after reading at least one article in each point of view.

  Is it possible for an instruction to be receiving forwarding

Is it possible for an instruction to be receiving forwarding information and simultaneously being flushed?If possible, can you provide an example sequence of instructions?

  How does cpu interface with device to coordinate transfer

Direct memory access is used for high-speed I/O devices to avoid increasing the CPUÂ ´s execution load. How does CPU interface with device to coordinate transfer?

  Retrieves a student name and three scores

Write an application that retrieves a student name and three scores per line from a text file. Process the values by calculating the average of the scores per student. Write the name and average to a different text file. Test your application with a ..

  Sbh problem to reconstruct dna sequence from its l-mer

The SBH problem is to reconstruct a DNA sequence from its l-mer composition. Suppose that instead of a single target DNA fragment, we have two target DNA fragments

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd