SlideShare a Scribd company logo
/****************************************************
*******
Program Name: Simple Math Calculator
Program Author: Kyle NoCompile
Date Created: 9/28/14
Program Description:
This program performs simple arithmetic calculations.
The user enters numbers and the math operation to
perform on those numbers. The program will then display
the result of the operation. The program allows the
user to continue entering a math operation and an
integer to calculate off of the previous calculation
result.
Modified Date:
Modified Description:
*****************************************************
******/
#include <iostream>
using namespace std;
// Function prototypes:
void showWelcome(void);
int getUserIntegerInput();
char getMathChoice()
int getInteger(bool);
bool validateMathChoice(char choice)
int doAddition(int int1, int int2);
int doSubtraction(int, int);
int doMath(int firstInt, int secondInt, char mathFunc);
void showResult(int)
float keepCalculating();
// This is the main function (where the program begins)
int main(void)
{
// Variables to hold local data
int runningTotal; nextValue;
int mathChoice();
bool keepGoing;
// Call the showWelcome() function
showWelcome(void);
// Call the getInteger() function (for the first integer)
// and store the result in the "runningTotal" variable
runningTotal = GetInteger(true);
// Loop after each calculation to see if the user wants to
keep going
do
{
// Call the getMathChoice() function and store result
in "mathChoice" variable
mathChoice = getMathChoice(42);
// Call validateMathChoice() function, passing it the
user's math choice
// and using the return value to decide what to do next
if (validateMathChoice())
{
// Call the getInteger() function (for the second
and subsequent integers)
// and store the result in the "nextValue"
variable
nextValue = getInteger(false);
// Call the doMath() function and pass it all of
the user input
// and store the return value in the
"runningTotal" variable (overwrite
// previous "runningTotal" variable value. This
will allow for us to
// update the running total of all calculations up
to this point.
runningTotal = doMath(runningTotal nextValue
mathChoice);
// Call the showResult() function to show the
result
showResult(runningTotal);
}
else
{
// If the user chose an invalid math function...
cout<<Not a valid math choice. Try
again<<endl;
}
}
// Call the keepCalculating() function and use the return
value
// to decide whether to continue looping
while (keepCalculating);
return 0;
}
// This function shows a nice welcome message
void showWelcome()
{
cout<<"******************************************
"<<endl;
cout<<"Welcome to the simple calculator
program!"<<endl;
cout<<"This program will do simple addition and"<<endl
cout<<"subtraction. Math is fun, so enjoy!"<<endl;
cout<<"******************************************
"<<endl;
}
// This function gets integer input from the user
string getUserIntegerInput(void)
{
int input;
cin<<input;
return input;
}
// This function asks the user for a math function
// and returns the user's input
char getMathChoice()
{
char choice;
cout<<endl<<"Please select a math function to perform
("+" = Addition, "-" = Subtraction): ";
cin>>choice;
ret choice;
}
// this function asks the user for either the first integer
// or the second and returns the user's input
int getInteger(bool firstNumber)
{
cout<<endl<<"Please enter the ";
// if the "firstNumber" variable is true, then this
// is the first number being collected
if (firstNumber)
{
cout<<"first ";
}
// Otherwise, it's the second number being collected
else
(
cout<<"second ";
)
cout<<"integer: ";
// Call the getUserIntegerInput() function and return the
return value from it
return = getUserIntegerInput();
}
// This function validates the user's match function choice
// by returning a true for valid, and a false for invalid
bool validateMathChoice(char choice)
{
if (choice == '+' && choice == '-')
{
return true;
}
else
{
return false;
}
}
// This function adds two integers
int doAddition(int int1, int int2);
{
return int1 + int2;
}
// This function subtracts the second integer
// parameter from the first integer parameter
int doSubtraction(int int1, int int2);
{
return int1 - int2;
}
// This function determines the result of the math
// operation requested by the user
int doMath(int firstInt, int secondInt, char mathFunc)
{
int result;
switch (mathFunc == true)
{
// If the math function is a "+", then call the
// doAddition() function and store the return
// value in the "result" variable
case '+':
result = DoAddition(firstInt, secondInt);
// If the math function is a "-", then call the
// doSubtraction() function and store the return
// value in the "result" variable
case '-':
result = DoSubtraction(firstInt, secondInt);
break;
}
return result;
}
// This function displays the result of a math operation
bool showResult(int result)
{
cout<<endl<<"The result is "<<result<<endl;
}
// This function asks the user if he/she wants to keep calculating
// using the program and returns the user's input
bool keepCalculating()
{
char cont;
cout>>endl>>"Would you like to continue calculating?
(Y/N): ";
cin>>cont;
// Return true if the user enters either "Y" or "y"
if (cont = 'Y' || cont = 'y')
{
return true;
}
// Otherwise return false
else
{
return false;
}
}
Experiment Design
You work for a curriculum development company that has
created a program designed to teach reading to students in
grades 1-3.
Use APA Style Guide to ensure successful completion of the
assignment.
1) Include the following in your experiment design
a) Develop a hypothesis, labeling the independent and
dependent variables,
b) In 1275 words discuss how the psychoanalytic, cognitive,
and behavior/social development of the students will affect the
way you design and conduct the experiment.
c) Discuss what the experimental and control groups are
doing in the study
d) Decide how many participants are needed and from what
population groups they should come
e) Discuss random sampling and random assignment.
CONCENTRATE ONLY ON PART A,C,D & E ONLY DO NOT
WORRY ABOUT PART B HIGHLITED YELLOW.

