Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,499 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,375 people online right now. Registration is fast and FREE... Join Now!




Ctt problem

 
Reply to this topicStart new topic

Ctt problem

WarGeneral
23 Mar, 2007 - 06:29 PM
Post #1

New D.I.C Head
*

Joined: 23 Mar, 2007
Posts: 3


My Contributions
For this program you will be creating an operation table. The operation will be chosen by the user, from addition, subtraction, multiplicaation, and division with remainders. The table will go from 1 to 10 on each side.

There will be a dialogue where you ask the user which operation they want. Based on their answer, you should produce an operation table for that operation. You should keep asking for an operation until you get a satisfactory answer. This dialogue should be in a function, with the good operation as the return value.

Sample output - Screen:

Enter an operation: + - * / ^
Enter an operation: + - * / @
Enter an operation: + - * / $
Enter an operation: + - * / /
/ 1 2 3 4 5 6 7 8 9 10
-------------------------------------------------------------
1 | 1 R0 0 R1 0 R1 0 R1 0 R1 0 R1 0 R1 0 R1 0 R1 0 R1
2 | 2 R0 1 R0 0 R2 0 R2 0 R2 0 R2 0 R2 0 R2 0 R2 0 R2
3 | 3 R0 1 R1 1 R0 0 R3 0 R3 0 R3 0 R3 0 R3 0 R3 0 R3
4 | 4 R0 2 R0 1 R1 1 R0 0 R4 0 R4 0 R4 0 R4 0 R4 0 R4
5 | 5 R0 2 R1 1 R2 1 R1 1 R0 0 R5 0 R5 0 R5 0 R5 0 R5
6 | 6 R0 3 R0 2 R0 1 R2 1 R1 1 R0 0 R6 0 R6 0 R6 0 R6
7 | 7 R0 3 R1 2 R1 1 R3 1 R2 1 R1 1 R0 0 R7 0 R7 0 R7
8 | 8 R0 4 R0 2 R2 2 R0 1 R3 1 R2 1 R1 1 R0 0 R8 0 R8
9 | 9 R0 4 R1 3 R0 2 R1 1 R4 1 R3 1 R2 1 R1 1 R0 0 R9
10 | 10 R0 5 R0 3 R1 2 R2 2 R0 1 R4 1 R3 1 R2 1 R1 1 R0



Sample output - File (table.txt):

/ 1 2 3 4 5 6 7 8 9 10
-------------------------------------------------------------
1 | 1 R0 0 R1 0 R1 0 R1 0 R1 0 R1 0 R1 0 R1 0 R1 0 R1
2 | 2 R0 1 R0 0 R2 0 R2 0 R2 0 R2 0 R2 0 R2 0 R2 0 R2
3 | 3 R0 1 R1 1 R0 0 R3 0 R3 0 R3 0 R3 0 R3 0 R3 0 R3
4 | 4 R0 2 R0 1 R1 1 R0 0 R4 0 R4 0 R4 0 R4 0 R4 0 R4
5 | 5 R0 2 R1 1 R2 1 R1 1 R0 0 R5 0 R5 0 R5 0 R5 0 R5
6 | 6 R0 3 R0 2 R0 1 R2 1 R1 1 R0 0 R6 0 R6 0 R6 0 R6
7 | 7 R0 3 R1 2 R1 1 R3 1 R2 1 R1 1 R0 0 R7 0 R7 0 R7
8 | 8 R0 4 R0 2 R2 2 R0 1 R3 1 R2 1 R1 1 R0 0 R8 0 R8
9 | 9 R0 4 R1 3 R0 2 R1 1 R4 1 R3 1 R2 1 R1 1 R0 0 R9
10 | 10 R0 5 R0 3 R1 2 R2 2 R0 1 R4 1 R3 1 R2 1 R1 1 R0



You must use a switch statement to deal with the choice of operation. You can have either:

1. a switch statement that calls one of four functions, each designed to produce a table for a particular operation, or
2. a function that produces a table with a switch statement that is only used for the calculation, or
3. you might choose to combine the two, with one function to handle +, -, and *, and another for division with remainders.

The table should be printed to both the screen and a file, table.txt.
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Ctt Problem
23 Mar, 2007 - 07:45 PM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,867



Thanked: 53 times
Dream Kudos: 550
My Contributions
please post code. Again two for-loops do the trick.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 06:19PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month