Write a C++ program for the conversion of a decimal number to a binary, octal and hexadecimal equivalents within a given range of the upper and lower limits. Your program needs to follow the following steps to give the desired output. (1.a). Your program should ask to choose the upper limit from 256, 128, 32, 16, 8, 4, 2 only. If a user enters a number other than these numbers, the program should display a message of wrong entry and should ask for retry, otherwise continue to step (b). (1.b). Your program should ask to enter the lower limit. The lower limit should be less than the upper limit (of step 1.a) and greater than 0. If a user enters a number greater than the upper limit or less than 0 (e.g., a negative value), then the program should display a message of wrong entry and should ask for retry, otherwise continue to display the output. (1.c). If a user enters the upper and lower limits correctly, then the program should print a table of the binary, octal and hexadecimal equivalents of the given decimal numbers in the range of upper and lower limits as given in screenshots. Use of while loop, if else, for loop, nested loops is allowed. Functions, arrays and goto statements are NOT allowed.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Write a C++ program for the conversion of a decimal number to a binary, octal and hexadecimal
equivalents within a given range of the upper and lower limits. Your program needs to follow the
following steps to give the desired output.
(1.a). Your program should ask to choose the upper limit from 256, 128, 32, 16, 8, 4, 2 only. If a
user enters a number other than these numbers, the program should display a message of wrong
entry and should ask for retry, otherwise continue to step (b).
(1.b). Your program should ask to enter the lower limit. The lower limit should be less than the
upper limit (of step 1.a) and greater than 0. If a user enters a number greater than the upper limit
or less than 0 (e.g., a negative value), then the program should display a message of wrong entry
and should ask for retry, otherwise continue to display the output.
(1.c). If a user enters the upper and lower limits correctly, then the program should print a table of
the binary, octal and hexadecimal equivalents of the given decimal numbers in the range of upper
and lower limits as given in screenshots.

Use of while loop, if else, for loop, nested loops is allowed. Functions, arrays and goto statements are NOT allowed.

24
011000
30
18
25
011001
31
19
26
011010
32
la
27
011011
33
lb
le
1d
28
011100
34
29
011101
35
30
011110
36
le
31
011111
37
If
32
100000
40
20
Transcribed Image Text:24 011000 30 18 25 011001 31 19 26 011010 32 la 27 011011 33 lb le 1d 28 011100 34 29 011101 35 30 011110 36 le 31 011111 37 If 32 100000 40 20
Example output:
Please enter one of a number from this list (256, 128, 64, 32, 16, 8, 4 or 2) as upper limit: 45
You should enter the upper limit from this list only: 256, 128, 64, 32, 16, 8, 4, 2
Please enter the upper limit: 32
Enter lower limit: -12
You should enter the value greater than 0 and less than the upper limit
Enter lower limit: 50
You should enter the value greater than 0 and less than the upper limit
Enter lower limit: 10
Decimal
Binary
Octal
Hexadecimal
10
001010
12
a
11
001011
13
b
12
001100
14
13
001101
15
d
14
001110
16
15
001111
17
f
16
010000
20
10
17
010001
21
11
18
010010
22
12
19
010011
23
13
20
21
010100
24
14
25
26
010101
15
22
010110
16
23
010111
27
17
Transcribed Image Text:Example output: Please enter one of a number from this list (256, 128, 64, 32, 16, 8, 4 or 2) as upper limit: 45 You should enter the upper limit from this list only: 256, 128, 64, 32, 16, 8, 4, 2 Please enter the upper limit: 32 Enter lower limit: -12 You should enter the value greater than 0 and less than the upper limit Enter lower limit: 50 You should enter the value greater than 0 and less than the upper limit Enter lower limit: 10 Decimal Binary Octal Hexadecimal 10 001010 12 a 11 001011 13 b 12 001100 14 13 001101 15 d 14 001110 16 15 001111 17 f 16 010000 20 10 17 010001 21 11 18 010010 22 12 19 010011 23 13 20 21 010100 24 14 25 26 010101 15 22 010110 16 23 010111 27 17
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Returning value from Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning