Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The year is 2524 and Martians and humans have been interacting on a regular basis, in fact, we have begun to exchange goods! Unfortunately, the

The year is 2524 and Martians and humans have been interacting on a regular basis, in fact, we have begun to exchange goods! Unfortunately, the Martian counting system does not directly transfer to our standard base 10 counting..... its ok though, we know C++. For this assignment you will be writing a program that converts Martian numerals to standard decimal digits. Please see the rules for Martian numbers below. I have provided some pseudo-code for the main program, you must write the actual code according to the specifications detailed in this assignment sheet and the pseudo-code provided. You will be turning in your program as project3 martian numerals.cpp, as well as the results of your testing. Remember to include your name at the top of your code in a comment as well as a brief description of how your program solves the problem. Also, you should make comments throughout your code to explain how your program is working. Converting Martian Numerals Goal: Write a program that will ask users to enter a Martian numeral and then give a decimal conversion. The program should first determine whether or not the numeral is formatted legally. The largest number you will have to worry about will be the decimal equivalent of 4999. Rules for Martian Numerals: The symbols used are @, Z, E, &, B, W, S which equate to 1000, 500, 100, 50, 10, 5, and 1 respectively. Martian numerals are written using the symbols above such that the value of these symbols as you read from left to right never increases. IE: EE is translated as 200. There can never be more than 4 @s, 1 Z, 4 Es, 1 &, 4 Bs, 1 W, or 4 Ss because then the representation is not minimal (e.g. 5 Bs can be written as &). Once you determine that the number is formatted legally, then your program will actually convert the number to its decimal equivalent using the values for each digit given above. You do not need to test for incorrect ordering of digits (ie EESB) but you should say that a Martian numeral is invalid if the user has included a character that is NOT a valid Martian digit (ie EESJ). Design: I have written some pseudo-code for the main program on the next page. It is up to you to write the actual code for the main program and you must write and use at least one function in your main program. One useful function might be a convert_digit function that takes one char as input and returns the integer equivalent of that one Roman Numeral using a switch statement. You could potentially use this function in more than one place in your program, or structure the program to also return a bool statement. Pseudo-code: int main() { string martian_number; loop as long as the user wants to keep going user inputs a string into martian_number if (martian_number is legally formatted) convert the martian_number to decimal digits and output result else output a mesage saying it was illegally formatted ask the user if they want to convert another martian number to decimal } For instance if the user types in EEWWS your program should say that it is formatted improperly (because there are 2 Ws). If the user types in EEWS then your program should output: EEWS is equal to 206 in decimal digits What to submit: You should turn in your commented C++ code. Also turn in a short explanation of the test cases you used to assure yourself that your program is functioning correctly. You should explain the results from at least 5 test cases that you try. Note that if you point out a flaw in your program you will still get full credit for the writeup and lose points on the program only. However, if we discover an error that you didnt test then you will lose points for the writeup and the program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago