Question

need help!!

Image for Bring in program for. cpp from the Lesson Set 5 source files folder. This program has the user input a numberImage for Bring in program for. cpp from the Lesson Set 5 source files folder. This program has the user input a number

0 0
Add a comment Improve this question Transcribed image text
Answer #1

\underline{original\;\;for.cpp}

#include <iostream>

using namespace std;

int main(){
   int value;
   int total = 0;
   int number;
   float mean;
   cout << "Please enter a positive integer: " << endl;
   cin >> value;
   if(value > 0){
       for(number = 1; number <= value; number++){
           total = total + number;
       }
       mean = static_cast<float>(total) / value;
       cout << "the mean average of the first " << value;
       cout << " positive integers is " << mean << endl;
   }
   else{
       cout << "invalid input - integer must be positive" << endl;
   }
   return 0;
}

\underline{Output:}

C: Program Files (x86)\Dev-Cppl ConsolePauser.exe Please enter a positive integer: the mean average of the first 9 positive i

\underline{Modified\;\;for.cpp}

#include <iostream>

using namespace std;

int main(){
   int value;
   float total = 0;
   int number;
   float mean;
   cout << "Please enter a positive integer: " << endl;
   cin >> value;
   if(value > 0){
       for(number = 1; number <= value; number++){
           total = total + number;
       }
       mean = total / value;
       cout << "the mean average of the first " << value;
       cout << " positive integers is " << mean << endl;
   }
   else{
       cout << "invalid input - integer must be positive" << endl;
   }
   return 0;
}

\underline{Output:}

C: Program Files (x86)\Dev-Cppl ConsolePauser.exe Please enter a positive integer: the mean average of the first 9 positive i

Add a comment
Know the answer?
Add Answer to:
need help!! Bring in program for. cpp from the Lesson Set 5 source files folder. This...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In python Simply write the Euclid algorithm in a form that takes two numbers from input...

    In python Simply write the Euclid algorithm in a form that takes two numbers from input and prints the gcd. The code does not need to check for valid input. It must work for any pair of positive integers. Create a separate program that uses the python timeit module to provide test run-times for your code. Provide at-least 5 sample runs. Create a third file that implements another algorithm to find the gcd. Provide a program that uses the timeit...

  • guys can you please help me to to write a pseudo code for this program and...

    guys can you please help me to to write a pseudo code for this program and write the code of the program in visual studio in.cpp. compile the program and run and take screenshot of the output and upload it. please help is really appreciated. UTF-8"CPP Instruction SU2019 LA X 119SU-COSC-1436- C Get Homework Help With Che X Facebook -1.amazonaws.com/blackboard.learn.xythos.prod/584b1d8497c84/98796290? response-content-dis 100% School of Engineering and Technology COSC1436-LAB1 Note: in the instruction of the lab change "yourLastName" to your last...

  • If x wame_Test_%232_2020W.pdf 2. Fill in the proper type specifiers in the two printf() statements in...

    If x wame_Test_%232_2020W.pdf 2. Fill in the proper type specifiers in the two printf() statements in the C program shown below. Save your completed file as <YourName>_Test2_2.cpp. (5 Marks] When you are finished, copy all of the source code into this Word document (replacing the code below). Make sure the formatting from Visual Studio is preserved. Question 2: Code Replace this code with your source code. *** Test #2, Question #2, ETEC128 #include <stdio.h> #include <stdlib.h> int main(void) //********** Enter...

  • Retrieve program randomAccess.cpp and the data file proverb.txt from the Lab 14 folder. The code is as follows: #include...

    Retrieve program randomAccess.cpp and the data file proverb.txt from the Lab 14 folder. The code is as follows: #include <iostream> #include <fstream> #include <cctype> using namespace std; 327 int main() { fstream inFile("proverb.txt", ios::in); long offset; char ch; char more; do { // Fill in the code to write to the screen // the current read position (with label) cout << "Enter an offset from the current read position: "; cin >> offset; // Fill in the code to move...

  • Hello, I need help with these two functions blockPrint and wordPrint.The program is written in C....

    Hello, I need help with these two functions blockPrint and wordPrint.The program is written in C. Thank you. ent the prototype for blockPrint. a) Intextfunctions.h, uncon Write the function definition for block Print dentical characters on a separate line. (See example This function should print each group (block) of ident output below) Example: Example: Incoming string: "Tbeehiklssuy Output (to the screen): Incoming string: "Java Programming Output to the screen: ee POOH da al Edit vour main function.include test calls and...

  • Overview Module 3 Assignment 2 features designing a program using pseudocode and then completing the program...

    Overview Module 3 Assignment 2 features designing a program using pseudocode and then completing the program in Python using strings. M3Lab2 asks you to write a Mortgage Loan Calculator. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. Instructions Pseudocode and Python Program with Strings M3Lab2.txt has some of the...

  • C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the...

    C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the class program with methods and variables 2. bill.cpp = contains the functions from class file 3. main.cpp = contains the main program. Please split this program into three files and make the program run. I have posted the code here. #include<iostream>...

  • I really need help with this python programming assignment Program Requirements For part 2, i need...

    I really need help with this python programming assignment Program Requirements For part 2, i need the following functions • get floats(): It take a single integer argument and returns a list of floats. where it was something like this def get_floats(n):   lst = []   for i in range(1,n+1):     val = float(input('Enter float '+str(i)+': '))     lst.append(val)   return lst • summer(): This non-void function takes a single list argument, and returns the sum of the list. However, it does not use...

  • Instructions: Consider the following C++ program. At the top you can see the interface for the...

    Instructions: Consider the following C++ program. At the top you can see the interface for the Student class. Below this is the implementation of the Student class methods. Finally, we have a very small main program. #include <string> #include <fstream> #include <iostream> using namespace std; class Student { public: Student(); Student(const Student & student); ~Student(); void Set(const int uaid, const string name, const float gpa); void Get(int & uaid, string & name, float & gpa) const; void Print() const; void...

  • 18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one...

    18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one part to lab lesson 11. The entire lab will be worth 100 points. Lab lesson 11 part 1 is worth 100 points For part 1 you will have 80 points if you enter the program and successfully run the program tests. An additional 20 points will be based on the style and formatting of your C++ code. Style points The 20 points for coding...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT