SlideShare a Scribd company logo
Loop example 1
                                      http://eglobiotraining.com.

#include <iostream>
using namespace std;
int main()
{
              int counter = 0; // Initialize counter to 0.
              int numTimes = 0; // Variable for user to enter the amount of times.

             cout << "How many times do you want to see Einstein?: ";
             cin >> numTimes; // This is how many times the loop repeats.

             cout << "n";

             while (counter < numTimes) // Counter is less than the users input.
             {
                          cout << "Einstein!n";
                          counter++; // Increment the counter for each loop.
             }

             cout << "n";

             return 0;
}
Screenshot
                   http://eglobiotraining.com.


/
    *===============================[outpu
    t]====================================
    How many times do you want to see
    Einstein?: 6 Einstein! Einstein! Einstein!
    Einstein! Einstein! Einstein! Press any key to
    continue . . .
    =====================================
    =====================================
    ===*/
Loop Example 2
                                                                    http://eglobiotraining.com.
#include "math.h"
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

using std::cout;
using std::endl;
using std::cin;

//mortgage class//
class Mortgage

{
        public:
        void header();
        void enterprinc();
        double princ;
        double anInt;
        int yrs;
};

//define function//

void Mortgage::header()
{

        cout << "Welcome to Smith's Amortization Calculatornn";
        cout << endl;
        cout << "Week 3 Individual Assignment C++ Mortgage Amortization Calculatornn";
        cout << endl;

}

void Mortgage::enterprinc()
{

        cout << endl;
        cout << "Enter the amount The Mortgage Amount:$";
        cin >> princ;

}
http://eglobiotraining.com.

//main function//
int main ()
{

Mortgage mortgageTotal;

    double princ = 0;
    double anInt [4]= {0, 5.35, 5.5, 5.75,};
    double yrs [4]= {0, 7, 15, 30,};
    double pmt = 0;
    double intPd = 0;
    double bal = 0;
    double amtPd = 0;
    double check(int min, int max);
    int NOP = 0;
    int Mnth = 0;
    int SL = 0;
    char indicator = ('A' ,'a','R','r','D','d');
  int select;
http://eglobiotraining.com.


//Begin Loop
{
     mortgageTotal.header ();
     mortgageTotal.enterprinc ();

             cout<< "Please Enter Your Selection!"<< endl;
             cout<< "Press A to make selection for term of mortgage and interest rate"<<endl;
             cin >> indicator;

                          if (indicator == 'A','a')
                          {

                                          cout << "Please select your Terms and Rates from the following choices: " <<
     endl;
                                          cout << "1. 7 years at 5.35%" << endl;
                                          cout << "2. 15 years at 5.5%" << endl;
                                          cout << "3. 30 years at 5.75%" << endl;
                                          cout << endl;
                                          cout << "What is your selection:";

                                                       select = 0;
                                                       cin >> select;
                                                       cout << endl << endl << endl;
                                                                      switch (select)
                          {
http://eglobiotraining.com.

case 0: cout << endl;
                                  break;
                                  case 1:
                                             yrs[2] = 7;
                                             anInt[2] = 5.35;
                                             cout << "You have selected a 7 year mortgage at 5.35% interest." << endl;
                                             break;

                                  case 2:
                                             yrs[3] = 15;
                                             anInt[3]= 5.50;
                                             cout << "You have selected 15 year mortgage at 5.50 interest%" << endl;
                                             break;

                                  case 3:
                                             yrs[4] = 30;
                                             anInt[4] = 5.75;
                                             cout << "You have selected a 30 year mortgage at 5.75% interest" << endl;
                                             break;

                                  default:
                                             cout << "Invalid Line Number" << endl;
                                             if ((select < 1)|| (select > 3))

                                             {
                                                                   system("cls");
                                                                   cout << "Your choice is invalid, please enter a valid choice!!!";
                                                                   system("PAUSE");
                                                                   system("cls");
                                                                   return main();
                                             }
                        }
                        }
http://eglobiotraining.com.



//Formulas//
double pmt = (mortgageTotal.princ*((anInt[select]/1200)/(1 - pow((1+(anInt[select]/1200)),-1*(yrs[select]*12))))); // notice the variable in the brackets
      that i added.

      cout << "Your Monthly Payment is: $" << pmt << "n";
      cout << endl;

double NOP = yrs [select] * 12;
      SL = 0;
                 for (Mnth = 1; Mnth <= NOP; ++Mnth)
                 {

      intPd = mortgageTotal.princ * (anInt[select] / 1200);
      amtPd = pmt - intPd;
      bal = mortgageTotal.princ - amtPd;
                 if (bal < 0)bal = 0;
                                      mortgageTotal.princ = bal;

                                    if (SL == 0)
                                    {
                                                      cout << "Balance of Loan" << "tttAmount of Interest Paid" << endl;
                                    }

                                                      cout << setprecision(2) << fixed << "$" << setw(5) << bal << "tttt$"<< setw(5) << intPd << endl;
                                                      ++SL;
http://eglobiotraining.com.


//Allows user to decide whether or not to continue//

      if (SL == 12)
      {
                  cout << "Would you like to continue the amoritization or quit the program?n";
                  cout << endl;
                  cout << "Enter 'R' to see the remainder or 'D' for done.n";
                  cin >> indicator;

                                  if
                                                       (indicator == 'R','r')SL = 0;

                                                                           else

                                  if

                                                       (indicator == 'D','d')
                                                       cout << endl;

      }

}

}

return 0;
}
Loop example 3
                                    http://eglobiotraining.com.