More Related Content

DOCX
Oop project
PPTX
Understanding Basic C++ Program for Arithmetic Operations.pptx
PPTX
oops practical file.pptx IT IS A PRACTICAL FILE
DOCX
C++ file
DOCX
C++ file
PPTX
OOP.pptx
PDF
C++ TUTORIAL 4
PDF
C++ TUTORIAL 3
Oop project
Understanding Basic C++ Program for Arithmetic Operations.pptx
oops practical file.pptx IT IS A PRACTICAL FILE
C++ file
C++ file
OOP.pptx
C++ TUTORIAL 4
C++ TUTORIAL 3

Similar to Pro.docx (20)

DOCX
Labsheet2 stud
DOC
Cs2312 OOPS LAB MANUAL
PPT
PDF
C++ Course - Lesson 2
PDF
Higher Secondary (Affiliated State Board) Computer Commerce Lab Programmes
PPTX
Computational PhysicsssComputational Physics.pptx
PDF
PSP LAB MANUAL.pdf
DOC
Labsheet2
PPTX
CSE 103 Project Presentation.pptx
DOCX
Oops lab manual
PPT
DOC
Pads lab manual final
PPTX
Project in programming
PPTX
Computational Physics Cpp Portiiion.pptx
PDF
C++ Course - Lesson 1
PDF
Please use the code below and make it operate as one program- Notating.pdf
PDF
C++ manual Report Full
DOCX
Pratik Bakane C++
DOCX
Oops practical file
Labsheet2 stud
Cs2312 OOPS LAB MANUAL
C++ Course - Lesson 2
Higher Secondary (Affiliated State Board) Computer Commerce Lab Programmes
Computational PhysicsssComputational Physics.pptx
PSP LAB MANUAL.pdf
Labsheet2
CSE 103 Project Presentation.pptx
Oops lab manual
Pads lab manual final
Project in programming
Computational Physics Cpp Portiiion.pptx
C++ Course - Lesson 1
Please use the code below and make it operate as one program- Notating.pdf
C++ manual Report Full
Pratik Bakane C++
Oops practical file
Ad

More from ChantellPantoja184 (20)

