CSCI 140 Project 3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

CSCI 140 PROJECT 3

__________________________________________________________
Introduction to Programming Fundamentals with C++ Programming
Project 3

Remember, projects take longer than regular labs do and there is no dedicated lab time for
the projects. I highly recommend starting to work on the projects as soon as you get them and
working on them regularly so you don’t get stuck and forget about them. Neither I nor your
TA may be around at the 23rd hour and it is not our responsibility if you need help and we are
not available the night or the weekend the project is due so work ahead and ask questions
before you need help.
Remember to ask your instructor or TA for help, copying any code from another student or
the internet is against the University dishonesty policy and will result in failing the course.

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..... it’s 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 on Canvas, 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.

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:


1. The symbols used are @, Z, E, &, B, W, S which equate to 1000, 500, 100, 50, 10, 5, and 1
respectively.

2. Martian numerals are written using the symbols above such that the value of these symbols as
you read from left to right never increases. For example: EE is translated as 200.

3. There can never be more than 4 @’s, 1 Z, 4 E’s, 1 &, 4 B’s, 1 W, or 4 S’s because then the
representation is not minimal (e.g. 5 B’s 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
©2017, WWU University, All Rights Reserved
CSCI 140 PROJECT 3
__________________________________________________________
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 below. 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 number using a switch statement. You could potentially use this
function in more than one place in your program, or structure the function 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 message 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 W’s). If the user types in EEWS then your program should output:
EEWS is equal to 206 in decimal digits

©2017, WWU University, All Rights Reserved


CSCI 140 PROJECT 3
__________________________________________________________

Define any other variables you decide are necessary for this program. During
execution, the program must:
 No global variables are allowed.
 Remember all constants must be in all caps. Review the other naming conventions in the lab
manual as well.
 No ‘\n’ allowed, only endl
 The only string function allowed is .length(), otherwise, no pre-defined string, cstdlib or
array functions are allowed, like toupper (), if you are unsure of whether or not you
can use one, and would like to, ask the instructor first
 Display a program description of what the program will do.

NOTE: All numeric values should be aligned right.

Documentation

1) For each program, be sure to include top of program comments (as specified in course lab
manual and syllabus) that include:
a) Your name, the course, and the assignment number
b) What the Program Does including:
o What is Input
o Processing/Calculations Performed
o What is Output

©2017, WWU University, All Rights Reserved


CSCI 140 PROJECT 3
__________________________________________________________

2) Include clarifying comments beside constants and variable declarations, and in-line, as needed.

Submission

This programming assignment is due by midnight Friday, March 16th.


Your code must follow the Coding Standards from the CS140 Lab Manual.

Submit your program source code to the Project 3 folder in the Canvas area of the online
course.

Before submitting your program files, you MUST name them as follows:
Lastname-proj3.cpp

For example:
Smith-proj1.cpp

Grading

The rubric that will be used to grade your program is included on the next pages.

©2017, WWU University, All Rights Reserved


CSCI 140 PROJECT 3
__________________________________________________________

CS 140 Lab Assignment Rubric


Program 1: (100 pts)
Rating Exemplary Partially Proficient Basic (needs work) Not Demonstrated
Rating Category
Documentation Top of program comments include: One of the following is missing Documentation has multiple No comments in program.
Student name, course, and or incorrect: Student name, problems with incomplete and/or
assignment number, along with a course, assignment number, or incorrect items.
brief description that clearly explains
description, OR description is too
what the program will do. vague.
Output Display Output matches program Output display has one or two Output display has many No output is displayed.
requirements sample exactly. minor differences from the differences from the program
program requirements sample. requirements sample.
C++ Constructs / Demonstrates understanding of Code is fairly easy to read, but Code is difficult to read or has A multitude of minor errors or
Readability / program structure. Code is organized there are some spacing, other major issues. One or two one or more major errors
Compiles / and easy to follow, with no issues. indentation, and/or other minor small errors prevent the code prevents the code from
Miscellaneous There is no unnecessary code and issues, or extraneous code. Code from compiling. compiling.
code compiles correctly. compiles correctly.
Decision Structures Program correctly identifies which Program correctly identifies Many decision structures are No decision structure
the string and converts to int which calculation to choose but incorrect causing some in program
properly; counts the correct number the if or decision structure is not calculations to be incorrect OR
of each char as well efficient and separated instead of completely incorrect decision
one large decision structure structure OR is too inefficient.

©2017, WWU University, All Rights Reserved


CSCI 140 PROJECT 3
__________________________________________________________

Loop/Menu Asks the user for the data and loops Loops created but does not loop Missing one or two of the loops no loops provided
until all chars are read and counted; around correctly, may end after or menu OR does not stop
Correct loop structure implemented an extra data member is entered looping correctly at all.
or require a second pass to get the
ending value.

Program Input / text Displays descriptive prompt(s) Reads the required input Some kind of prompt issued and Fails to read required input.
files indicating what the user needs to correctly, but does not display data read, but not stored into Hardcoded values used to
provide, and reads the required input appropriate prompt(s) indicating correct variable, or other issues obtain the results or no results
correctly from the text files. what data the user needs to preventing proper use of input obtained.
provide OR reads unnecessary data.
extra input.
Program Logic / The program logic accomplishes all One mathematical equation Multiple mathematical equations Program logic /calculations
Calculations program requirements. Mathematical computes incorrect results, or the compute incorrect results OR accomplish few or none of the
equations compute the correct program logic does not program uses input or hardcoded program requirements.
results. accomplish one of the program value(s) instead of performing a
requirements. computation.
Compilation Code compiles correctly. One or two minor error prevents Multiple minor errors prevent the One or more major errors or a
the code from compiling. code from compiling. multitude of minor errors
prevent the code from
compiling.

©2017, WWU University, All Rights Reserved

You might also like