Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
void process(); // call for process function
int intro(); // call for intro function
void roof(int numFloors); // call for roof function
void floors(int numFloors, char *siding, char *siding2); // call for floors function
void ground(char *siding, char *siding2); // call for ground function
void sidingType(char *siding, char *siding2); // call for siding type function
int main() // main function
{ // begin intro
char play; // initializing characer for play
printf("\tWelcome to...\n");
printf("\tBUILD YOUR DREAMHOUSE!\n\n");
printf("\tBy: Stokes Construction Co.\n");
printf("\tYou plan it, we build it!\n\n");
printf("\tWant to start planning? y/n "); // prompt for answer from user
scanf("%c", &play); // scanning answer from user
fflush(stdin); // flushing keyboard input
if (play == 'y') // begin if "yes"
{
process(); //call for process
} //end if
else // begin if "no"
{
system("cls"); // clear screen
printf("\t Thanks for using Stokes Construction.\n"); // ending
printf("\tDon't forget to tell your friends about us!\n\n");
system("PAUSE");
return 0; // end program
} // end else
} // end main
void process() // main process
{ // start process
char siding; // initializing characer for left side
char siding2; // initializing characer for right side
int numFloors = 0; // number of floors
int floorCount = 1; // initializing counter to 1
int sidingChoice; // storing siding preference
numFloors = intro(); // starting intro and objective
sidingType(&siding, &siding2); // call for siding type and conversion
roof(numFloors); // call for roof
floors(numFloors, &siding, &siding2); // call for floors including loop
ground(&siding, &siding2); // call for ground
} // end process
int intro() // intro & objective, and call for floor number
{
int numFloors = 0;
system("cls");
printf("\t\t BUILD YOUR OWN HOME!!\n\n"); //start objective
printf("\tThe purpose of this program is to demonstrate the four ways to use\n");
printf("\ta function(), Switch/Case and pointers. This project will finish the\n");
printf("\tintroduction of Structure, Selection and Looping you learned in\n");
printf("\tCOP1000 Data structures and Algorithms class and apply how it\n");
printf("\tapplies to the C programming language.\n\n");
printf("\tThis program asks you for the number of floors, and type of siding\n\n");
printf("\tHow many floors would you like your house to be? "); //prompt for # of floors
scanf("%d", &numFloors); // scan # of floors and add to numFloors
fflush(stdin);
printf("\t\n\n");
return numFloors;
} //end intro
void sidingType(char *siding, char *siding2) // siding menu and concversion to type char
{ // start sidingType
int sidingChoice = 0;
system("cls"); // new screen
printf("\t PLEASE CHOOSE YOUR SIDING TYPE: \n\n"); // siding options
printf("\t \n");
printf("\t 1. Straight (boring) siding | | \n");
printf("\t 2. Brick (hurricane strength) siding [ ] \n");
printf("\t 3. Log (Lincold style) siding ( ) \n");
printf("\t 4. Stucko (too cheap for brick) siding { } \n");
printf("\t 5. X (whatever this is) siding X X \n");
printf("\t 6. Shinge (poop on a) siding / \\ \n\n");
printf("\t Please enter your siding preference: ");
scanf("%d", &sidingChoice); // read user siding preference
fflush(stdin);
printf("\t\n\n");
switch( sidingChoice ) { // start switch for conversion
case 1: *siding = '|'; *siding2 = '|'; break; // conversion to straight
case 2: *siding = '['; *siding2 = ']'; break; // conversion to brick
case 3: *siding = '('; *siding2 = ')'; break; // conversion to log
case 4: *siding = '{'; *siding2 = '}'; break; // conversion to stucko
case 5: *siding = 'X'; *siding2 = 'X'; break; // conversion to x
case 6: *siding = '/'; *siding2 = '\\\'; break; // conversion to shingle
default: printf("Invalid option selected, straight assigned\n"); *siding = '|'; *siding2 = '|';
} // end switch
} // end siding type
void roof(int numFloors) // function roof
{ // start roof
system("cls");
printf("\t \n");
printf("\t ,~ ~~ ,~ ~~~ \n");
printf("\t ,~ ~~ ~ ~~ ,~ ~~~~~ \n");
printf("\t ~~~ ,~ ~ ~~ ~ ~~ \n");
printf("\t ^ ,~ ~~ ,~ ~~~ \n");
printf("\t /_\\ _______ \n");
printf("\t /___\\ |__|__| \n");
printf("\t /__|__\\ |_|__|| \n");
printf("\t /_|___|_\\ |__|__| \n");
printf("\t /|___|___|\\|_|__|| \n");
printf("\t /|__|___|__|\\__|__| \n");
printf("\t /__|___|___|__\\|__|| \n");
printf("\t /_|___|___|___|_\\|__| \n");
printf("\t /|__Total Floors_|\\_|| \n");
printf("\t /___|___ %2.2d ___|___\\_| \n", numFloors);
printf("\t /__|___|___|___|___|__\\| \n");
printf("\t /_|___|___|___|___|___|_\\ \n");
printf("\t /-------------------------\\ \n");
} // end roof
void floors(int numFloors, char *siding, char *siding2) // function floors with loop for # of floors
{
int floorCount = numFloors;
for( floorCount; floorCount > 1; floorCount--) //for loop
{
printf("\t %c %c\n", *siding, *siding2);
printf("\t %c %c\n", *siding, *siding2);
printf("\t %c |---| |---| %c\n", *siding, *siding2);
printf("\t %c | | | | %c\n", *siding, *siding2);
printf("\t %c |---| |---| %c\n", *siding, *siding2);
printf("\t %c %c\n", *siding, *siding2);
printf("\t %c %c\n", *siding, *siding2);
printf("\t %c Floors: %2.2d %c\n", *siding, floorCount, *siding2);
printf("\t %c %c\n", *siding, *siding2);
printf("\t %c-------------------------%c\n", *siding, *siding2);
} // end floor
} // end floors
void ground(char *siding, char *siding2) // function ground
{ // start ground
char play; // initializing characer for play
printf("\t %c %c\n", *siding, *siding2);
printf("\t %c %c\n", *siding, *siding2);
printf("\t %c %c\n", *siding, *siding2);
printf("\t %c /======\\ %c\n", *siding, *siding2);
printf("\t %c |----| %c\n", *siding, *siding2);
printf("\t %c | | %c\n", *siding, *siding2);
printf("\t %c | .| %c\n", *siding, *siding2);
printf("\t %c | | %c \n", *siding, *siding2);
printf("\t @ @ %c | | %c @ @ \n", *siding, *siding2);
printf("\t___|__|___%c-------------------------%c___|__|___ \n", *siding, *siding2);
printf("\t ' . ' . / \\ ' . ' \n");
printf("\t ' ' / \\ . \n");
printf("\t . ~ ' ' / \\ ' ' ' . \n");
printf("\t ' . ./ \\ . . ~ \n");
printf("\t ' ' / \\ ' ' \n");
printf("\t .|Rob|' ' / \\. ~ '|Stokes| \n");
printf("\t================================================ \n\n\n");
printf(" Would you like to build another house? y/n ");
scanf("%c", &play); // read player's response to playing again
fflush(stdin);
if (play == 'y') // if statement for play again
{
process(); // call for prosess
} // end if
else // statement for not playing again
{
system("cls");
printf("\t Thanks for using Stokes Construction.\n");
printf("\tDon't forget to tell your friends about us!\n\n");
system("PAUSE");
} // end else
} // end ground