C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 7th, 2012, 10:54 AM
archael07 archael07 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 15 archael07 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 20 m 31 sec
Reputation Power: 0
Please Help!!!

this was running before, but after some tweaking it is now asking for another while at the end...i checked and it should be sufficient, am not sure whats happening




Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<iostream>
#include<ctype.h>
#define br 800
#define sqlot 500
#define sqfl 600
#define lot1 1000
#define lot2 1500
#define lot3 2000
#define lot4 2500
#define lot5 3000
main()
{
    do
    {
    char opt,rerun;
    int count,L,F,LA,FA,Bed1,Bed2,Bed3,TB,TotExp;
    system("cls");
    printf("This program will calculate the expense of building a house.");
    printf("\nAlways verify choice before proceeding.");
    getch();
    system("cls");
    printf("\nInput the required input then press[ENTER] key...");
    printf("\nPressing an incorrect input will require you to select again...");
    getch();
    system("cls");
                  do
                  {
                    do
                    {             
                               printf("Please select desired lot by pressing the corresponding number");
                               printf("\n[1]Sampaguita Drive");
                               printf("\n[2]Mahogany Boulevard");
                               printf("\n[3]Diamond Street");
                               printf("\n[4]Moon Valley");
                               printf("\n[5]Heaven's Gate:\t");
                               scanf("%d",&L);
                    }
                    while((opt=='n')||(opt=='N')||((L>!0)&&(L<!6)));
                    if(L==1)
                               printf("\nYou have selected:\tSampaguita Drive %d per square meter",lot1);
                    else if(L==2)
                               printf("\nYou have selected:\tMahogany Boulevard %d per square meter",lot2);
                    else if(L==3)
                               printf("\nYou have selected:\tDiamond Street %d per square meter",lot3);
                    else if(L==4)
                               printf("\nYou have selected:\tMoon Valley %d per square meter",lot4);
                    else if(L==5)
                               printf("\nYou have selected:\tHeaven's Gate %d per square meter",lot5);
                    else
                               printf("\nInvalid choice");break;
                                          
    printf("\nAre you sure?");
    printf("\nEnter [n] to go back, [y] to proceed:\t");
    scanf("%c",&opt);
                 }                               
                 while((opt=='n')||(opt=='N'));                         
    
    do
    {
                  do
                  {
                  printf("\nNow enter desired lot area:\t");
                  printf("\nMAXIMUM OF 500 square meters\t");
                  scanf(" %d",&LA);
                  printf("\nYou have entered %d",LA);
                  }
                  while((LA>!0)&&(LA<!501));                  
    printf("\nAre you sure?");
    printf("\nEnter [n] to go back, [y] to proceed:\t");
    scanf(" %c",&opt);
    }
    while((opt=='n')||(opt=='N'));
    
    return 0;                            
    getch();           
    system("cls");
    do
    {
                  do
                  {
                  printf("\nNow enter desired floor area:\t");
                  scanf(" %d",&FA);
                  }
                  while((FA>!0)&&(LA<!FA));
    printf("\nYou have selected%d square meters",FA);
    printf("\nAre you sure?");
    printf("\nEnter [n] to go back, [y] to proceed:\t");
    scanf(" %c",&opt);
    getch();
    }
    while((opt=='n')||(opt=='N'));
    return 0;                            
    getch();           
    system("cls");
    do
    {
                  do
                  {
                  printf("MAXIMUN OF 3 FLOORS ONLY");
                  printf("\nNow enter how many floors you wish your house will be:\t");
                  scanf(" %d",&F);
                  }
                  while((F<!3)&&(F>!0));
    printf("\nYou have selected%d floors",F);
    printf("\nAre you sure?");
    printf("\nEnter [n] to go back, [y] to proceed:\t");
    scanf(" %c",&opt);
    getch();
    }
    while((opt=='n')||(opt=='N'));
    return 0;                            
    getch();           
    system("cls");
    do
    {
    switch(F)
             {
             do
             {
                  case 1:
                          do
                          {
                          printf("MAXIMUM OF 10 Bedrooms only per floor");
                          printf("Now enter how many bedrooms you wish your house will be:\t");
                          scanf(" %d",&Bed1);
                          TB=Bed1;
                          }
                          while((Bed1>!0)&&(Bed1<!11));                                 
                  printf("\nYou have selected%d bedroom(s)",TB);                       
                  printf("\nAre you sure?");
                  printf("\nEnter [n] to go back, [y] to proceed:\t");
                  scanf(" %c",&opt);break;
                  }
             while((opt=='n')||(opt=='N'));
             if((opt=='y')||(opt=='Y'))
             break;
             return 0;                            
             getch();           
             system("cls");
             do
             {
                  case 2:
                         do
                         {
                         printf("MAXIMUM OF 10 Bedrooms only per floor");
                         printf("Now enter how many bedrooms you wish your house will be on the first floor:\t");
                         scanf(" %d",&Bed1);
                         printf("Now enter how many bedrooms you wish your house will be on the second floor:\t");\
                         scanf(" %d",&Bed2);
                         TB=Bed1+Bed2;
                         }
                         while(((Bed1>!0)&&(Bed1<!11))||((Bed2>!0)&&(Bed2<!11)));
                  printf("\nYou have selected%d bedroom(s)",TB);
                  printf("\nAre you sure?");
                  printf("\nEnter [n] to go back, [y] to proceed:\t");
                  scanf(" %c",&opt);break;
                  }
             while((opt=='n')||(opt=='N'));
             return 0;                            
             getch();           
             system("cls");
             do
             {
                  case 3:
                         do
                         {
                         printf("Now enter how many bedrooms you wish your house will be on the first floor:\t");
                         scanf(" %d",&Bed1);
                         printf("Now enter how many bedrooms you wish your house will be on the second floor:\t");
                         scanf(" %d",&Bed2);
                         printf("Now enter how many bedrooms you wish your house will be on the third floor:\t");
                         scanf(" %d",&Bed3);
                         TB=Bed1+Bed2+Bed3;
                         }
                         while(((Bed1>!0)&&(Bed1<!11))||((Bed2>!0)&&(Bed2<!11))||((Bed3>!0)&&(Bed3<!11)));
                       printf("\nYou have selected%d bedroom(s)",TB);
                       printf("\nAre you sure?");
                       printf("\nEnter [n] to go back, [y] to proceed:\t");
                       scanf(" %c",&opt);break;
                  }
             while((opt=='n')||(opt=='N'));
             return 0;                            
             getch();           
             system("cls");
    }
    while((opt=='n')||(opt=='N'));
    system("cls");
    TB=Bed1+Bed2+Bed3;
    
    if(L=1)
        
        switch(F)
        {
                 case 1:
                      TotExp=(lot1*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Sampaguita Drive\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break; 
                 case 2:
                      TotExp=(lot1*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Sampaguita Drive\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 3:
                      TotExp=(lot1*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Sampaguita Drive\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 default:
                         printf("Invalid...");
        }
    else if(L=2)
         switch(F)
        {
                 case 1:
                      TotExp=(lot2*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Mahogany Boulevard\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 2:
                      TotExp=(lot2*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Mahogany Boulevard\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 3:
                      TotExp=(lot2*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Mahogany Boulevard\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 default:
                         printf("Invalid...");
        }
    else if(L=3)
         switch(F)
        {
                 case 1:
                      TotExp=(lot3*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Diamond Street\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 2:
                      TotExp=(lot3*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Diamond Street\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 3:
                      TotExp=(lot3*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Diamond Street\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 default:
                         printf("Invalid...");
        }
    else if(L=4)
         switch(F)
        {
                 case 1:
                      TotExp=(lot4*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Moon Valley\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 2:
                      TotExp=(lot4*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Moon Valley\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 3:
                      TotExp=(lot4*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Moon Valley\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 default:
                         printf("Invalid...");
        }
    else if(L=5)
         switch(F)
        {
                 case 1:
                      TotExp=(lot5*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Heaven's Gate\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 2:
                      TotExp=(lot5*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Heaven's Gate\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 3:
                      TotExp=(lot5*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Heaven's Gate\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 default:
                         printf("Invalid...");
        }
    else
    printf("\nYou selected an invalid lot");
    getch();
    system("cls");
    printf("\nIf you want to run this program again?\t");
    printf("\nEnter [n] to go back, [y] to proceed:\t");
    scanf(" %c",&rerun);
    }
    while((rerun=='y')||(rerun=='Y'));
    getch();
    return 0;
}                        
              


this one runs but mess up at the end...skips the part where is should display all choices made

Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<iostream>
#include<ctype.h>
#define br 800
#define sqlot 500
#define sqfl 600
#define lot1 1000
#define lot2 1500
#define lot3 2000
#define lot4 2500
#define lot5 3000
int main()
{
    char opt,rerun;
    int count,L,F,LA,FA,Bed1,Bed2,Bed3,TB,TotExp;
    system("cls");
    printf("This program will calculate the expense of building a house.");
    printf("\nAlways verify choice before proceeding.");
    getch();
    system("cls");
    printf("\nInput the required input then press[ENTER] key...");
    printf("\nPressing an incorrect input will require you to select again...");
    getch();
    system("cls");
    do
    {              
    do
    {
    printf("Please select desired lot by pressing the corresponding number");
    printf("\n[1]Sampaguita Drive");
    printf("\n[2]Mahogany Boulevard");
    printf("\n[3]Diamond Street");
    printf("\n[4]Moon Valley");
    printf("\n[5]Heaven's Gate:\t");
    scanf("%d",&L);
    
        switch(L)
                 {
                 case 1:
                      printf("\nYou have selected:\tSampaguita Drive %d per square meter",lot1);break;
                 case 2:
                      printf("\nYou have selected:\tMahogany Boulevard %d per square meter",lot2);break;
                 case 3:
                      printf("\nYou have selected:\tDiamond Street %d per square meter",lot3);break;
                 case 4:
                      printf("\nYou have selected:\tMoon Valley %d per square meter",lot4);break;
                 case 5:
                      printf("\nYou have selected:\tHeaven's Gate %d per square meter",lot5);break;
                 default:
                         printf("\nInvalid choice");break;
                 }   
    printf("\nAre you sure?");
    printf("\nEnter [n] to go back, otherwise input any character:\t");
    scanf(" %c",&opt);         
    }
    while((opt=='n')||(opt=='N')||(isalpha(L))||((L<=0)||(L>5)||(ispunct(L))));
    system("cls");
    do
    {
    printf("\nNow enter desired lot area:\t");
    printf("\nMAXIMUM OF 1000 square meters\t");
    scanf(" %d",&LA);
    if((LA>0)&&(LA<=1000))
                {
                 printf("\nYou have selected %d square meters",LA);
                 
                }
    else 
         {
         printf("\nInvalid, returning to selection");
         }
    printf("\nAre you sure?");
    printf("\nEnter [n] to go back, otherwise input any character:\t");
    scanf(" %c",&opt);
    }
    while((opt=='n')||(opt=='N')||(isalpha(LA))||(LA>1000)||(LA<=0)||(ispunct(LA)));
    system("cls");
    do
    {
    printf("\nNow enter desired floor area:\t");
    scanf(" %d",&FA);
    if((FA>0)&&(FA<=1000))
         {
         printf("\nYou have selected %d square meters",FA);
         }
    else
          {
          printf("\nInvalid, returning to selection");
          }
    printf("\nAre you sure?");
    printf("\nEnter [n] to go back, otherwise input any character:\t");
    scanf(" %c",&opt);
    }
    while(((opt=='n')||(opt=='N'))||(FA>LA)||(FA<=0)||(isalpha(FA))||(ispunct(FA)));
    system("cls");
    do
    {
    printf("MAXIMUN OF 3 FLOORS ONLY");
    printf("\nNow enter how many floors you wish your house will be:\t");
    scanf(" %d",&F);
    switch(F)
             {
                    case 1:case 2:case 3:
                         printf("\nYou have selected %d floors",F);break;
                    default:
                    printf("\nInvalid Input");
             }

    printf("\nAre you sure?");
    printf("\nEnter [n] to go back, otherwise input any character:\t");
    scanf(" %c",&opt);
    }
    while(((opt=='n')||(opt=='N'))||(F>3)||(F<=0)||(isalpha(F))||(ispunct(F)));
    system("cls");
    do
    {
    switch(F)
             {
             case 1:
                  do
                  {
                  printf("Now enter how many bedrooms you wish your house will be:\t");
                  scanf(" %d",&Bed1);
                  TB=Bed1;
                  if(Bed1>0)
                       {
                       printf("\nYou have selected%d bedroom(s)",TB);
                       }
                  else
                        {
                        printf("\nInvalid, returning to selection");
                        }                                         
                       printf("\nYou have selected %d bedroom(s)",TB);                       
                       printf("\nAre you sure?");
                       printf("\nEnter [n] to go back, otherwise input any character:\t");
                       scanf(" %c",&opt);break;
                  }
                  while((opt=='n')||(opt=='N')||(isalpha(Bed1))||(ispunct(Bed1))||(Bed1<0));
             case 2:
                  do
                  {
                  printf("Now enter how many bedrooms you wish your house will be on the first floor:\t");
                  scanf(" %d",&Bed1);
                  if(Bed1>0)
                        {
                            printf("Now enter how many bedrooms you wish your house will be on the second floor:\t");\
                            scanf(" %d",&Bed2);
                            TB=Bed1+Bed2;
                            if(Bed2>0)
                                      {
                                      printf("\nYou have selected%d bedroom(s)",TB);
                                      }
                            else
                                      {
                                      printf("\nInvalid, returning to selection");
                                      } 
                        }       
                   else    
                                {
                                printf("\nInvalid, returning to selection");
                                }
                       printf("\nAre you sure?");
                       printf("\nEnter [n] to go back, otherwise input any character:\t");
                       scanf(" %c",&opt);break;
                  }
                  while((opt=='n')||(opt=='N')||(isalpha(Bed1))||(isalpha(Bed2))||(ispunct(Bed1))||(ispunct(Bed2))||(B  ed1<0)||(Bed2<0));
             case 3:
                  do
                  {
                  printf("Now enter how many bedrooms you wish your house will be on the first floor:\t");
                  scanf(" %d",&Bed1);
                  if(isalpha(Bed1)||(ispunct(Bed1))||(Bed1<0))
                        {
                                  printf("\nInvalid, returning to selection");
                                  }               
                  else;
                       {
                       printf("Now enter how many bedrooms you wish your house will be on the second floor:\t");
                       scanf(" %d",&Bed2);
                       }
                  if(isalpha(Bed2)||(ispunct(Bed1))||(ispunct(Bed2))||(Bed1<0)||(Bed2<0))
                        {
                                  printf("\nInvalid, returning to selection");
                                  }
                  else;
                       {
                       printf("Now enter how many bedrooms you wish your house will be on the third floor:\t");
                       scanf(" %d",&Bed3);
                       }
                  TB=Bed1+Bed2+Bed3;
                  if(isalpha(Bed3)||(ispunct(Bed1))||(ispunct(Bed2))||(ispunct(Bed3))||(Bed1<0)||(Bed2<0)||(Bed3<0))
                        {
                                  printf("\nInvalid, returning to selection");
                                  }
                  else;
                       {
                       printf("\nYou have selected %d bedroom(s)",TB);
                       }
                       printf("\nAre you sure?");
                       printf("\nEnter [n] to go back, otherwise input any character:\t");
                       scanf(" %c",&opt);break;
                  }
                  while((opt=='n')||(opt=='N')||(isalpha(Bed1))||(isalpha(Bed2))||(isalpha(Bed3))||(ispunct(Bed1))||(i  spunct(Bed2))||(ispunct(Bed3))||(Bed1<0)||(Bed2<0)||(Bed3<0));
             default:
                     printf("Invalid Input");
             }
    }
    while((opt=='n')||(opt=='N'));
    system("cls");
    TB=Bed1+Bed2+Bed3; /*it skips this part onwards*/
    if(L==1) 
                      switch(F)
            {
                 case 1:
                      TotExp=(lot1*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Sampaguita Drive\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break; 
                 case 2:
                      TotExp=(lot1*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Sampaguita Drive\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break;
                 case 3:
                      TotExp=(lot1*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Sampaguita Drive\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break;
                 default:
                         printf("Invalid...");break;break;
                 getch();
            }
    else if(L==2)          
                 switch(F)
           {
                 case 1:
                      TotExp=(lot2*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Mahogany Boulevard\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break;
                 case 2:
                      TotExp=(lot2*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Mahogany Boulevard\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break;
                 case 3:
                      TotExp=(lot2*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Mahogany Boulevard\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break;
                 default:
                         printf("Invalid...");break;
                         getch();
                         }
    else if(L==3)
                  switch(F)
        {
                 case 1:
                      TotExp=(lot3*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Diamond Street\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break;
                 case 2:
                      TotExp=(lot3*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Diamond Street\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break;
                 case 3:
                      TotExp=(lot3*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Diamond Street\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break;
                 default:
                         printf("Invalid...");break;
                         getch();
        }
    else if(L==4)
                 switch(F)
        {
                 case 1:
                      TotExp=(lot4*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Moon Valley\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break;
                 case 2:
                      TotExp=(lot4*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Moon Valley\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;
                 case 3:
                      TotExp=(lot4*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Moon Valley\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;
                 default:
                         printf("Invalid...");break;
                         getch();
        }
    else if(L==5)
                 switch(F)
        {
                 case 1:
                      TotExp=(lot5*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Heaven's Gate\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is %d",TotExp);break;
                 case 2:
                      TotExp=(lot5*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Heaven's Gate\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break;
                 case 3:
                      TotExp=(lot5*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Heaven's Gate\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is P%d",TotExp);break;break;
                 default:
                         printf("Invalid...");break;break;
                         getch();
        }
        
    else
        
                         printf("\nYou selected an invalid lot");break;
        getch();
        
    system("cls");
    printf("\nIf you want to run this program again?\t");
    printf("\nPress [Y] to run again, otherwise input any key:\t");
    scanf(" %c",&rerun);
    system("cls");
    }
    while((rerun=='y')||(rerun=='Y'));
    system("cls");
    return 0;
}

Reply With Quote
  #2  
Old December 7th, 2012, 11:23 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,252 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 19 h 31 m 35 sec
Reputation Power: 1985
Quote:
Originally Posted by archael07
... it is now asking for another while at the end.

Are you trying to say that you have a do ... while mismatch?

If you had done a proper and consistent job of indenting your code, you should be able to see almost immediately where you have such mismatches. But your margins are jumping all over the place and your close-braces are not aligned with their mates -- though at least you aren't hiding the open-braces at the ends of or in the middle of lines as so many love to do.

I would recommand formatting your code more consistently and correctly. Barring that, print it out and with pencil physically match each do with its corresponding while.

BTW, there are a number of weird things going on in that code. Such as a switch case under a do. Again, if you were to format your code more consistently and correctly then structural problems like that would be more readily apparent to you. Remember always: formatting your code is more for your own benefit than for the benefit of others.

Reply With Quote
  #3  
Old December 7th, 2012, 11:32 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,252 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 19 h 31 m 35 sec
Reputation Power: 1985
Also, there are several lines like this:
else if(L=4)
That is always going to evaluate to true, because the value of assigning 4 to L is always 4.

If instead of setting L to 4 you were wanting to test whether L had already been set to 4, then you should have instead used the equality relational operator, which is ==.

Remember: single equals assigns; double equals compares.

Reply With Quote
  #4  
Old December 7th, 2012, 11:44 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,252 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 19 h 31 m 35 sec
Reputation Power: 1985
OK, I had to just plain give up on making sense of what you're trying to do.

You have multiple return 0; statements spread throughout your program right in the line of execution. That's absolute nonsense.

But nothing like this:
Code:
    
    return 0;                            
    getch();           
    system("cls");
    
    do
    {
    switch(F)
    {
    do
    {
    case 1:
        do
        {
            printf("MAXIMUM OF 10 Bedrooms only per floor");
            printf("Now enter how many bedrooms you wish your house will be:    ");
            scanf(" %d",&Bed1);
            TB=Bed1;
        } while((Bed1>!0)&&(Bed1<!11));                                 
        printf("\nYou have selected%d bedroom(s)",TB);                       
        printf("\nAre you sure?");
        printf("\nEnter [n] to go back, [y] to proceed:    ");
        scanf(" %c",&opt);
        break;
    }

Just what exactly is that monstrosity supposed to be?

Go back and rewrite all your switch statements correctly!!. It's possible that some of those extra do statements are causing the error message, but that's by far the least of your problems.

Reply With Quote
  #5  
Old December 7th, 2012, 12:02 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,252 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 19 h 31 m 35 sec
Reputation Power: 1985
This is where the entire structure just falls apart:
Code:
        do
        {
        switch(F)
        {
        do
        {
        case 1:
            do
            {
                printf("MAXIMUM OF 10 Bedrooms only per floor");
                printf("Now enter how many bedrooms you wish your house will be:    ");
                scanf(" %d",&Bed1);
                TB=Bed1;
            } while((Bed1>!0)&&(Bed1<!11));                                 
            printf("\nYou have selected%d bedroom(s)",TB);                       
            printf("\nAre you sure?");
            printf("\nEnter [n] to go back, [y] to proceed:    ");
            scanf(" %c",&opt);
            break;
        }
        while((opt=='n')||(opt=='N'));
        if((opt=='y')||(opt=='Y'))
        break;
        return 0;                            
        getch();           
        system("cls");
        do
        {
            case 2:
                do
                {
                    printf("MAXIMUM OF 10 Bedrooms only per floor");
                    printf("Now enter how many bedrooms you wish your house will be on the first floor:    ");
                    scanf(" %d",&Bed1);
                    printf("Now enter how many bedrooms you wish your house will be on the second floor:    ");\
                    scanf(" %d",&Bed2);
                    TB=Bed1+Bed2;
                }
                while(((Bed1>!0)&&(Bed1<!11))||((Bed2>!0)&&(Bed2<!11)));
                printf("\nYou have selected%d bedroom(s)",TB);
                printf("\nAre you sure?");
                printf("\nEnter [n] to go back, [y] to proceed:    ");
                scanf(" %c",&opt);break;
                } while((opt=='n')||(opt=='N'));
            return 0;                            
            getch();           
            system("cls");
        do
        {
            case 3:
                do
                {
                    printf("Now enter how many bedrooms you wish your house will be on the first floor:    ");
                    scanf(" %d",&Bed1);
                    printf("Now enter how many bedrooms you wish your house will be on the second floor:    ");
                    scanf(" %d",&Bed2);
                    printf("Now enter how many bedrooms you wish your house will be on the third floor:    ");
                    scanf(" %d",&Bed3);
                    TB=Bed1+Bed2+Bed3;
                } while(((Bed1>!0)&&(Bed1<!11))||((Bed2>!0)&&(Bed2<!11))||((Bed3>!0)&&(Bed3<!11)));
                printf("\nYou have selected%d bedroom(s)",TB);
                printf("\nAre you sure?");
                printf("\nEnter [n] to go back, [y] to proceed:    ");
                scanf(" %c",&opt);break;
        } while((opt=='n')||(opt=='N'));
        return 0;                            
        getch();           
        system("cls");
        } while((opt=='n')||(opt=='N'));
        
        system("cls");
        
        TB=Bed1+Bed2+Bed3;

Yes, the number of "do" and "while" braces do match up, but they're tearing that switch statement to shreads in the process.

Not only that, but where is the close brace for the switch statement? It doesn't exist, does it?

Reply With Quote
  #6  
Old December 7th, 2012, 12:31 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,252 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 19 h 31 m 35 sec
Reputation Power: 1985
There's a very basic rule/principle/concept that you are forgetting: control structures nest within other control structures.
do-while is a control structure, as is the switch statement. Where a control structure allows you to insert statements, that is where you embed other control structures. However, at no time can one control structure be allowed to violate the structure of another.

For example, here's the overall structure of what I assume you meant to do with that monstrosity:
Code:
        do
        {
            switch(F)
            {
            case 1:
                /* code for case 1 */
                break;
                
            case 2:
                /* code for case 2 */
                break;
                
            case 3:
                /* code for case 3 */
                break;
            } // end switch
            
            getch();           
            system("cls");
        } while((opt=='n')||(opt=='N'));
        
        system("cls");
        
        TB=Bed1+Bed2+Bed3;

The overall control structure is the do-while. Embedded/nested within that control structure is another, a switch statement. And nested within each case can be other control structures, even more do-while loops. However, please note that the nested control structure must end before you get back to the outer control structure. For example, you cannot have the outer while statement before the end of the switch; that would not only make no sense, but would also confuse the compiler. Similarly, if you have two do-while loops, one inside the other, you cannot place the outer loop's while before the inner loop's while. And proper indenting clearly identifies where each control structure is as well as which statements belong to which control structure.

Now, here's what I think you were trying to do (though I had to leave out a few lines that I just could not make sense of):

Code:
        do
        {
            switch(F)
            {
            case 1:
                do
                {
                    do
                    {
                        printf("MAXIMUM OF 10 Bedrooms only per floor");
                        printf("Now enter how many bedrooms you wish your house will be:    ");
                        scanf(" %d",&Bed1);
                        TB=Bed1;
                    } while((Bed1>!0)&&(Bed1<!11));                                 
                    printf("\nYou have selected%d bedroom(s)",TB);                       
                    printf("\nAre you sure?");
                    printf("\nEnter [n] to go back, [y] to proceed:    ");
                    scanf(" %c",&opt);
                } while((opt=='n')||(opt=='N'));
                break;
                
            case 2:
                do
                {
                    do
                    {
                        printf("MAXIMUM OF 10 Bedrooms only per floor");
                        printf("Now enter how many bedrooms you wish your house will be on the first floor:    ");
                        scanf(" %d",&Bed1);
                        printf("Now enter how many bedrooms you wish your house will be on the second floor:    ");\
                        scanf(" %d",&Bed2);
                        TB=Bed1+Bed2;
                    } while(((Bed1>!0)&&(Bed1<!11))||((Bed2>!0)&&(Bed2<!11)));
                    printf("\nYou have selected%d bedroom(s)",TB);
                    printf("\nAre you sure?");
                    printf("\nEnter [n] to go back, [y] to proceed:    ");
                    scanf(" %c",&opt);break;
                } while((opt=='n')||(opt=='N'));
                break;
                
            case 3:
                do
                {
                    do
                    {
                        printf("Now enter how many bedrooms you wish your house will be on the first floor:    ");
                        scanf(" %d",&Bed1);
                        printf("Now enter how many bedrooms you wish your house will be on the second floor:    ");
                        scanf(" %d",&Bed2);
                        printf("Now enter how many bedrooms you wish your house will be on the third floor:    ");
                        scanf(" %d",&Bed3);
                        TB=Bed1+Bed2+Bed3;
                    } while(((Bed1>!0)&&(Bed1<!11))||((Bed2>!0)&&(Bed2<!11))||((Bed3>!0)&&(Bed3<!11)));
                    printf("\nYou have selected%d bedroom(s)",TB);
                    printf("\nAre you sure?");
                    printf("\nEnter [n] to go back, [y] to proceed:    ");
                    scanf(" %c",&opt);break;
                } while((opt=='n')||(opt=='N'));
                break;
            } // end switch
            
            getch();           
            system("cls");
        } while((opt=='n')||(opt=='N'));
        
        system("cls");
        
        TB=Bed1+Bed2+Bed3;

Two nested do-while loops, but contained entirely within their case. Each case is part of the switch structure and must not be violated.

Is that making any sense now?

Reply With Quote
  #7  
Old December 7th, 2012, 12:47 PM
archael07 archael07 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 15 archael07 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 20 m 31 sec
Reputation Power: 0
it is....the unclosed switch case was the problem...hahahha did not see that part, well its past 2 am now haha

Reply With Quote
  #8  
Old December 7th, 2012, 01:24 PM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,905 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 4 Days 1 h 9 m 41 sec
Reputation Power: 1774
The basic problem is your main is too damn long - I counted 300+ lines.
So you can't actually see where the matching { brace is, when you try and place a closing }.

Developing in a modular fashion

So for example, you might have
Code:
do {
  switch ( option ) {
    case 1: doFile(); break;
    case 2: doEdit(); break;
    case 3: doPrint(); break;
    case 4: quit = 1;
  }
} while ( !quit );

which is a nice simple loop that offloads most of the work to other functions.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper

Reply With Quote
  #9  
Old December 7th, 2012, 06:31 PM
archael07 archael07 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 15 archael07 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 20 m 31 sec
Reputation Power: 0
am not sure how you shorten it as we are just starting at school...anyhow, its working as long as user entered expected keys

do you know anything simple that will only accept numbers and reject other inputs esp if its alphabets...

Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<iostream>
#include<ctype.h>
#define br 800
#define sqlot 500
#define sqfl 600
#define lot1 1000
#define lot2 1500
#define lot3 2000
#define lot4 2500
#define lot5 3000
main()
{
      int count;
    for(count=0;count<1000;count++) 
    {
        char opt,rerun;
        int L,F,LA,FA,Bed1,Bed2,Bed3,TB,TotExp;
        system("cls");
        printf("This program will calculate the expense of building a house.");
        printf("\nAlways verify choice before proceeding.");
        getch();
        system("cls");
        printf("\nInput the required input then press[ENTER] key...");
        printf("\nPressing an incorrect input will require you to select again...");
        getch();
        system("cls");
                  do
                  {
                                           printf("Please select desired lot by pressing the corresponding number");
                                           printf("\n[1]Sampaguita Drive");
                                           printf("\n[2]Mahogany Boulevard");
                                           printf("\n[3]Diamond Street");
                                           printf("\n[4]Moon Valley");
                                           printf("\n[5]Heaven's Gate:\t");
                                           scanf(" %d",&L);                                       
                                switch(L)
                                         {
                                           case 1:
                                           printf("\nYou have selected:\tSampaguita Drive %d per square meter",lot1);break;
                                           case 2:
                                           printf("\nYou have selected:\tMahogany Boulevard %d per square meter",lot2);break;
                                           case 3:
                                           printf("\nYou have selected:\tDiamond Street %d per square meter",lot3);;break;
                                           case 4:
                                           printf("\nYou have selected:\tMoon Valley %d per square meter",lot4);break;
                                           case 5:
                                           printf("\nYou have selected:\tHeaven's Gate %d per square meter",lot5);break;
                                           default:
                                           printf("\nInvalid choice");break;
                                         }
                                          
                                printf("\nAre you sure?");
                                printf("\nEnter [n] to go back, [y] to proceed:\t");
                                scanf(" %c",&opt);            
                     }                               
                     while((opt=='n')||(opt=='N')||(L<=0)||(L>=6)||(isalpha(L)));                        
                     system("cls");
                  do
                  {
                                  printf("\nNow enter desired lot area:\t");
                                  printf("\nMAXIMUM OF 500 square meters\t");
                                  scanf(" %d",&LA);
                                  printf("\nYou have entered %d",LA);                                               
                                  printf("\nAre you sure?");
                                  printf("\nEnter [n] to go back, [y] to proceed:\t");
                                  scanf(" %c",&opt);
                  }
                  while((opt=='n')||(opt=='N')||(LA<0)||(LA>500)||(isalpha(LA)));        
                  system("cls");
                do
                {
                              
                                  printf("\nNow enter desired floor area:\t");
                                  scanf(" %d",&FA);
                                  printf("\nYou have selected %d square meters",FA);
                                  printf("\nAre you sure?");
                                  printf("\nEnter [n] to go back, [y] to proceed:\t");
                                  scanf(" %c",&opt);
                                 
                }
                while((opt=='n')||(opt=='N')||(FA<0)||(LA>FA)||(isalpha(FA))); 
                system("cls");
            do
            {
                          printf("MAXIMUN OF 3 FLOORS ONLY");
                          printf("\nNow enter how many floors you wish your house will be:\t");
                          scanf(" %d",&F);
                          printf("\nYou have selected %d floors",F);
                          printf("\nAre you sure?");
                          printf("\nEnter [n] to go back, [y] to proceed:\t");
                          scanf(" %c",&opt);
                          
            }
            while((opt=='n')||(opt=='N')||(F>3)||(F<0)||(isalpha(F))); 
            system("cls");
    
    do
    {
    switch(F)
             {
                  case 1:
                          printf("MAXIMUM OF 10 Bedrooms only per floor");
                          printf("\nNow enter how many bedrooms you wish your house will be:\t");
                          scanf(" %d",&Bed1);
                  printf("\nYou have selected %d bedroom(s)",Bed1);                       
                  printf("\nAre you sure?");
                  printf("\nEnter [n] to go back, [y] to proceed:\t");
                  scanf(" %c",&opt);break;
                  case 2:
                         printf("MAXIMUM OF 10 Bedrooms only per floor");
                         printf("\nNow enter how many bedrooms you wish your house will be on the first floor:\t");
                         scanf(" %d",&Bed1);
                         printf("\nNow enter how many bedrooms you wish your house will be on the second floor:\t");\
                         scanf(" %d",&Bed2);                        
                  printf("\nYou have selected%d bedroom(s)",Bed1+Bed2);
                  printf("\nAre you sure?");
                  printf("\nEnter [n] to go back, [y] to proceed:\t");
                  scanf(" %c",&opt);break;
                  case 3:
                         printf("MAXIMUM OF 10 Bedrooms only per floor");
                         printf("\nNow enter how many bedrooms you wish your house will be on the first floor:\t");
                         scanf(" %d",&Bed1);
                         printf("\nNow enter how many bedrooms you wish your house will be on the second floor:\t");
                         scanf(" %d",&Bed2);
                         printf("\nNow enter how many bedrooms you wish your house will be on the third floor:\t");
                         scanf(" %d",&Bed3);                       
                       printf("\nYou have selected %d bedroom(s)",Bed1+Bed2+Bed3);
                       printf("\nAre you sure?");
                       printf("\nEnter [n] to go back, [y] to proceed:\t");
                       scanf(" %c",&opt);break;
                  default:
                          printf("Invalid Input");
             }
             }
             while(((Bed1<0)||(Bed1>10))||((Bed2<0)||(Bed2>10))||((Bed3<0)||(Bed3>10))||(isalpha(Bed1))||(isalpha(Bed2))||(isalpha(Bed3)));                 
    system("cls");
    if(L==1)
        
        switch(F)
        {
                 case 1:
                      TotExp=(lot1*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Sampaguita Drive\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break; 
                 case 2:
                      TotExp=(lot1*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Sampaguita Drive\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 3:
                      TotExp=(lot1*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Sampaguita Drive\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 default:
                         printf("Invalid...");
        }
    else if(L==2)
         switch(F)
        {
                 case 1:
                      TotExp=(lot2*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Mahogany Boulevard\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 2:
                      TotExp=(lot2*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Mahogany Boulevard\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 3:
                      TotExp=(lot2*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Mahogany Boulevard\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 default:
                         printf("Invalid...");
        }
    else if(L==3)
         switch(F)
        {
                 case 1:
                      TotExp=(lot3*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Diamond Street\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 2:
                      TotExp=(lot3*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Diamond Street\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 3:
                      TotExp=(lot3*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Diamond Street\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 default:
                         printf("Invalid...");
        }
    else if(L==4)
         switch(F)
        {
                 case 1:
                      TotExp=(lot4*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Moon Valley\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 2:
                      TotExp=(lot4*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Moon Valley\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 3:
                      TotExp=(lot4*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Moon Valley\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 default:
                         printf("Invalid...");
        }
    else if(L==5)
                 switch(F)
        {
                 case 1:
                      TotExp=(lot5*LA)+(LA*sqlot)+(FA*sqfl)+(Bed1*br);
                      printf("\nYour chosen lot is at Heaven's Gate\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 2:
                      TotExp=(lot5*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2)*br);
                      printf("\nYour chosen lot is at Heaven's Gate\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 case 3:
                      TotExp=(lot5*LA)+(LA*sqlot)+(FA*sqfl)+((Bed1+Bed2+Bed3)*br);
                      printf("\nYour chosen lot is at Heaven's Gate\nLot Area:%d\nFloor Area:%d\nNumber of Floors:%d\nNUmber of Bedrooms:%d",LA,FA,F,TB);
                      printf("\nThe Price is%d",TotExp);break;
                 default:
                         printf("Invalid...");
        }
    else
            {
            printf("\nYou selected an invalid lot");                             
            }
            getch();          

}
}

Reply With Quote
  #10  
Old December 7th, 2012, 07:07 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,252 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 19 h 31 m 35 sec
Reputation Power: 1985
Quote:
Originally Posted by archael07
do you know anything simple that will only accept numbers and reject other inputs esp if its alphabets...

You're almost doing it already:
scanf(" %d",&Bed1);
Except you're not testing scanf's return value. Read the documentation on scanf -- if you're stuck with that ancient Turbo C compiler, then it should have at least come with the help files that I remember from over 20 years ago. If not, then Google on man page scanf.

Basically, scanf will return how many conversion it completed successfully, which should match the number that you told it to perform. Though it's not perfect ("12abc" would pass, since it would convert the "12" and stop, leaving "abc" in the input buffer).

Reply With Quote
  #11  
Old December 9th, 2012, 05:20 AM
archael07 archael07 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 15 archael07 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 20 m 31 sec
Reputation Power: 0
am not really understanding the part to "test" its return value, but from what I do understand .. would it help if i change this part

if(Bed1==1)
{statement}
else
{statement}

to

if(scanf(" %d",&Bed1)==1)
{statement}
else if(scanf(" %d",&Bed1)==2)
{statement}
else
{statement}

Reply With Quote
  #12  
Old December 9th, 2012, 05:39 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,252 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 19 h 31 m 35 sec
Reputation Power: 1985
Think it through.

scanf(" %d",&Bed1)
attempts to perform a single conversion.

If scanf returns 1, then it succeeded.

If scanf returned any other value, then it failed.

Furthermore, as written, your scanf could only return a 1 or a 0. To test for anything more would be meaningless.

Now consider rewriting that scanf to:
scanf(" %d %d",&Bed1, &Bed2)
In this case, scanf could return 0, 1, or 2.

Now consider rewriting that scanf to:
scanf(" %d %d %d",&Bed1), &Bed2, &Bed3);
In this case, scanf could return 0, 1, 2, or 3.

Do you see that?

Reply With Quote
  #13  
Old December 9th, 2012, 03:10 PM
archael07 archael07 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 15 archael07 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 20 m 31 sec
Reputation Power: 0
how about


Code:
if((scanf(" %d",&Bed1)==1)&&(Bed1==1))
{statement}
else if((scanf(" %d",&Bed1)==1)&&(Bed1==2))
{statement}
else
{statement}



pushing my luck hahhahaha

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Please Help!!!

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap