//Data: 18 42 78 22 42 5 42 57
#include <iostream>
#include "unorderedArrayListType.h"
using namespace std;
int main()
{
unorderedArrayListType intList(25);
int number;
cout << "Enter 8 integers: ";
for (int count = 0; count < 8;
count++)
{
cin >> number;
intList.insertEnd(number);
}
cout << endl;
cout << "intList: ";
intList.print();
cout << endl;
cout << "The smallest number in
intList: "
<< intList.min() << endl;
system("pause");
return 0;
}
arrayListType.h
arrayListType.Imp.cpp
unorderedArrayListType.h
unorderedArrayListTypeImp.cpp
EXPLANATION : We first declare an abstract function in the class arrayListType. Since, min() being an abstract function we need to define it in the class unorderedArrayListType. You need to add the lines of code written by me in your cpp files and run it to check the min() function.
class arrayListType {
public:
int min(); //Declaring an abstract function in the class
arrayListType
}
#include <iostream>
#include <algorithm>
#include "unorderedArrayListType.h"
#include arrayListType.h
using namespace std;
class unorderedArrayListType : arrayListType {
public:
int unorderedArrayListType::min() //Defining the function min in
the class unorderedArrayListType
{
int* i1;
i1 = std::min_element(List+1, List+8); // Finding the
minimum value in the given list which consists of 8 elements.
return *i1; // Returning the minimum value in the
list.
}
int main()
{
unorderedArrayListType intList(25);
int number;
cout << "Enter 8 integers: ";
for (int count = 0; count < 8;
count++)
{
cin >> number;
intList.insertEnd(number);
}
cout << endl;
cout << "intList: ";
intList.print();
cout << endl;
cout << "The smallest number in
intList: "
<< intList.min() << endl;
system("pause");
return 0;
}
}
THANKS,
PLEASE UPVOTE THE ANSWER AS IT WOULD BE OF GREAT HELP TO ME.
Do not change anything in the supplied code below that will be the Ch12_Ex9.cpp except to...
15.6: Fix the code to print the count from 1 to x (to loop x times) #include <iostream> // include the header file using namespace std; void count(int x){ for(int i=1; i<=x; i++){ cout<<x; } } int main(){ int x,i; cin >> x; count(x); return 0; } 15.7 Fix the nested for loops to print the count from 1 to x twice, e.g. "12....x12.....x" #include <iostream> // include the header file using namespace std; int main(){...
C++ Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original main(): int main() { double milesPerHour; double minutesTraveled; double hoursTraveled; double milesTraveled; cin >> milesPerHour; cin >> minutesTraveled; hoursTraveled = minutesTraveled / 60.0; milesTraveled = hoursTraveled * milesPerHour; cout << "Miles: " << milesTraveled << endl; return 0; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include <iostream> using...
c++ by microsoft visual studio i wanna the answer for header file , cpp file , main file. 1). The function remove of the class arrayListType removes only the first occurrence of an element. Add the function removeAll to the class arrayListType that would remove all occurrences of a given element. Also, write the definition of the function removeAll and a program to test this function. 2)Add the function min to the class arrayListType to return the smallest element of...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...
Write a c++ code into the given code to find composite numbers from the given random number list. The composite numbers is only counted once if there is a repeated number. I need to use this code and add on a code to find if the numbers generated is a composite function. Please help #include <cmath> #include <cstdlib> #include <ctime> #include <iostream> #include <vector> using namespace std; int main() { srand(time(NULL)); int size_of_list = 0; // the number of random...
How do I complete my code using an external file? External file: data.txt //the number 6 is in the external file Incomplete code: #include <iostream> #include <fstream> using namespace std; class example { int data[1]; public: example(); void read(ifstream &); }; example::example() { ifstream infile; infile.open("data.txt"); } void example::read(ifstream &infile) { infile >> data[1]; cout << data[1] << endl; } int main() { example example, read; //system("pause"); return 0;...
C++ Please complete the implementation of the following source code (Question3.cpp). You need to add your code in the source code where the comment “// your code” locates. After you finish the implementation, please also provide the output of your program. #include <iostream> using namespace std; class Shape { protected: // your code public: void setWidth (int w) { // your code } void setHeight (int h) { // your code } }; class Rectangle: public Shape { public: int...
C++ Language I have a class named movie which allows a movie object to take the name, movie and rating of a movie that the user inputs. Everything works fine but when the user enters a space in the movie's name, the next function that is called loops infinetly. I can't find the source of the problem. Down below are my .cpp and .h file for the program. #include <iostream> #include "movie.h" using namespace std; movie::movie() { movieName = "Not...
Complete a partially written C++ program that includes a function that return a value. The program is a simple calculator that prompts the user of 2 number and an operation (+, -, * or, /). The two number and the operator are passed to the function where the appropriate arithmetic operation is performed. The result is return to the main function () where the arithmetic operation and result are displayed. For example 3 * 4 = 12 The source code...
What did I do wrong with this C++ code? Assume that we don't need to ask users for the number of students. #include <iostream> #include <iomanip> using namespace std; int main() { float *grades; // a pointer used to point to an array int size; int count = 0; // track the number of grade/student float grade; // the grade of a student float average, total; // average grade and total grades //**************start your code here************************ cout<<"How many student grades...