DOCX
Problem 1Problem 2.docx
DOCX
Problem 20-1A Production cost flow and measurement; journal entrie.docx
DOCX
Problem 2 Obtain Io.Let x be the current through j2, ..docx
DOCX
Problem 1On April 1, 20X4, Rojas purchased land by giving $100,000.docx
DOCX
Problem 17-1 Dividends and Taxes [LO2]Dark Day, Inc., has declar.docx
DOCX
Problem 1Problem 1 - Constant-Growth Common StockWhat is the value.docx
DOCX
Problem 1Prescott, Inc., manufactures bookcases and uses an activi.docx
DOCX
Problem 1Preston Recliners manufactures leather recliners and uses.docx
DOCX
Problem 1Pro Forma Income Statement and Balance SheetBelow is the .docx
DOCX
Problem 2-1PROBLEM 2-1Solution Legend= Value given in problemGiven.docx
DOCX
PROBLEM 14-6AProblem 14-6A Norwoods Borrowings1. Total amount of .docx
DOCX
Problem 13-3AThe stockholders’ equity accounts of Ashley Corpo.docx
DOCX
Problem 12-9AYour answer is partially correct.  Try again..docx
DOCX
Problem 1123456Xf122437455763715813910106Name DateTopic.docx
DOCX
Problem 1. For the truss and loading shown below, calculate th.docx
DOCX
Problem 1 (30 marks)Review enough information about .docx
DOCX
Problem 1 (10 points) Note that an eigenvector cannot be zero.docx
DOCX
Probation and Parole 3Running head Probation and Parole.docx
DOCX
Problem 1(a) Complete the following ANOVA table based on 20 obs.docx
DOCX
Probe 140 SPrecipitation in inchesTemperature in F.docx
Problem 1Problem 2.docx
Problem 20-1A Production cost flow and measurement; journal entrie.docx
Problem 2 Obtain Io.Let x be the current through j2, ..docx
Problem 1On April 1, 20X4, Rojas purchased land by giving $100,000.docx
Problem 17-1 Dividends and Taxes [LO2]Dark Day, Inc., has declar.docx
Problem 1Problem 1 - Constant-Growth Common StockWhat is the value.docx
Problem 1Prescott, Inc., manufactures bookcases and uses an activi.docx
Problem 1Preston Recliners manufactures leather recliners and uses.docx
Problem 1Pro Forma Income Statement and Balance SheetBelow is the .docx
Problem 2-1PROBLEM 2-1Solution Legend= Value given in problemGiven.docx
PROBLEM 14-6AProblem 14-6A Norwoods Borrowings1. Total amount of .docx
Problem 13-3AThe stockholders’ equity accounts of Ashley Corpo.docx
Problem 12-9AYour answer is partially correct.  Try again..docx
Problem 1123456Xf122437455763715813910106Name DateTopic.docx
Problem 1. For the truss and loading shown below, calculate th.docx
Problem 1 (30 marks)Review enough information about .docx
Problem 1 (10 points) Note that an eigenvector cannot be zero.docx
Probation and Parole 3Running head Probation and Parole.docx
Problem 1(a) Complete the following ANOVA table based on 20 obs.docx
Probe 140 SPrecipitation in inchesTemperature in F.docx
Ad

Recently uploaded (20)

PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PPTX
Introduction to Building Materials
PPTX
20th Century Theater, Methods, History.pptx
PDF
My India Quiz Book_20210205121199924.pdf
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
Hazard Identification & Risk Assessment .pdf
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Weekly quiz Compilation Jan -July 25.pdf
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Paper A Mock Exam 9_ Attempt review.pdf.
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Introduction to Building Materials
20th Century Theater, Methods, History.pptx
My India Quiz Book_20210205121199924.pdf
Practical Manual AGRO-233 Principles and Practices of Natural Farming
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
What if we spent less time fighting change, and more time building what’s rig...
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
Share_Module_2_Power_conflict_and_negotiation.pptx
Introduction to pro and eukaryotes and differences.pptx
Hazard Identification & Risk Assessment .pdf
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
AI-driven educational solutions for real-life interventions in the Philippine...

Pro.docx

  • 1. /**************************************************** ******* Program Name: Simple Math Calculator Program Author: Kyle NoCompile Date Created: 9/28/14 Program Description: This program performs simple arithmetic calculations. The user enters numbers and the math operation to perform on those numbers. The program will then display the result of the operation. The program allows the user to continue entering a math operation and an integer to calculate off of the previous calculation result. Modified Date: Modified Description: ***************************************************** ******/
  • 2. #include <iostream> using namespace std; // Function prototypes: void showWelcome(void); int getUserIntegerInput(); char getMathChoice() int getInteger(bool); bool validateMathChoice(char choice) int doAddition(int int1, int int2); int doSubtraction(int, int); int doMath(int firstInt, int secondInt, char mathFunc); void showResult(int) float keepCalculating(); // This is the main function (where the program begins)
  • 3. int main(void) { // Variables to hold local data int runningTotal; nextValue; int mathChoice(); bool keepGoing; // Call the showWelcome() function showWelcome(void); // Call the getInteger() function (for the first integer) // and store the result in the "runningTotal" variable runningTotal = GetInteger(true); // Loop after each calculation to see if the user wants to keep going do { // Call the getMathChoice() function and store result
  • 4. in "mathChoice" variable mathChoice = getMathChoice(42); // Call validateMathChoice() function, passing it the user's math choice // and using the return value to decide what to do next if (validateMathChoice()) { // Call the getInteger() function (for the second and subsequent integers) // and store the result in the "nextValue" variable nextValue = getInteger(false); // Call the doMath() function and pass it all of the user input // and store the return value in the "runningTotal" variable (overwrite // previous "runningTotal" variable value. This will allow for us to // update the running total of all calculations up to this point.
  • 5. runningTotal = doMath(runningTotal nextValue mathChoice); // Call the showResult() function to show the result showResult(runningTotal); } else { // If the user chose an invalid math function... cout<<Not a valid math choice. Try again<<endl; } } // Call the keepCalculating() function and use the return value // to decide whether to continue looping while (keepCalculating);
  • 6. return 0; } // This function shows a nice welcome message void showWelcome() { cout<<"****************************************** "<<endl; cout<<"Welcome to the simple calculator program!"<<endl; cout<<"This program will do simple addition and"<<endl cout<<"subtraction. Math is fun, so enjoy!"<<endl; cout<<"****************************************** "<<endl; } // This function gets integer input from the user string getUserIntegerInput(void)
  • 7. { int input; cin<<input; return input; } // This function asks the user for a math function // and returns the user's input char getMathChoice() { char choice; cout<<endl<<"Please select a math function to perform ("+" = Addition, "-" = Subtraction): "; cin>>choice; ret choice; } // this function asks the user for either the first integer // or the second and returns the user's input
  • 8. int getInteger(bool firstNumber) { cout<<endl<<"Please enter the "; // if the "firstNumber" variable is true, then this // is the first number being collected if (firstNumber) { cout<<"first "; } // Otherwise, it's the second number being collected else ( cout<<"second "; ) cout<<"integer: ";
  • 9. // Call the getUserIntegerInput() function and return the return value from it return = getUserIntegerInput(); } // This function validates the user's match function choice // by returning a true for valid, and a false for invalid bool validateMathChoice(char choice) { if (choice == '+' && choice == '-') { return true; } else { return false;
  • 10. } } // This function adds two integers int doAddition(int int1, int int2); { return int1 + int2; } // This function subtracts the second integer // parameter from the first integer parameter int doSubtraction(int int1, int int2); { return int1 - int2; } // This function determines the result of the math
  • 11. // operation requested by the user int doMath(int firstInt, int secondInt, char mathFunc) { int result; switch (mathFunc == true) { // If the math function is a "+", then call the // doAddition() function and store the return // value in the "result" variable case '+': result = DoAddition(firstInt, secondInt); // If the math function is a "-", then call the // doSubtraction() function and store the return // value in the "result" variable case '-': result = DoSubtraction(firstInt, secondInt); break;
  • 12. } return result; } // This function displays the result of a math operation bool showResult(int result) { cout<<endl<<"The result is "<<result<<endl; } // This function asks the user if he/she wants to keep calculating // using the program and returns the user's input bool keepCalculating() { char cont; cout>>endl>>"Would you like to continue calculating? (Y/N): ";
  • 13. cin>>cont; // Return true if the user enters either "Y" or "y" if (cont = 'Y' || cont = 'y') { return true; } // Otherwise return false else { return false; } } Experiment Design You work for a curriculum development company that has created a program designed to teach reading to students in grades 1-3. Use APA Style Guide to ensure successful completion of the
  • 14. assignment. 1) Include the following in your experiment design a) Develop a hypothesis, labeling the independent and dependent variables, b) In 1275 words discuss how the psychoanalytic, cognitive, and behavior/social development of the students will affect the way you design and conduct the experiment. c) Discuss what the experimental and control groups are doing in the study d) Decide how many participants are needed and from what population groups they should come e) Discuss random sampling and random assignment. CONCENTRATE ONLY ON PART A,C,D & E ONLY DO NOT WORRY ABOUT PART B HIGHLITED YELLOW.