Question

You will develop a program that will read a list of integers into an array. Data entry will end when a negative number is ent
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================


#include <iostream>
#include <iomanip>

using namespace std;

void title();
int DataIn(int nos[]);
void Threshold(int nos[], int cnt);
int main()
{
//Declaring variables
const int SIZE = 100;
int nos[SIZE], cnt = 0;

title();

cnt = DataIn(nos);

Threshold(nos, cnt);

return 0;
}

void title()
{
cout << "This program inputs a list of numbers and then displays" << endl;
cout << "those integers above or equal to and below a nominal number." << endl;
cout << "Use a negative number to stop entering data." << endl;
cout << endl;
}
int DataIn(int nos[])
{
int num, cnt = 0;
cout << "Input the first number :";
cin >> num;
while (num > 0) {
nos[cnt] = num;
cnt++;
cout << "Input another number :";
cin >> num;
}

cout << endl;
return cnt;
}
void Threshold(int nos[], int cnt)
{
int nominalLevel;

cout << "What is the nominal level? ";
cin >> nominalLevel;

cout << "Above" << endl;
cout << "-----" << endl;
for (int i = 0; i < cnt; i++) {
if (nos[i] >= nominalLevel) {
cout << nos[i] << endl;
}
}

cout << "\nBelow" << endl;
cout << "-----" << endl;
for (int i = 0; i < cnt; i++) {
if (nos[i] < nominalLevel) {
cout << nos[i] << endl;
}
}
}

==================================

Output:

I C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\NumbersThresholdLevel.exe This program inputs a list of numbers and then display

=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
You will develop a program that will read a list of integers into an array. Data...
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
  • Consider the following program that reads a number of nonnegative integers into an array and prints...

    Consider the following program that reads a number of nonnegative integers into an array and prints the contents of the array.   Complete the missing parts, add new function prototypes and function definitions, and test the program several times. Add the following to the program: Write a void function that prints the list of nonnegative integers in reverse. Write a void function that prints all the numbers stored in the list that are greater than 10. It will also print the...

  • Write a recursive function in C++ that displays all nodes data (integers) in an array of...

    Write a recursive function in C++ that displays all nodes data (integers) in an array of linked lists. Assuming: struct node { int data; node * next; }; class arrayList { public: arrayList(); ~arrayList(); private: node ** head; int size; //(this is determined by another part of the program) }

  • LAB: How many negative numbers Write a program that generates a list of integers, and outputs...

    LAB: How many negative numbers Write a program that generates a list of integers, and outputs those integers, and then prints the number of negative elements. Create a method (static void fillArray(int [] array)) that uses Random to generate 50 values (Random.nextInt()), put each value in the array (make sure to pass the array in to this method as an argument). Write another method (static int printAndCountNeg(int [] array)) that prints each element’s value and count the number of negative...

  • C++ assignment Write a program that reads a sequence of integers and prints the following: 1....

    C++ assignment Write a program that reads a sequence of integers and prints the following: 1. The number of odd and even numbers of inputs Use a sentinel value to signal the end of inputs. If the sentinel value is the first you enter, give a message “NO input is entered!”. Input Validation: Do not accept a negative number.

  • Write a program that uses an int one-dimensional array list to input 10 integers representing amounts...

    Write a program that uses an int one-dimensional array list to input 10 integers representing amounts of money. Find the highest (maximum) amount and the lowest (minimum) amount. Output all the amounts and their difference to the highest amount side by side as shown in the sample output. c++ Chapter #8 (Arrays) and 6 (Value Returning and void Functions) Exercise #1: One-dimensional array manipulation Write a program that uses an int one-dimensional array list to input 10 integers representing amounts...

  • Please Help! Write a C++ program to read integers until 9999 is entered (called sentinel –...

    Please Help! Write a C++ program to read integers until 9999 is entered (called sentinel – sentinel is used to indicate the end of input and must not to be considered as the valid data for the computation). Perform the following operations for the integers entered by the user. Display the sum of the numbers less than 100 Display the smallest of the positive integers Display the largest of the negative integers Display how many integers are between 100 and...

  • Write a C Program that inputs an array of integers from the user along-with the length...

    Write a C Program that inputs an array of integers from the user along-with the length of array. The program then prints out the array of integers in reverse. (You do not need to change (re-assign) the elements in the array, only print the array in reverse.) The program uses a function call with array passed as call by reference. Part of the Program has been given here. You need to complete the Program by writing the function. #include<stdio.h> void...

  • Write a program that instantiates an array of integers named scores. Let the size of the...

    Write a program that instantiates an array of integers named scores. Let the size of the array be 10. The program then first invokes randomFill to fill the scores array with random numbers in the range of 0 -100. Once the array is filled with data, methods below are called such that the output resembles the expected output given. The program keeps prompting the user to see if they want to evaluate a new set of random data. Find below...

  • Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers

    Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers (words)that are read from the console. Be reminded that in a descending sort, the integers are sorted from the largest to the smallest. A “special value” 99999 will beused to signify the end of the input sequence. This value is not to be considered part of the input data set. However, any value greater than 99999 that...

  • 1. Please provide a C++ program which faithfully reads a list of non-negative integer scores, ultimately...

    1. Please provide a C++ program which faithfully reads a list of non-negative integer scores, ultimately terminating the list reading when the sentinel value (lets use -9999) is entered. The program should then correctly report the number of non-negative scores entered and the arithmetic mean (average) of those scores 2. Demonstrate your programs behavior in response to errors on input (that is, show that it faithfully rejects improper input such as alphabetic characters, decimal points, and commas). Here are some...

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
ADVERTISEMENT