Code:
/* Rob - Home.c */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
void process(); // call for process function
void intro(); // call for intro function
void roof(); // call for roof function
void floors(); // call for floors function
void ground(); // call for ground function
void sidingType(); // 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: Rob's 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 Rob's 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
intro(); // starting intro and objective
sidingType(); // call for siding type and conversion
roof(); // call for roof
floors(); // call for floors including loop
ground(); // call for ground
} // end process
void intro() // intro & objective, and call for floor number
{
int numFloors ; //number of floors
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");
} //end intro
void sidingType() // siding menu and concversion to type char
{ //start sidingType
char siding; // initializing characer for left side
char siding2; // initializing characer for right side
int sidingChoice; // storing siding preference
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 (Lincoln 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() // function roof
{ // start roof
int numFloors; //number of floors
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 /|___|___|___|___|\\_|| \n");
printf("\t /__|TOTAL FLOORS|___\\_| \n");
printf("\t /__|___|_ _|___|__\\| \n" );
printf("\t /_|___|___|___|___|___|_\\ \n");
printf("\t /-------------------------\\ \n");
} //end roof
void floors() //function floors with loop for # of floors
{
char siding; // initializing characer for left side
char siding2; // initializing characer for right side
int floorCount = 1; // initializing counter to 1
int numFloors =0; //number of floors
for( floorCount>1; floorCount < numFloors; 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 %c\n", siding, siding2);
printf("\t %c %c\n", siding, siding2);
printf("\t %c-------------------------%c\n", siding, siding2);
} //end floor
} // end floors
void ground() // function ground
{ // start ground
char siding; // initializing characer for left side
char siding2; // initializing characer for right side
char play; // initializing characer for play
printf("\t %c %c\n", siding, siding2);
printf("\t %c GROUND FLOOR %c\n", siding, siding2);
printf("\t %c 1 %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|' ' / \\. ~ '|Rob | \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 Rob's Construction.\n");
printf("\tDon't forget to tell your friends about us!\n\n");
system("PAUSE");
} //end else
} // end ground