#include <iostream>
using namespace std;
int main()
{
     int number = 0; // Variable for user to enter a number.
     int sum = 0; // To hold the running sum during all loop iterations.

    cout << "Enter a number: ";
    cin >> number;

    // Loop keeps adding until it reaches the number entered.
    for (int index = 0; index <= number; index++)
    {
             sum += index; // Each iteration Adds to the variable sum.
    }

    // cout statement is put after the loop.
    cout << "nThe sum of all numbers from 0 to " << number
                       << " equals: " << sum << "nn";

    return 0;
}
Screenshot
                http://eglobiotraining.com.


*===========================[output]====
  =============================== Enter a
  number: 6 The sum of all numbers from 0 to
  6 equals: 21 Press any key to continue . . .
  =====================================
  ===================================*/
Loop example 4
                                                    http://eglobiotraining.com.
#include <iostream>
using namespace std;

int main()
{
    char selection;
    cout<<"n Menu";
    cout<<"n========";
    cout<<"n A - Append";
    cout<<"n M - Modify";
    cout<<"n D - Delete";
    cout<<"n X - Exit";
    cout<<"n Enter selection: ";
    cin>>selection;
     switch(selection)
{
    case 'A' : {cout<<"n To append a recordn";}
           break;
    case 'M' : {cout<<"n To modify a record";}
          break;
    case 'D' : {cout<<"n To delete a record";}
          break;
    case 'X' : {cout<<"n To exit the menu";}
          break;
    // other than A, M, D and X...
    default : cout<<"n Invalid selection";
    // no break in the default case
  }
  cout<<"n";
  return 0;
}
Screenshot
http://eglobiotraining.com.
Loop Example 5
                         http://eglobiotraining.com.

#include <iostream>
using namespace std;

int main ()
{

    for( ; ; )
    {
      printf("This loop will run forever.n");
    }

    return 0;
}
Submitted to:
Professor Erwin Globio
http://eglobiotraining.com/

More Related Content

What's hot

INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
Darwin Durand
 
C programming
C programmingC programming
C programming
Muhammad Hamza
 
Mocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitMocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnit
mfrost503
 
BLOOD DONATION SYSTEM IN C++
BLOOD DONATION SYSTEM IN C++BLOOD DONATION SYSTEM IN C++
BLOOD DONATION SYSTEM IN C++
vikram mahendra
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)
Darwin Durand
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error Examples
Andrey Karpov
 
How Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzerHow Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzer
Andrey Karpov
 
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
SHAJUS5
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
Aqib Memon
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
Aqib Memon
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
Aqib Memon
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
Aqib Memon
 
Computer Science class 12
Computer Science  class 12Computer Science  class 12
Computer Science class 12
Abhishek Sinha
 
Window object methods (timer related)
Window object methods (timer related)Window object methods (timer related)
Window object methods (timer related)
Shivani Thakur Daxini
 
12. stl örnekler
12.  stl örnekler12.  stl örnekler
12. stl örnekler
karmuhtam
 
CSNB244 Lab5
CSNB244 Lab5CSNB244 Lab5
CSNB244 Lab5
Muhd Mu'izuddin
 
Telephone billing system in c++
Telephone billing system in c++Telephone billing system in c++
Telephone billing system in c++
vikram mahendra
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns project
Aayush Mittal
 
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventas
DAYANA RETO
 

What's hot (19)

INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
 
C programming
C programmingC programming
C programming
 
Mocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitMocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnit
 
BLOOD DONATION SYSTEM IN C++
BLOOD DONATION SYSTEM IN C++BLOOD DONATION SYSTEM IN C++
BLOOD DONATION SYSTEM IN C++
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error Examples
 
How Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzerHow Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzer
 
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
 
Atm machine using c++
Atm machine using c++Atm machine using c++
Atm machine using c++
 
Computer Science class 12
Computer Science  class 12Computer Science  class 12
Computer Science class 12
 
Window object methods (timer related)
Window object methods (timer related)Window object methods (timer related)
Window object methods (timer related)
 
12. stl örnekler
12.  stl örnekler12.  stl örnekler
12. stl örnekler
 
CSNB244 Lab5
CSNB244 Lab5CSNB244 Lab5
CSNB244 Lab5
 
Telephone billing system in c++
Telephone billing system in c++Telephone billing system in c++
Telephone billing system in c++
 
Computer mai ns project
Computer mai ns projectComputer mai ns project
Computer mai ns project
 
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventas
 

Similar to Powerpoint loop examples a

Project in programming
Project in programmingProject in programming
Project in programming
sahashi11342091
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solving
Syed Umair
 
Lecture04
Lecture04Lecture04
Lecture04
elearning_portal
 
ch5_additional.ppt
ch5_additional.pptch5_additional.ppt
ch5_additional.ppt
LokeshK66
 
Penjualan swalayan
Penjualan swalayanPenjualan swalayan
Penjualan swalayan
Setiyo Agus Widjaja
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
rohassanie
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
Dendi Riadi
 
Program membalik kata
Program membalik kataProgram membalik kata
Program membalik kata
haqiemisme
 
Ch4
Ch4Ch4
Lecture16
Lecture16Lecture16
Lecture16
elearning_portal
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
Farhan Ab Rahman
 
Object Oriented Programming Using C++: C++ Exception Handling.pptx
Object Oriented Programming Using C++: C++ Exception Handling.pptxObject Oriented Programming Using C++: C++ Exception Handling.pptx
Object Oriented Programming Using C++: C++ Exception Handling.pptx
RashidFaridChishti
 
Programación
ProgramaciónProgramación
Programación
Luci2013
 
FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3
rohassanie
 
Programa Sumar y Multiplicar
Programa Sumar y MultiplicarPrograma Sumar y Multiplicar
Programa Sumar y Multiplicar
Anais Rodriguez
 
Contoh program c++ kalkulator
Contoh program c++ kalkulatorContoh program c++ kalkulator
Contoh program c++ kalkulator
JsHomeIndustry
 
4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf
ShifatiRabbi
 
Computer Science Project on Management System
Computer Science Project on Management System Computer Science Project on Management System
Computer Science Project on Management System
SajidAli643
 
goto dengan C++
goto dengan C++goto dengan C++
goto dengan C++
Achmad Sidik
 
JavaScript Control Statements II
JavaScript Control Statements IIJavaScript Control Statements II
JavaScript Control Statements II
Reem Alattas
 

Similar to Powerpoint loop examples a (20)

