Lab Programming - Assignment 1 | Data Structures Concepts | CPSC 131, Assignments of Data Structures and Algorithms

Material Type: Assignment; Professor: Laguna; Class: Data Structures Concepts; Subject: Computer Science; University: California State University - Fullerton; Term: Spring 2009;

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-m7i-1
koofers-user-m7i-1 🇺🇸

9 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CPSC 131
LAB PROGRAMMING
ASSIGNMENT #1
Due Date:
Menu Driver: February 19, 2009 at 1:00 p.m.
Class: February 26, 2009 at 1:00 p.m.
Program: March 10, 2009 at 1:00 p.m.
Problem:
Egyptian Math
Write a C++ program that adds and subtracts Egyptian numbers. The
Egyptian numbers are:
Decimal Egyptian Symbol Represents Computer Symbol
1 staff I
10 heel bone N
100 coil of rope 9
1000 lotus flower L
10000 pointing finger /
100000 tadpole O
1000000 astonished man Y
Note: The Egyptian numbers is in base 10.
Representing Egyptian numbers:
92 = = IINNNNNNNNN
46,206 = = IIIIII99LLLLLL////
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Lab Programming - Assignment 1 | Data Structures Concepts | CPSC 131 and more Assignments Data Structures and Algorithms in PDF only on Docsity!

CPSC 131

LAB PROGRAMMING

ASSIGNMENT

Due Date:

Menu Driver: February 19, 2009 at 1:00 p.m. Class: February 26, 2009 at 1:00 p.m. Program: March 10, 2009 at 1:00 p.m.

Problem:

Egyptian Math Write a C++ program that adds and subtracts Egyptian numbers. The Egyptian numbers are: Decimal Egyptian Symbol Represents Computer Symbol 1 staff I 10 heel bone N 100 coil of rope 9 1000 lotus flower L 10000 pointing finger / 100000 tadpole O 1000000 astonished man Y Note: The Egyptian numbers is in base 10. Representing Egyptian numbers: 92 = = IINNNNNNNNN 46,206 = = IIIIII99LLLLLL////

Adding two Egyptian numbers: (= 456) (= 265) Combine together And reduce (=721) Computer Symbols IIIIIINNNNN9999 + IIIIINNNNNN99 = IIIIIIIIIIINNNNNNNNNNN999999 = INN

Computer Symbols IIIIIINNNNN9999 - IIIIINNNNNN99 = INNNNNNNNN

Menu Driver:

Your program will be written as a menu driver which means that you will display a menu to select the operation that is wanted. (p. 230 – 250; p.

  1. Your menu driver will have the following three functions: DisplayMenu() /* Function: Displays on the screen the selection for addition, subtraction and exit. Precondition: Postcondition: / GetCommand(command) / Function: Gets the choice from menu. Precondition: Postcondition: / RunChoice(command) / Function: Run the command the user selected. Precondition: Postcondition: */ The following choices are needed:
  1. Add Two Egyptian Numbers
  2. Subtract Two Egyptian Numbers
  3. Quit

Test: Test your menu to determine if the correct choice is gotten.

Hand In: February 19, 2009 at 1:00 p.m.

  1. Functional Design Trees for the main program
  2. Hardcopy of your main program with documentation

Egyptian Math:

You need to design and code a class called EgyptianMathType. The storage component for the Egyptian number should be an array of 50 characters or a string. The following public functions must appear in your class: (You may use private functions if needed.) Get Egyptian Number /* Function: Gets both Egyptian numbers Precondition: Postcondition: / Add Egyptian Numbers / Function: Adds both Egyptian numbers together Precondition: Postcondition: / Subtract Egyptian Numbers / Function: Subtracts first Egyptian number from the second Egyptian number. Precondition: Postcondition: / Print Egyptian Number / Function: Prints both Egyptian numbers with appropriate + or – and the result. Precondition: Postcondition: */

Test: Test your functions to determine if working correctly. If not, mark as not

working and turn in your class.

Hand In: February 26, 2009 at 1:00 p.m.

  1. Hardcopy of your Class EgyptianMathType with documentation.

CPSC 131

LAB PROGRAMMING

ASSIGNMENT

Due Date:

Menu Driver: February 19, 2009 at 5:30 p.m. Class: February 26, 2009 at 5:30 p.m. Program: March 10, 2009 at 5:30 p.m.

Problem:

Egyptian Math Write a C++ program that adds and subtracts Egyptian numbers. The Egyptian numbers are: Decimal Egyptian Symbol Represents Computer Symbol 1 staff I 10 heel bone N 100 coil of rope 9 1000 lotus flower L 10000 pointing finger / 100000 tadpole O 1000000 astonished man Y Note: The Egyptian numbers is in base 10. Representing Egyptian numbers: 92 = = IINNNNNNNNN 46,206 = = IIIIII99LLLLLL////

Adding two Egyptian numbers: (= 456) (= 265) Combine together And reduce (=721) Computer Symbols IIIIIINNNNN9999 + IIIIINNNNNN99 = IIIIIIIIIIINNNNNNNNNNN999999 = INN

Computer Symbols IIIIIINNNNN9999 - IIIIINNNNNN99 = INNNNNNNNN

Menu Driver:

Your program will be written as a menu driver which means that you will display a menu to select the operation that is wanted. (p. 230 – 250; p.

  1. Your menu driver will have the following three functions: DisplayMenu() /* Function: Displays on the screen the selection for addition, subtraction and exit. Precondition: Postcondition: / GetCommand(command) / Function: Gets the choice from menu. Precondition: Postcondition: / RunChoice(command) / Function: Run the command the user selected. Precondition: Postcondition: */ The following choices are needed:
  1. Add Two Egyptian Numbers
  2. Subtract Two Egyptian Numbers
  3. Quit

Test: Test your menu to determine if the correct choice is gotten.

Hand In: February 19, 2009 at 5:30 p.m.

  1. Functional Design Trees for the main program
  2. Hardcopy of your main program with documentation

Egyptian Math:

You need to design and code a class called EgyptianMathType. The storage component for the Egyptian number should be an array of 50 characters or a string. The following public functions must appear in your class: (You may use private functions if needed.) Get Egyptian Number /* Function: Gets both Egyptian numbers Precondition: Postcondition: / Add Egyptian Numbers / Function: Adds both Egyptian numbers together Precondition: Postcondition: / Subtract Egyptian Numbers / Function: Subtracts first Egyptian number from the second Egyptian number. Precondition: Postcondition: / Print Egyptian Number / Function: Prints both Egyptian numbers with appropriate + or – and the result. Precondition: Postcondition: */

Test: Test your functions to determine if working correctly. If not, mark as not

working and turn in your class.

Hand In: February 26, 2009 at 5:30 p.m.

  1. Hardcopy of your Class EgyptianMathType with documentation.