Reference no: EM132213280
Question :
Write a Ruby Script that simulates a simple four function calculator without a memory. The operations you should implement are:
+ - Add
- - Subtract
/ - Divide
* - Multiply
Q - Quit Program Error message must be displayed when invalid command is used or attempt to divide by zero. Use a single character as the command for each operation.
Here's a sample of the calculator in use:
Enter First Operand: 0
Enter Command (+ - * / C Q): +
Enter Second Operand : 12
Result = 12
Enter First Operand: -4
Enter Command (+ - * / C Q): -
Enter Second Operand : 12
Result = -16
Enter First Operand: 10
Enter Command (+ - * / C Q): *
Enter Second Operand : 5
Result = 50
Enter First Operand: 13
Enter Command (+ - * / C Q): /
Enter Second Operand : 3
Result = 4.333333
Enter First Operand: 13
Enter Command (+ - * / C Q): \
Enter Second Operand : 3
******* ERROR : \ is not a valid command *******
Enter First Operand: 28
Enter Command (+ - * / C Q): /
Enter Second Operand : 0
******* ERROR : Cannot divide by zero *******
Enter First Operand: 15
Command (+ - * / C Q) Q
End
Compute morgans dependent tax credit
: Morgan (age 45) is single and provides more than 50% of the support of Rosalyn (a family friend, age 36), Flo (a niece, age 18), and Jerold (a nephew, age 18).
|
Write a regular expression that describes the language
: Write a regular expression that describes the following language: the set of strings that that contain an even number of a's.
|
Write a routine to list out the nodes of a binary tree
: Write a routine to list out the nodes of a binary tree in level-order. List the root, then nodes at depth 1, followed by nodes at depth 2, and so on.
|
Write a recursive function that will take a nonnegative int
: Write a recursive function that will take a nonnegative integer n as formal parameter and return its factorial. Trace the function calls for n = 4.
|
Simulate a simple four function calculator without a memory
: Write a Ruby Script that simulates a simple four function calculator without a memory.
|
Write a regular expression to pass to grep to determine
: Write a regular expression to pass to grep to determine if a Chicago area (773 or 312) phone number, in the form (312) 281-3303, is present in a given file.
|
Write a research about the importance of servers rooms
: Write a research about the importance of servers rooms or (network devices rooms) in any organization or institutions.
|
Write a recursive method search stack which returns true
: Write a recursive method search Stack(LinkedStack S, E x) which returns true if the stack S contains the element x, otherwise it returns false.
|
Compute the value of an expression in parentheses
: Write a recursive MARS program that can compute the value of an expression in parentheses.
|