Advertisements

Monthly Archives: February 2012

C++ program "Rent for your entire life"

#include <iostream>
#include <cmath>

using namespace std;

int main()

{
   int rent, years, age;
   float cost1, months, result1, result2, result3, result4, life;
  
   cout <<“plese enter your age:” << endl;
   cin >> age;

   cout << “plese enter the cost of your rent:” << endl;
   cin >> cost1;

   cout << “enter the number of months left in your lease, or mortgage:” <<endl;
   cin >> months;

   cout << “the amount you will pay over the remainder of your lease or mortgage is:”  << endl;
   result1 = cost1 * months;
  
   cout << result1 << endl;

   cout << “The average life expectancy is 78.1 years;” << endl;
   cout << “The average age of a first time home owner is currently 38 years old” << endl;
   cout << “The amount of money you will pay through out the rest of your life \n(estimated) is:” << endl;
   result3 = age -78.1;
   life = abs(result3);
   result4 = life * 12 * cost1;
   cout << result4 <<endl;
   
  

   cin.get();
   cin.ignore();  
   cout << “Now you know how much money you are spending on living arrangements:”<<endl;
   system (“pause”);
   return 0;

}

Advertisements

New to C++

Hey everyone I’m trying out something here, I’m taking a class in basic c++ programming, if anyone has some knowledge, or websites that might help me along, post them up, as I really would appreciate it.  I will also be attempting to post the code that I write up here in the blog, so check back frequently.  Who knows what my crazy mind might think up:)

debug please

#include <string>
#include <iostream>
using namespace std;

int main()
{
   
  
    int tempNumber, number1, number2, nonNumber; //Declaring the variables
    string string1, string2, tempString;
    float floatNumber; //Declaring the floatnumber
    string name; // Declaring the string name

    number1 = 50;  //setting the number1
    number2 = 30; //setting the number2
    string1 = “First”; //setting the string1
    string2 = “Second”; //setting the string2
    floatNumber = 15.45; //setting the floatNumber
    name = “Mitchell_Meyer”; //setting the name

    cout << “Please Enter a Number(1):” << number1 << endl; //output for number1
    cout << “Please Enter a Number(2):” << number2 << endl; //output for number2
    cout << “Please Enter a string(1):” << string1 << endl; //output for string1
    cout << “Please Enter a string(2):” << string2 << endl; //output for string2
    cout << “Time for the swap:…Right Now” << endl << endl; //output for time of swap

    tempNumber = number1;  //Setting swap for variables
    number1 = number2;  //Setting swap for variables
    number2 = tempNumber;  //Setting swap for variables
    tempString = string1;  //Setting swap for strings
    string1 = string2;  //Setting swap for strings
    string2 = tempString;  //Setting swap for strings

    cout <<“Number 1 is:” << number1 << endl;  // Displaying the swapped number
    cout <<“Number 2 is:” << number2 << endl;  // Displaying the swapped number
    cout <<“String 1 is:” << string1 << endl;  // Displaying the swapped string
    cout <<“String 2 is:” << string2 << endl;  // Displaying the swapped string

    system (“pause”);  //wait for any key to be pressed before exit
    return 0; //end of program
}

%d bloggers like this: