Create a new file (in Dev C++)
Modify program above to use a vector instead of an array.
======================================================================================================
#include <iostream>
using namespace std;
int main() {
cout<<"Welcome! This program will find the minimum and maximum numbers in an array."<<endl;
cout<<"You will be asked to enter a number ten times. Then, the program will display"<<endl;
cout<<"the numbers back to you and indicate which is the smallest and which is the largest."<<endl<<endl;
int arr[10],min=1000,max=-1;
for(int i=0;i<10;i++){
cout<<"Please enter a number: ";
cin>>arr[i];
if(min>arr[i])
min=arr[i];
if(max<arr[i])
max=arr[i];
}
cout<<"\nValues: ";
for(int i=0;i<10;i++)
cout<<arr[i]<<" ";
cout<<"\nMinimum: "<<min<<endl;
cout<<"Maximum: "<<max<<endl;
cout<<"\nExiting program. Goodbye!";
}#include <iostream>
#include <vector>
using namespace std;
void hello();
void goodbye();
void printVector(vector<int> v);
int minVector(vector<int> v);
int maxVector(vector<int> v);
int main() {
int num;
vector<int> v;
hello();
for (int i = 0; i < 10; i++) {
cout << "Please enter a number: ";
cin >> num;
v.push_back(num);
}
printVector(v);
cout << "\nMinimum: " << minVector(v) << endl;
cout << "Maximum: " << maxVector(v) << endl;
goodbye();
}
void hello() {
cout << "Welcome! This program will find the minimum and maximum numbers in an array." << endl;
cout << "You will be asked to enter a number ten times. Then, the program will display" << endl;
cout << "the numbers back to you and indicate which is the smallest and which is the largest." << endl << endl;
}
void goodbye() {
cout << "\nExiting program. Goodbye!";
}
void printVector(vector<int> v) {
cout << "\nValues: ";
for (int i = 0; i < 10; i++)
cout << v[i] << " ";
cout << endl;
}
int minVector(vector<int> v) {
int num = v[0];
for (int i = 0; i < v.size(); ++i) {
if (v[i] < num)
num = v[i];
}
return num;
}
int maxVector(vector<int> v) {
int num = v[0];
for (int i = 0; i < v.size(); ++i) {
if (v[i] > num)
num = v[i];
}
return num;
}
Create a new file (in Dev C++) Modify program above to use a vector instead of...
part1 7.4 Create a new file (in Dev C++) and save it Write a program that uses parallel arrays to store payroll data for 5 employees. The program should display each employee name and then prompt for hours and rate. Calculate and store gross pay for each employee. After the data has been entered for all employees, display each employee's ID, name, hours, rate and gross pay as a table. Use the following arrays: arrEmpIDs: array of five integers, initialized...
What does this error message mean? "expected primary expression before int" Also, how do i get the program to repeat the numbers that were entered by the user back to me? this is my code below: // This program accepts a series of positive numbers // This code was last modified on 2/16/2020 #include <iostream> #include <iomanip> #include <cmath> using namespace std; void welcome(); int entrySubmission(int numbers); void acceptsNumbers(int); void goodbye(); int main() { welcome(); entrySubmission(int numbers); acceptsNumbers(int); goodbye(); return...
Modify PartTwo.cpp so that it is uses a vector, named vect, instead of an array. PartTwo.cpp Is posted here: // This program reads data from a file into an array. Then, it // asks the user for a number. It then compares the user number to // each element in the array, displays the array element if it is larger. // After looking at entire array, it displays the number of elements in the array larger // than the user...
In
c++ programming, can you please edit this program to meet these
requirements:
The program that needs editing:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int cal_avg(char* filenumbers, int n){
int a = 0;
int number[100];
ifstream filein(filenumbers);
if (!filein) {
cout << "Please enter a a correct file to read in the
numbers from";
}
while (!filein.eof()) {
filein >> number[a];
a++;
}
int total = number[0];
for (a = 0; a < n; a++) {...
/* Implementation of the main() method of the program. */ #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; class Student { public: // default constructor Student() { studentID = 0; studentFirst = "First"; studentMiddle = "Middle"; studentLast = "Last"; } void SetStudentID(int number) { studentID = number; } void SetStudentFirst(string name) { studentFirst = name; } void SetStudentMiddle(string name) { studentMiddle =...
Flow chart of this
program
#include <iostream> #include <cmath> using namespace std; int mainO double sum=0.0, ave-ee, int locmx, locmn int n; cout <<"Enter the number of students: "<<endl; cin >> ni double listln]; double max-0; double min-e; for (int i-e ; i<n ;i++) cout<s enter the gpa: "<cendli cin>>listli]; while (listlile i listli1>4) cout<s error,Try again "<cendl; cin>listlil: sun+=list[i]; N1 if (listli]>max) for(int isin itt) max=list [i]; 10cmx=1+1 ; else if (list [i] min) min=list [i]; locmn-i+1; ave sum/n;...
need help editing or rewriting java code, I have this program
running that creates random numbers and finds min, max, median ect.
from a group of numbers,array. I need to use a data class and a
constructor to run the code instead of how I have it written right
now. this is an example of what i'm being asked
for.
This is my code:
import java.util.Random;
import java.util.Scanner;
public class RandomArray {
// method to find the minimum number in...
please Code in c++ Create a new Library class. You will need both a header file and a source file for this class. The class will contain two data members: an array of Book objects the current number of books in the array Since the book array is moving from the main.cc file, you will also move the constant array size definition (MAX_ARR_SIZE) into the Library header file. Write the following functions for the Library class: a constructor that initializes...
I have a program that needs comments added to it: #include <iostream> #include <stdio.h> #include <conio.h> #include <windows.h> using namespace std; int main() { int m, s,h; cout << "A COUNTDOWN TIMER " << endl; cout << "enter time in hours here" << endl; cin >> h; cout << "enter time in minutes here " << endl; cin >> m; cout << "enter time in seconds here" << endl; cin >> s; cout << "Press any key to start" <<...
Q2. Consider the following C++ program that declares, allocates and fills in a1D array with random numbers between 0 and 100. The array is sent to a function that finds the indices of all items > 50. A new array is created and the indices are stored inside it. The size of the new arrays MUST BE the same as the number of items > 50. The function returns the new array which is then printed out by main. Here...