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

  Finite difference method

Use the finite difference method to calculate the temperature at the point specified since it is easier.

  Determine the necessary shell temperature

In a shell-and-tube heat exchanger, one fluid passes through a central tube while another fluid flows through an outer shell in the opposite direction. The purpose is to heat the fluid passing through the central tube.

  Find the integral of a function at an arbitrary location

Write a Matlab function to perform numerical integration of a set of evenly spaced data points using the trapezoidal rule

  Compute the speed of single-stage planetary gear train

Write a MATLAB function [speed] = planetary (N, emesh, first, last, arm) that computes the speed of a given link in a single-stage planetary gear train.

  Calculate and plot the error in the numerical derivative

Write a program to calculate and plot the error in the numerical estimate of the derivative.

  Create the graph using matlab functions

Create the graph, which contains a piecewise function where a line exists in the first interval, a parabola in the second interval, and the sine function in the third interval.

  Develop a simulation program

Develop a simulation program

  Create a vector in matlab

Create a three dimensional diagram of function.

  Open a named pipe and to read data from the pipe

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

  Write the commands that will create the matrix

Write the commands that will create the matrix.

  Lagrange interpolating polynomial of degree

Lagrange interpolating polynomial of degree

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