Grade - Division of Engineering Programs

advertisement
Engineering Computing 1
Major Assignment I
Name:
Grade:
Engineering Computing I
Major Homework Assignment I
Write a C program to implement the following:
1- When running your program it should first print out a welcoming message describing the
functionality of your program. Choose your own (brief) words to describe such
functionality.
2- Then it should prompt the user to select a base for conversion. Your program should be
able to work with bases 2 (binary), 8 (octal) and 10 (decimal). Therefore, the user is
prompted to enter ‘B’, ‘O’ or, ‘D’.
3- Your program then should prompt the user to enter digits in the appropriate base one by
one. The user terminates the sequence by entering ‘#’ character.
4- After receiving ‘#’, your program should convert the entered sequence of digits into an
integer and prints that as a decimal value.
Example:
Hello! Welcome to ……..
Please Enter ‘B’ for binary, ‘O’ for octal, ……
B
Thank you! You selected conversion from Binary ……
Enter digit 1 ( use # to terminate):
1
Enter digit 2 ( use # to terminate):
1
Enter digit 3 ( use # to terminate):
2
You entered an unacceptable digit! Enter digit 3 ( use # to terminate):
0
Enter digit 4 ( use # to terminate):
1
Enter digit 5 ( use # to terminate):
#
Result of Conversion => 14
Thank you for using ….. BYE!
Notes: If the user enters a digit that is not part of the base digits (such as 2 in
the case of Binary), you program should alert the user about the error and
ignore that entry. The number of the next digit should stay the same!
Download