~V3N0M~
2012-02-21 11:42:05 UTC
The user should be able to enter integers and see the digits as many times as they want, a negative integer will signal the program to quit.
An input value greater than 999 should trigger the response "Invalid input: try again".
For this program, you should have at least one procedure, called find_digits: Since up to three separate items need to be extracted from the input, and since a function can only return a single value through a return statement, you will instead have to use pass-by-reference parameters to "pass back" the digits.
So your procedure should have a return type of void and take 4 parameters: the number itself (should be a value parameter), and a reference parameter for each digit of the number.
2)Write a program that allows a user to randomly draw two cards and see if they win a prize.
Each card's value (2-10, Jack, Queen, King, and Ace) and suit (hearts, diamonds, spades, and clubs) will be randomly chosen.
You will need to use integer values as codes for those things that are not integers (Jack, Queen, hearts, diamonds, etc.). This will allow you to use the rand() function which only generates integers.
However, when printing the two cards, you should translate the integers into what they are representing. For example, you should output, "You drew a 3 of Hearts.", or "You drew a Jack of spades." Do not output, "You drew a 12 of suit type 2".
Lastly, output whether they win.
A pair (two of the same value (suit doesn't matter)) wins a large prize.
Drawing a Jack (of any suit) wins a small prize.
You should use the library's rand() function from the previous experience to generate your card value (2-10, Jack, Queen, King, Ace) and your suit. You must also write the following functions: translate_card_num, translate_card_type and print_winnings. You may write additional functions if you wish.
3)Write a predicate function that tests whether a year is a leap year
bool leap_year( int year )
A leap year is: a year with 366 days. Leap years are necessary to keep the calendar synchronized with the sun because the earth revolves around the sun once every 365.25 days. Actually, that figure is not entirely precise, and for all dates after 1582 the Gregorian correction applies. Leap years follow some basic rules:
Usually years that are divisible by 4 are leap years, for example 1996.
However, years that are divisible by 100 (for example, 1900) are not leap years.
But years that are divisible by 400 are leap years (for example, 2000).
For more of a challenge, write this function as a single return statement (no if statement(s)).