Project 4
due: 21:00 M 11/19


Project Assistance

"ERROR: Computer possessed; Load EXOR.SYS ? [Y/N]"

Project Requirements

Complete the following requirements in the order given:

  1. The isPrime predicate we covered in class is in a header file, isPrime-fn1.h.Copy it to your local host and store it in /122/include/isPrime-fn1.h.


  2. primeGT.cpp. On paper write and test (hand-trace) a function that meets this specification:
    /* prime_gt( )=================================================
     * returns first prime greater than n
     */
    int primeGT(int n);
    
    Examples:
    cout << primeGT(6);  // displays 7 
    cout << primeGT(13); // displays 17 

    When your function is correct on paper, type it into a Visual C++ file named primeGT.cpp; compile, debug and test. When complete, upload it to /122/p4/primeGT.cpp on shell.uoregon.edu

  3. picAdilly.cpp.

    Let's Make Another Deal!

    Deal #1: You get a stack of pennies equaling your weight.

    Deal #2: You get a stack of quarters equaling your height.

    Write a program that prompts the user for her/his height & weight, and then displays the weight's value as a stack of pennies and the height's value as a stack of quarters.

    Read the U.S. Mint's coin specifications.

    I/O Specification. Generate the following I/O interface:

    enter height (feet, inches) & weight (ctrl-z to exit): 5 6 110
    your weight in pennies:   $199.58  
    your height in quarters:  $239.49
    
    
    enter height(feet, inches) & weight (ctrl-z to exit): 6 2 225
    your weight in pennies:   $408.23   
    your height in quarters:  $268.51 

    enter height(feet, inches) & weight (ctrl-z to exit): [user enters ctrl-z] exiting . .

    How to Solve It

    1. pw-tester.cpp. Create this program to test a function named pennyWeight() that accepts a weight as an argument and returns the value of that amount of pennies. Only after you've completed this program, go on to the next step.
    2. qh-tester.cpp. Create this program to test a function named quarterHeight() that accepts a height as an argument and returns the value of a stack of quarters of that height.
    3. Now you can copy your function definitions into picAdilly.cpp; compile it, debug and test.

    When complete, upload pw-tester.cpp, qh-tester.cpp and picAdilly.cpp to /122/p4/ on shell.uoregon.edu.


  4. verb1digit.cpp: 'Verbalise' a one-digit number.

    On p3-B, we generated large numbers that are a challenge to verbalise. Now we will see how to write a C++ that can 'verbalise large number names.

    On paper,write a function that meets this specification.
    /* verb1digit() ========================================
     * returns the 'verbalised' form of the digit n
     */
    string verb1digit(n);
    Examples: cout << verb1digit(7); //displays seven cout << verb1digit(0); //displays zero

    When complete, upload verb1digit.cpp to /122/p4/ on shell.uoregon.edu.


  5. verbteen.cpp. 'Verbalising' a two-digit number in the teens.

    On paper,write a function that meets this specification.
    /* verbteen() ========================================
     * returns the 'verbalised' form of the number n
     * 10 < = n < = 19
     * teen-names (thirteen, fourteen, ..) come from when 
     * Europeans used to count in scores rather than tens)
     */
    string verbteen(n);
    
    Examples: 
    alert(verbteen(10)) displays ten
    alert(verbteen(17)) displays seventeen
      

    When complete, upload verbteen.cpp to /122/p4/ on shell.uoregon.edu.


  6. verb2digit.cpp. 'Verbalising' a two-digit number.

    On paper,write a function that meets this specification. Be careful to handle trailing zeroes correctly.
    /* verb2digit() ========================================
     * returns the 'verbalised' form of the number n
     */
    string verb2digit(n)
    
    
    Examples: 
    cout << verb2digit(67);   //displays sixty-seven
    cout << verb2digit(60);   //displays sixty (not sixty-zero)
    cout << verb2digit(17);   //displays seventeen 
    cout << verb2digit(5);    //displays five
      
    Note: verb2digit() is a client of (i.e., calls) verb1digit() and verbteen().

    When complete, upload verb2digit.cpp to /122/p4/ on shell.uoregon.edu.


  7. Verbalising a three-digit number.

    Save verb2digit.cpp as verbalizeNum.cpp

    Add a function that meets the following specification; compile, test and debug.
    /* verb3digit() ========================================
     * returns the 'verbalised' form of the number n
     */
    string verb3digit(n);
    
    
    Examples: 
    cout << verb3digit(416)  //displays four hundred and sixteen
    cout << verb3digit(260)  // displays two hundred and sixty 
    cout << verb3digit(200)  // displays two hundred
    cout << verb3digit(60);  //displays sixty (not sixty-zero)
    cout << verb3digit(5);   //displays five
    
      

    Note: verb2digit() is a client of (i.e., calls) verb1digit(), verb1digit() and verbteen().

    When complete, upload verbalizeNum.cpp to /122/p4/ on shell.uoregon.edu.


  8. Extra Credit Option (5 pts added directly to your p4 score). If (and only if) and when you have completed all the above requirements correctly and if you still have time to budget to this project, add a verbalise function to verbaliseNum.cpp that handles all numbers in the range 0..9999:
    
    Examples: 
    verbalise(1111) ==> one thousand one hundred and eleven
    verbalise(4110) ==> four thousand one hundred and ten
    verbalise(4100) ==> four thousand one hundred
    verbalise(4000) ==> four thousand
    verbalise(4002) ==> four thousand and two
    verbalise(4020) ==> four thousand and twenty
    verbalise(4202) ==> four thousand two hundred and two
    verbalise(202)  ==> two hundred and two
    verbalise(82)   ==>  eighty-two
    verbalise(0)    ==>  zero
      


  9. Optional Extra Credit Options:

    A) verbalize.cpp: +5.



    B) "Early" Turn In: +5.



  10. Project 4 Grading Rubric. This document describes how your lab instructor (GTF) will grade your project. You should assess your project using this rubric before turning in your project. Also, this would be a good exercise for each member of your VLT: assess each other's work using this rubric before submitting it.


  11. How to Submit your Project for Grading.