Thread: cin statement skipping

  1. #1
    Registered User
    Join Date
    Oct 2014
    Posts
    1

    cin statement skipping

    when run, program is skipping over cin statements where data should be entered

    Code:
    /*
        Programmer:            Joe Difilippo
        Userid:                Jdifilip
        Section:            091
        Assignment:            Program 2
        Purpose:            This program determines whether or not an applicant qualifies to receive a home loan based on his/her ability to repay a mortgage.
    
    */
    
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        int house;
        double downPayment;
        char county;
        int age;
        char military;
        double annualLoan;
        double annualPropertyTax;
        const double INTEREST_RATE = .05;
        int Insurance;
        double annualIncome;
        double monthlyOtherDebt;
        double yearlyOtherDebt;
        double annualDebt;
        double annualHouseLoan;
        char Mecklenburg;
        char Cabarrus;
        double annualPrivateMortgage;
        double annualBaseLoan;
        char yes;
    
        cout << "How much is the desired house? " << endl;
        cin >> house;
    
         if (house >= 50000) {
            Insurance = (house % 50000) * 250;
         }
            else {
                if (house < 50000) {
                Insurance = 250;
                }
            }
    
        cout << "How much will you pay up front? " << endl;
        cin >> downPayment;
    
         if (downPayment < (.2 * house)) {
           annualPrivateMortgage = 1.12 * annualLoan;
        }
        else {
            if (downPayment >= (.2 * house)) {
                annualPrivateMortgage = 1 * annualLoan;
            }
        }
    
        cout << "Do you live in Mecklenburg or Cabarrus county? " << endl;
        cin >> county;
    
         if (county = Mecklenburg) {
            annualPropertyTax = .015 * house;
        }
        else {
            if (county = Cabarrus) {
            annualPropertyTax = .012 * house;
            }
        }
    
        cout << "How old are you? " << endl;
        cin >> age;
    
        cout << "Are you currently in the military? (Enter yes or no)" << endl;
        cin >> military;
    
        cout << "What is your annual gross income? " << endl;
        cin >> annualIncome;
    
        cout << "How much do you pay each month for other debt? " << endl;
        cin >> monthlyOtherDebt;
    
         if ((county = Cabarrus) && (age > 65 || military = yes)) {
            annualPropertyTax = (annualPropertyTax * .998);
        }
    
        yearlyOtherDebt = monthlyOtherDebt * 12;
        annualHouseLoan = house/20;
    
        annualBaseLoan = (Insurance + annualPropertyTax + annualHouseLoan);
        annualLoan = (annualBaseLoan * annualPrivateMortgage) + (annualBaseLoan * INTEREST_RATE);
        annualDebt = yearlyOtherDebt + (annualBaseLoan * annualPrivateMortgage) + (annualBaseLoan * INTEREST_RATE);
    
         if ((annualIncome / annualDebt) <= .28) {
            cout << "Your debt to income ratio is: $ " << (annualIncome / annualDebt) << endl;
            cout << "You qualify for mortgage." << endl;
            }
            else {
                if ((annualIncome / annualDebt) > .28) {
            cout << "Your debt to income ratio is: $ " << (annualIncome / annualDebt) << endl;
            cout << " You do not qualify for mortgage." << endl;
            }
        }
    
            return 0;
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,537
    Code:
        cout << "Do you live in Mecklenburg or Cabarrus county? " << endl;
        cin >> county;
     
         if (county = Mecklenburg) {
            annualPropertyTax = .015 * house;
        }
        else {
            if (county = Cabarrus) {
            annualPropertyTax = .012 * house;
            }
        }
    1. how many characters do you think county can hold? How many do you type in?
    2. Do you know the difference between = and ==
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program skipping if statement
    By russiancircles in forum C++ Programming
    Replies: 0
    Last Post: 03-16-2014, 05:55 PM
  2. skipping switch statement
    By psppb in forum C Programming
    Replies: 14
    Last Post: 07-25-2012, 05:43 AM
  3. Replies: 16
    Last Post: 11-30-2011, 09:59 AM
  4. Compiler skipping a statement & moving to nxt instruction
    By MarjunC in forum C++ Programming
    Replies: 8
    Last Post: 06-29-2010, 05:34 AM
  5. Skipping if statement
    By FallenBlade in forum C Programming
    Replies: 6
    Last Post: 12-13-2009, 03:40 PM