Project in programming
Project in programmingProject in programming
Project in programming
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solving
 
Lecture04
Lecture04Lecture04
Lecture04
 
ch5_additional.ppt
ch5_additional.pptch5_additional.ppt
ch5_additional.ppt
 
Penjualan swalayan
Penjualan swalayanPenjualan swalayan
Penjualan swalayan
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
Program membalik kata
Program membalik kataProgram membalik kata
Program membalik kata
 
Ch4
Ch4Ch4
Ch4
 
Lecture16
Lecture16Lecture16
Lecture16
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
Object Oriented Programming Using C++: C++ Exception Handling.pptx
Object Oriented Programming Using C++: C++ Exception Handling.pptxObject Oriented Programming Using C++: C++ Exception Handling.pptx
Object Oriented Programming Using C++: C++ Exception Handling.pptx
 
Programación
ProgramaciónProgramación
Programación
 
FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3
 
Programa Sumar y Multiplicar
Programa Sumar y MultiplicarPrograma Sumar y Multiplicar
Programa Sumar y Multiplicar
 
Contoh program c++ kalkulator
Contoh program c++ kalkulatorContoh program c++ kalkulator
Contoh program c++ kalkulator
 
4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf
 
Computer Science Project on Management System
Computer Science Project on Management System Computer Science Project on Management System
Computer Science Project on Management System
 
goto dengan C++
goto dengan C++goto dengan C++
goto dengan C++
 
JavaScript Control Statements II
JavaScript Control Statements IIJavaScript Control Statements II
JavaScript Control Statements II
 

Recently uploaded

Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Vivekanand Anglo Vedic Academy
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 

Recently uploaded (20)

Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 

