A good way to structure this program

Assignment Help MATLAB Programming
Reference no: EM13164895

Write a program that allows numbers to be entered in decimal (base 10), hexadecimal (base 16), or binary (base 2), and then prints out the number again in all three bases.

To distinguish between different bases we'll say that hexadecimal numbers should always be preceded by a "$" and binary numbers by a "%". Other numbers are assumed to be decimal.

When the program is run it should repeatedly allow a number to be entered and then print it out in all three bases until "q" is typed in. Here's an example of how your program should operate:

Enter #: 45

    Decimal: 45

    Hexadecimal: 2D

    Binary: 101101

Enter #: %101

    Decimal: 5

    Hexadecimal: 5

    Binary: 101

Enter #: $31

    Decimal: 49

    Hexadecimal: 31

    Binary: 110001

Enter #: q

Approach

A good way to structure this program is to read in each "number" as a string of characters, look at the first character to determine what kind of number it is (hex, binary, decimal), and then call an appropriate function to convert the string into a hex, binary, or decimal number Then, print those numbers out next to each of their corresponding bases.

You will have to use these two functions and their variations to convert between bases:

            dec2bin( {user input as integer} ); % e.g. 4 ? "0100"

     hex2dec( {user input as string} ); % e.g. 1D ? "14"

Also, use one or more of the following functions and their variations to convert from an integer to a string and vice versa:

str2num( {user input as string} );

str2double( {user input as string} );

     str2single( {user input as string} );

Reference no: EM13164895

Questions Cloud

Create a document describing the business : Created a document describing the business and identifying the problems being experienced by the assignment case study company, Farmers Friend.
When merge sorting you could recursively : Suppose when merge sorting you could recursively sort four sub-lists instead of two and still merge them all in linear time. Give the recurrence relation that describes this.
What is the mole fraction of na2co3 in resulting solution : You want to prepare a solution that is 0.200m in Na2CO3. How many grams of the salt must you add to 125g of water? What is the mole fraction of Na2CO3 in the resulting solution?
What is the l2 read miss penalty? : s computer calculate the following: (a) What is the L2 read miss penalty? (b) What is the L1 read miss penalty? (c) What is the read penalty (L1 and L2 cache)? (d) Assume 33% (1/3) loads, and everything else is ideal. What is the CPI? (e) What would ..
A good way to structure this program : A good way to structure this program is to read in each "number" as a string of characters, look at the first character to determine what kind of number it is (hex, binary, decimal), and then call an appropriate function to convert the string into..
Ssk software has opened offices in toledo : SSK software has opened offices in Toledo, Columbus, and Cleveland. Toledo will serve as the hub for the network, cisco router will be used at each location.
Draw the mechanism for reaction : Draw the mechanism for each reaction you will do today. Pyridinium tribromide releases molecular bromine, so molecular bromine is the brominating agent.
Designing a 24 cpu multiprocessor chip : designing a 24 CPU multiprocessor chip to compete with Intel PHI at a lower price point. Each core will run at 2 GHz and have a 32Kb L1 cache, 50ps access (per word), 8 word blocks, 4-way associative, write-through, 1% miss ratio There is a 6Mb L2 ca..
I had to call a webservice : I had to call a webservice (1st line of code) and then from there created a loop but keep getting an error every time on the .getBusiness - I don't know what I should be using there instead of getBusiness.

Reviews

Write a Review

 

MATLAB Programming Questions & Answers

  Finds the value of a using a numerical method

Finds the value of a using a numerical method

  Fingerprint watermarking techniques

Need to investigate the best method to embed watermark image into fingerprint image.

  Plot way forms for the subsequent modulation schemes

Plot way forms for the subsequent modulation schemes using Matlab

  Write the command and assign it to variable

Write the command and assign it to variable , Write a function named function_test

  Open a named pipe and to read data from the pipe

Open a named pipe and to read data from the pipe in matlab

  Calculate the geometric mean of numbers

Write a program to calculate the geometric mean of numbers entered by a user. The program should prompt the user to enter numbers and continue to accept the numbers until the user enters 999.

  Compare two sound wave in matlab

Compare two sound wave in matlab as on speech to text processing and open as notepad, calculator,C:,D: and many other on speaking

  Secant method to tryt to find out the root

create a function that will use the secant method to tryt to find out the root

  Write matlab scripts

Write MATLAB scripts for to accept two numbers from the user; Display all prime numbers between these two numbers.

  Determine the specular component

Reparemeterizing each pixel point using spherical coordinates and rotation RGB color space to SUV color space in the paper

  Write a functions

The function range basis takes a matrix A as input, and outputs a basis (again written as columns) for the range space of A.

  Explore the design of a recursive digital filter

In this simulation we are going to explore the design of a recursive digital filter which might be usedvin a digital radio station. The sampling frequency used in digital radio (DAB) is either 48 kHz or 24 kHz and for the purposes of this simulation,

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