MCIS-4135
Homework Assignment 4
This assignment is intended to give you some experience with functions in a program, and with basic data types
For each programming assignment, please hand in a hardcopy listing of your code, in a readable, legible, easy to evaluate form, along with the output that your program generates. If your program doesn’t compile for any reason, hand in the error listing from your compiler as the output.
For the essay portions, make your write-ups easy to understand, and concise.
Write a program that outputs 30 asterisks(*) on a single line. Be sure to use a variable to represent the “30”.
Take
problem 1 and create a function called print_asterisks
that puts a number of
asterisks on a line, where the number is passed in as a parameter.
The function should be void—that
is, it does not return a useful value.
Continue by modifying the
main program in three ways.
First, make the main program call
print_asterisks
instead of printing the asterisks itself. Pass in the integer
variable representing the number 30 as the parameter to
print_asterisks.
Second, place a declaration for
the print_asterisks function before the main().
Third,
add another call to print_asterisks in main, after setting
the parameter to 50.
Imagine you would like to create a standard way of manipulating dates for your business ledgers and calendar scheduling. What would be a good way to express the idea of a date? How would you know if a date is valid? What kind of operations would you like to perform on the date?
You will produce two (2) separate main programs for this exercise, one for problem 1, and one for problem 2. Do not combine the exercises, please.
Exercise 1 should be done first. It is easier, and leads to the starting point for exercise 2.
The declaration used in problem 2 is the beginning step in creating functions that can be properly applied by many different programs. Such declarations will be moved to a header file.
For problem 3, think about how your current computer applications deal with dates. Note how they tend to separate what they must represent internally from what they display to the user. About 3 paragraphs (between half a page and a page) should be enough to capture this idea.
.
25 |
Problem 1: Write 30 asterisks |
40 |
Problem 2: Convert the program to having a function and calling the function |
35 |
Problem 3: Describe what you would like in a Date |