Powerpoint loop examples a

  • 1. Loop example 1 http://eglobiotraining.com. #include <iostream> using namespace std; int main() { int counter = 0; // Initialize counter to 0. int numTimes = 0; // Variable for user to enter the amount of times. cout << "How many times do you want to see Einstein?: "; cin >> numTimes; // This is how many times the loop repeats. cout << "n"; while (counter < numTimes) // Counter is less than the users input. { cout << "Einstein!n"; counter++; // Increment the counter for each loop. } cout << "n"; return 0; }
  • 2. Screenshot http://eglobiotraining.com. / *===============================[outpu t]==================================== How many times do you want to see Einstein?: 6 Einstein! Einstein! Einstein! Einstein! Einstein! Einstein! Press any key to continue . . . ===================================== ===================================== ===*/
  • 3. Loop Example 2 http://eglobiotraining.com. #include "math.h" #include <iostream> #include <cmath> #include <iomanip> using namespace std; using std::cout; using std::endl; using std::cin; //mortgage class// class Mortgage { public: void header(); void enterprinc(); double princ; double anInt; int yrs; }; //define function// void Mortgage::header() { cout << "Welcome to Smith's Amortization Calculatornn"; cout << endl; cout << "Week 3 Individual Assignment C++ Mortgage Amortization Calculatornn"; cout << endl; } void Mortgage::enterprinc() { cout << endl; cout << "Enter the amount The Mortgage Amount:$"; cin >> princ; }
  • 4. http://eglobiotraining.com. //main function// int main () { Mortgage mortgageTotal; double princ = 0; double anInt [4]= {0, 5.35, 5.5, 5.75,}; double yrs [4]= {0, 7, 15, 30,}; double pmt = 0; double intPd = 0; double bal = 0; double amtPd = 0; double check(int min, int max); int NOP = 0; int Mnth = 0; int SL = 0; char indicator = ('A' ,'a','R','r','D','d'); int select;
  • 5. http://eglobiotraining.com. //Begin Loop { mortgageTotal.header (); mortgageTotal.enterprinc (); cout<< "Please Enter Your Selection!"<< endl; cout<< "Press A to make selection for term of mortgage and interest rate"<<endl; cin >> indicator; if (indicator == 'A','a') { cout << "Please select your Terms and Rates from the following choices: " << endl; cout << "1. 7 years at 5.35%" << endl; cout << "2. 15 years at 5.5%" << endl; cout << "3. 30 years at 5.75%" << endl; cout << endl; cout << "What is your selection:"; select = 0; cin >> select; cout << endl << endl << endl; switch (select) {
  • 6. http://eglobiotraining.com. case 0: cout << endl; break; case 1: yrs[2] = 7; anInt[2] = 5.35; cout << "You have selected a 7 year mortgage at 5.35% interest." << endl; break; case 2: yrs[3] = 15; anInt[3]= 5.50; cout << "You have selected 15 year mortgage at 5.50 interest%" << endl; break; case 3: yrs[4] = 30; anInt[4] = 5.75; cout << "You have selected a 30 year mortgage at 5.75% interest" << endl; break; default: cout << "Invalid Line Number" << endl; if ((select < 1)|| (select > 3)) { system("cls"); cout << "Your choice is invalid, please enter a valid choice!!!"; system("PAUSE"); system("cls"); return main(); } } }
  • 7. http://eglobiotraining.com. //Formulas// double pmt = (mortgageTotal.princ*((anInt[select]/1200)/(1 - pow((1+(anInt[select]/1200)),-1*(yrs[select]*12))))); // notice the variable in the brackets that i added. cout << "Your Monthly Payment is: $" << pmt << "n"; cout << endl; double NOP = yrs [select] * 12; SL = 0; for (Mnth = 1; Mnth <= NOP; ++Mnth) { intPd = mortgageTotal.princ * (anInt[select] / 1200); amtPd = pmt - intPd; bal = mortgageTotal.princ - amtPd; if (bal < 0)bal = 0; mortgageTotal.princ = bal; if (SL == 0) { cout << "Balance of Loan" << "tttAmount of Interest Paid" << endl; } cout << setprecision(2) << fixed << "$" << setw(5) << bal << "tttt$"<< setw(5) << intPd << endl; ++SL;
  • 8. http://eglobiotraining.com. //Allows user to decide whether or not to continue// if (SL == 12) { cout << "Would you like to continue the amoritization or quit the program?n"; cout << endl; cout << "Enter 'R' to see the remainder or 'D' for done.n"; cin >> indicator; if (indicator == 'R','r')SL = 0; else if (indicator == 'D','d') cout << endl; } } } return 0; }
  • 9. Loop example 3 http://eglobiotraining.com. #include <iostream> using namespace std; int main() { int number = 0; // Variable for user to enter a number. int sum = 0; // To hold the running sum during all loop iterations. cout << "Enter a number: "; cin >> number; // Loop keeps adding until it reaches the number entered. for (int index = 0; index <= number; index++) { sum += index; // Each iteration Adds to the variable sum. } // cout statement is put after the loop. cout << "nThe sum of all numbers from 0 to " << number << " equals: " << sum << "nn"; return 0; }
  • 10. Screenshot http://eglobiotraining.com. *===========================[output]==== =============================== Enter a number: 6 The sum of all numbers from 0 to 6 equals: 21 Press any key to continue . . . ===================================== ===================================*/
  • 11. Loop example 4 http://eglobiotraining.com. #include <iostream> using namespace std; int main() { char selection; cout<<"n Menu"; cout<<"n========"; cout<<"n A - Append"; cout<<"n M - Modify"; cout<<"n D - Delete"; cout<<"n X - Exit"; cout<<"n Enter selection: "; cin>>selection; switch(selection) { case 'A' : {cout<<"n To append a recordn";} break; case 'M' : {cout<<"n To modify a record";} break; case 'D' : {cout<<"n To delete a record";} break; case 'X' : {cout<<"n To exit the menu";} break; // other than A, M, D and X... default : cout<<"n Invalid selection"; // no break in the default case } cout<<"n"; return 0; }
  • 13. Loop Example 5 http://eglobiotraining.com. #include <iostream> using namespace std; int main () { for( ; ; ) { printf("This loop will run forever.n"); } return 0; }
  • 14. Submitted to: Professor Erwin Globio http://eglobiotraining.com/